Skip to content

Commit

Permalink
Migrate 'is invalid' exception messages to helper method.
Browse files Browse the repository at this point in the history
Drop lots of inline strings, and migrated the callsites to
ExceptionMessages::argumentNullOrIncorrect for consistency.

BUG=270033

Review URL: https://codereview.chromium.org/173573002

git-svn-id: svn://svn.chromium.org/blink/trunk@167516 bbb929c8-8fbe-4397-9dbb-9b2b20218538
  • Loading branch information
mkwst@chromium.org committed Feb 20, 2014
1 parent 2ef5592 commit 8ae0cd1
Show file tree
Hide file tree
Showing 25 changed files with 145 additions and 145 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ Success: s.extend(span2.firstChild, 4) raised IndexSizeError: Failed to execute
Success: s.extend(span2.firstChild, -1) raised IndexSizeError: Failed to execute 'extend' on 'Selection': -1 is not a valid offset..
Success: window.getSelection() is b.
Success: window.getSelection() is arbaz.
Success: s.extend() raised TypeMismatchError: Failed to execute 'extend' on 'Selection': The node provided is invalid..
Success: s.extend(null, 0) raised TypeMismatchError: Failed to execute 'extend' on 'Selection': The node provided is invalid..
Success: s.extend() raised TypeMismatchError: Failed to execute 'extend' on 'Selection': The 1st argument provided is either null, or an invalid Node object..
Success: s.extend(null, 0) raised TypeMismatchError: Failed to execute 'extend' on 'Selection': The 1st argument provided is either null, or an invalid Node object..
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Test canvas createImageData()
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".


PASS ctx.createImageData(null) threw exception NotSupportedError: Failed to execute 'createImageData' on 'CanvasRenderingContext2D': The ImageData provided is invalid..
PASS ctx.createImageData(null) threw exception NotSupportedError: Failed to execute 'createImageData' on 'CanvasRenderingContext2D': The 1st argument provided is either null, or an invalid ImageData object..
PASS imageData.width is 100
PASS imageData.height is 50
PASS imageData.data[32] is 255
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ This test checks behavior of Canvas::drawImage with a broken source image.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".


PASS ctx.drawImage(null, 0, 0) threw exception TypeMismatchError: Failed to execute 'drawImage' on 'CanvasRenderingContext2D': The image element provided is invalid..
PASS ctx.drawImage(null, 0, 0, 20, 20) threw exception TypeMismatchError: Failed to execute 'drawImage' on 'CanvasRenderingContext2D': The image element provided is invalid..
PASS ctx.drawImage(null, 0, 0, 20, 20, 0, 0, 20, 20) threw exception TypeMismatchError: Failed to execute 'drawImage' on 'CanvasRenderingContext2D': The image element provided is invalid..
PASS ctx.drawImage(null, 0, 0) threw exception TypeMismatchError: Failed to execute 'drawImage' on 'CanvasRenderingContext2D': The 1st argument provided is either null, or an invalid HTMLImageElement object..
PASS ctx.drawImage(null, 0, 0, 20, 20) threw exception TypeMismatchError: Failed to execute 'drawImage' on 'CanvasRenderingContext2D': The 1st argument provided is either null, or an invalid HTMLImageElement object..
PASS ctx.drawImage(null, 0, 0, 20, 20, 0, 0, 20, 20) threw exception TypeMismatchError: Failed to execute 'drawImage' on 'CanvasRenderingContext2D': The 1st argument provided is either null, or an invalid HTMLImageElement object..
PASS ctx.drawImage(invalidImage, 0, 0) is undefined
PASS ctx.drawImage(invalidImage, 0, 0, 20, 20) is undefined
PASS ctx.drawImage(invalidImage, 0, 0, 20, 20, 0, 0, 20, 20) is undefined
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ PASS context.bindRenderbuffer(context.RENDERBUFFER, argument) threw exception Ty
PASS context.bindTexture(context.TEXTURE_2D, argument) threw exception TypeError: Failed to execute 'bindTexture' on 'WebGLRenderingContext': parameter 2 is not of type 'WebGLTexture'..
PASS context.framebufferRenderbuffer(context.FRAMEBUFFER, context.DEPTH_ATTACHMENT, context.RENDERBUFFER, argument) threw exception TypeError: Failed to execute 'framebufferRenderbuffer' on 'WebGLRenderingContext': parameter 4 is not of type 'WebGLRenderbuffer'..
PASS context.framebufferTexture2D(context.FRAMEBUFFER, context.COLOR_ATTACHMENT0, context.TEXTURE_2D, argument, 0) threw exception TypeError: Failed to execute 'framebufferTexture2D' on 'WebGLRenderingContext': parameter 4 is not of type 'WebGLTexture'..
PASS context.uniform2fv(argument, new Float32Array([0.0, 0.0])) threw exception TypeError: Failed to execute 'uniform2fv' on 'WebGLRenderingContext': The 1st argument is not a WebGLUniformLocation object..
PASS context.uniform2iv(argument, new Int32Array([0, 0])) threw exception TypeError: Failed to execute 'uniform2iv' on 'WebGLRenderingContext': The 1st argument is not a WebGLUniformLocation object..
PASS context.uniformMatrix2fv(argument, false, new Float32Array([0.0, 0.0, 0.0, 0.0])) threw exception TypeError: Failed to execute 'uniformMatrix2fv' on 'WebGLRenderingContext': The 1st argument is not a WebGLUniformLocation object..
PASS context.getProgramParameter(argument, 0) threw exception TypeError: Failed to execute 'getProgramParameter' on 'WebGLRenderingContext': The 1st argument is not a WebGLProgram object..
PASS context.getShaderParameter(argument, 0) threw exception TypeError: Failed to execute 'getShaderParameter' on 'WebGLRenderingContext': The 1st argument is not a WebGLShader object..
PASS context.getUniform(argument, loc) threw exception TypeError: Failed to execute 'getUniform' on 'WebGLRenderingContext': The 1st argument is not a WebGLProgram object..
PASS context.getUniform(program, argument) threw exception TypeError: Failed to execute 'getUniform' on 'WebGLRenderingContext': The 2nd argument is not a WebGLUniformLocation object..
PASS context.uniform2fv(argument, new Float32Array([0.0, 0.0])) threw exception TypeError: Failed to execute 'uniform2fv' on 'WebGLRenderingContext': The 1st argument provided is either null, or an invalid WebGLUniformLocation object..
PASS context.uniform2iv(argument, new Int32Array([0, 0])) threw exception TypeError: Failed to execute 'uniform2iv' on 'WebGLRenderingContext': The 1st argument provided is either null, or an invalid WebGLUniformLocation object..
PASS context.uniformMatrix2fv(argument, false, new Float32Array([0.0, 0.0, 0.0, 0.0])) threw exception TypeError: Failed to execute 'uniformMatrix2fv' on 'WebGLRenderingContext': The 1st argument provided is either null, or an invalid WebGLUniformLocation object..
PASS context.getProgramParameter(argument, 0) threw exception TypeError: Failed to execute 'getProgramParameter' on 'WebGLRenderingContext': The 1st argument provided is either null, or an invalid WebGLProgram object..
PASS context.getShaderParameter(argument, 0) threw exception TypeError: Failed to execute 'getShaderParameter' on 'WebGLRenderingContext': The 1st argument provided is either null, or an invalid WebGLShader object..
PASS context.getUniform(argument, loc) threw exception TypeError: Failed to execute 'getUniform' on 'WebGLRenderingContext': The 1st argument provided is either null, or an invalid WebGLProgram object..
PASS context.getUniform(program, argument) threw exception TypeError: Failed to execute 'getUniform' on 'WebGLRenderingContext': The 2nd argument provided is either null, or an invalid WebGLUniformLocation object..
PASS context.getUniformLocation(argument, 'u_modelViewProjMatrix') threw exception TypeError: Failed to execute 'getUniformLocation' on 'WebGLRenderingContext': parameter 1 is not of type 'WebGLProgram'..
PASS context.getProgramInfoLog(argument) threw exception TypeError: Failed to execute 'getProgramInfoLog' on 'WebGLRenderingContext': parameter 1 is not of type 'WebGLProgram'..
PASS context.getShaderInfoLog(argument) threw exception TypeError: Failed to execute 'getShaderInfoLog' on 'WebGLRenderingContext': parameter 1 is not of type 'WebGLShader'..
Expand All @@ -46,13 +46,13 @@ PASS context.bindRenderbuffer(context.RENDERBUFFER, argument) threw exception Ty
PASS context.bindTexture(context.TEXTURE_2D, argument) threw exception TypeError: Failed to execute 'bindTexture' on 'WebGLRenderingContext': parameter 2 is not of type 'WebGLTexture'..
PASS context.framebufferRenderbuffer(context.FRAMEBUFFER, context.DEPTH_ATTACHMENT, context.RENDERBUFFER, argument) threw exception TypeError: Failed to execute 'framebufferRenderbuffer' on 'WebGLRenderingContext': parameter 4 is not of type 'WebGLRenderbuffer'..
PASS context.framebufferTexture2D(context.FRAMEBUFFER, context.COLOR_ATTACHMENT0, context.TEXTURE_2D, argument, 0) threw exception TypeError: Failed to execute 'framebufferTexture2D' on 'WebGLRenderingContext': parameter 4 is not of type 'WebGLTexture'..
PASS context.uniform2fv(argument, new Float32Array([0.0, 0.0])) threw exception TypeError: Failed to execute 'uniform2fv' on 'WebGLRenderingContext': The 1st argument is not a WebGLUniformLocation object..
PASS context.uniform2iv(argument, new Int32Array([0, 0])) threw exception TypeError: Failed to execute 'uniform2iv' on 'WebGLRenderingContext': The 1st argument is not a WebGLUniformLocation object..
PASS context.uniformMatrix2fv(argument, false, new Float32Array([0.0, 0.0, 0.0, 0.0])) threw exception TypeError: Failed to execute 'uniformMatrix2fv' on 'WebGLRenderingContext': The 1st argument is not a WebGLUniformLocation object..
PASS context.getProgramParameter(argument, 0) threw exception TypeError: Failed to execute 'getProgramParameter' on 'WebGLRenderingContext': The 1st argument is not a WebGLProgram object..
PASS context.getShaderParameter(argument, 0) threw exception TypeError: Failed to execute 'getShaderParameter' on 'WebGLRenderingContext': The 1st argument is not a WebGLShader object..
PASS context.getUniform(argument, loc) threw exception TypeError: Failed to execute 'getUniform' on 'WebGLRenderingContext': The 1st argument is not a WebGLProgram object..
PASS context.getUniform(program, argument) threw exception TypeError: Failed to execute 'getUniform' on 'WebGLRenderingContext': The 2nd argument is not a WebGLUniformLocation object..
PASS context.uniform2fv(argument, new Float32Array([0.0, 0.0])) threw exception TypeError: Failed to execute 'uniform2fv' on 'WebGLRenderingContext': The 1st argument provided is either null, or an invalid WebGLUniformLocation object..
PASS context.uniform2iv(argument, new Int32Array([0, 0])) threw exception TypeError: Failed to execute 'uniform2iv' on 'WebGLRenderingContext': The 1st argument provided is either null, or an invalid WebGLUniformLocation object..
PASS context.uniformMatrix2fv(argument, false, new Float32Array([0.0, 0.0, 0.0, 0.0])) threw exception TypeError: Failed to execute 'uniformMatrix2fv' on 'WebGLRenderingContext': The 1st argument provided is either null, or an invalid WebGLUniformLocation object..
PASS context.getProgramParameter(argument, 0) threw exception TypeError: Failed to execute 'getProgramParameter' on 'WebGLRenderingContext': The 1st argument provided is either null, or an invalid WebGLProgram object..
PASS context.getShaderParameter(argument, 0) threw exception TypeError: Failed to execute 'getShaderParameter' on 'WebGLRenderingContext': The 1st argument provided is either null, or an invalid WebGLShader object..
PASS context.getUniform(argument, loc) threw exception TypeError: Failed to execute 'getUniform' on 'WebGLRenderingContext': The 1st argument provided is either null, or an invalid WebGLProgram object..
PASS context.getUniform(program, argument) threw exception TypeError: Failed to execute 'getUniform' on 'WebGLRenderingContext': The 2nd argument provided is either null, or an invalid WebGLUniformLocation object..
PASS context.getUniformLocation(argument, 'u_modelViewProjMatrix') threw exception TypeError: Failed to execute 'getUniformLocation' on 'WebGLRenderingContext': parameter 1 is not of type 'WebGLProgram'..
PASS context.getProgramInfoLog(argument) threw exception TypeError: Failed to execute 'getProgramInfoLog' on 'WebGLRenderingContext': parameter 1 is not of type 'WebGLProgram'..
PASS context.getShaderInfoLog(argument) threw exception TypeError: Failed to execute 'getShaderInfoLog' on 'WebGLRenderingContext': parameter 1 is not of type 'WebGLShader'..
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ PASS shaders[0] == standardVert && shaders[1] == standardFrag || shaders[1] == s
PASS getError was expected value: NO_ERROR :
PASS gl.getAttachedShaders(null) is null
PASS getError was expected value: INVALID_VALUE :
PASS gl.getAttachedShaders(standardVert) threw exception TypeError: Failed to execute 'getAttachedShaders' on 'WebGLRenderingContext': The 1st argument is not a WebGLProgram object..
PASS gl.getAttachedShaders(standardVert) threw exception TypeError: Failed to execute 'getAttachedShaders' on 'WebGLRenderingContext': The 1st argument provided is either null, or an invalid WebGLProgram object..
PASS getError was expected value: NO_ERROR :
PASS gl.getBufferParameter(gl.ARRAY_BUFFER, gl.BUFFER_SIZE) is 16
PASS gl.getBufferParameter(gl.ARRAY_BUFFER, gl.BUFFER_USAGE) is gl.DYNAMIC_DRAW
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ This test checks whether passing wrong types to setAttributeNode causes a crash.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".


PASS element.setAttributeNode("style"); threw exception TypeMismatchError: Failed to execute 'setAttributeNode' on 'Element': The node provided is invalid..
PASS element.setAttributeNode(null); threw exception TypeMismatchError: Failed to execute 'setAttributeNode' on 'Element': The node provided is invalid..
PASS element.setAttributeNode(undefined); threw exception TypeMismatchError: Failed to execute 'setAttributeNode' on 'Element': The node provided is invalid..
PASS element.setAttributeNode(new Object); threw exception TypeMismatchError: Failed to execute 'setAttributeNode' on 'Element': The node provided is invalid..
PASS element.removeAttributeNode("style"); threw exception TypeMismatchError: Failed to execute 'removeAttributeNode' on 'Element': The node provided is invalid..
PASS element.removeAttributeNode(null); threw exception TypeMismatchError: Failed to execute 'removeAttributeNode' on 'Element': The node provided is invalid..
PASS element.removeAttributeNode(undefined); threw exception TypeMismatchError: Failed to execute 'removeAttributeNode' on 'Element': The node provided is invalid..
PASS element.removeAttributeNode(new Object); threw exception TypeMismatchError: Failed to execute 'removeAttributeNode' on 'Element': The node provided is invalid..
PASS element.setAttributeNode("style"); threw exception TypeMismatchError: Failed to execute 'setAttributeNode' on 'Element': The 1st argument provided is either null, or an invalid Attr object..
PASS element.setAttributeNode(null); threw exception TypeMismatchError: Failed to execute 'setAttributeNode' on 'Element': The 1st argument provided is either null, or an invalid Attr object..
PASS element.setAttributeNode(undefined); threw exception TypeMismatchError: Failed to execute 'setAttributeNode' on 'Element': The 1st argument provided is either null, or an invalid Attr object..
PASS element.setAttributeNode(new Object); threw exception TypeMismatchError: Failed to execute 'setAttributeNode' on 'Element': The 1st argument provided is either null, or an invalid Attr object..
PASS element.removeAttributeNode("style"); threw exception TypeMismatchError: Failed to execute 'removeAttributeNode' on 'Element': The 1st argument provided is either null, or an invalid Attr object..
PASS element.removeAttributeNode(null); threw exception TypeMismatchError: Failed to execute 'removeAttributeNode' on 'Element': The 1st argument provided is either null, or an invalid Attr object..
PASS element.removeAttributeNode(undefined); threw exception TypeMismatchError: Failed to execute 'removeAttributeNode' on 'Element': The 1st argument provided is either null, or an invalid Attr object..
PASS element.removeAttributeNode(new Object); threw exception TypeMismatchError: Failed to execute 'removeAttributeNode' on 'Element': The 1st argument provided is either null, or an invalid Attr object..
PASS successfullyParsed is true

TEST COMPLETE
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
This page tests calling document.importNode(null). If it passes, you'll see a "PASS" message below.

caught exception: NotSupportedError: Failed to execute 'importNode' on 'Document': The node provided is invalid.
caught exception: NotSupportedError: Failed to execute 'importNode' on 'Document': The 1st argument provided is either null, or an invalid Node object.
PASS: importNode(null) didn't crash
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Tests type enforcement on DOM setters.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".


PASS document.body = nodelist; threw exception HierarchyRequestError: Failed to set the 'body' property on 'Document': The node provided is invalid..
PASS document.body = nodelist; threw exception HierarchyRequestError: Failed to set the 'body' property on 'Document': The 1st argument provided is either null, or an invalid HTMLElement object..
PASS table.tHead = nodelist; threw exception NotFoundError: Failed to set the 'tHead' property on 'HTMLTableElement': The new child element is null..
PASS successfullyParsed is true

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ PASS getSelection().setBaseAndExtent(document.documentElement, -1, document.docu
PASS getSelection().setBaseAndExtent(document.documentElement, 0, document.documentElement, -1) threw exception IndexSizeError: Failed to execute 'setBaseAndExtent' on 'Selection': -1 is not a valid extent offset..
PASS getSelection().setPosition(document.documentElement, -1) threw exception IndexSizeError: Failed to execute 'setPosition' on 'Selection': -1 is not a valid offset..
PASS getSelection().getRangeAt(-1) threw exception IndexSizeError: Failed to execute 'getRangeAt' on 'Selection': -1 is not a valid index..
PASS getSelection().extend(0, -1) threw exception TypeMismatchError: Failed to execute 'extend' on 'Selection': The node provided is invalid..
PASS getSelection().extend(0, -1) threw exception TypeMismatchError: Failed to execute 'extend' on 'Selection': The 1st argument provided is either null, or an invalid Node object..
PASS getSelection().extend(document.documentElement, -1) threw exception IndexSizeError: Failed to execute 'extend' on 'Selection': -1 is not a valid offset..
PASS getSelection().extend(document.documentElement, 1000) threw exception IndexSizeError: Failed to execute 'extend' on 'Selection': 1000 is larger than the given node's length..
PASS successfullyParsed is true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

shouldThrow('getSelection().getRangeAt(-1)', '"IndexSizeError: Failed to execute \'getRangeAt\' on \'Selection\': -1 is not a valid index."');

shouldThrow('getSelection().extend(0, -1)', '"TypeMismatchError: Failed to execute \'extend\' on \'Selection\': The node provided is invalid."');
shouldThrow('getSelection().extend(0, -1)', '"TypeMismatchError: Failed to execute \'extend\' on \'Selection\': The 1st argument provided is either null, or an invalid Node object."');
shouldThrow('getSelection().extend(document.documentElement, -1)', '"IndexSizeError: Failed to execute \'extend\' on \'Selection\': -1 is not a valid offset."');
shouldThrow('getSelection().extend(document.documentElement, 1000)', '"IndexSizeError: Failed to execute \'extend\' on \'Selection\': 1000 is larger than the given node\'s length."');
</script>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
PASS document.evaluate('/body', document, 5, 0, null) threw exception TypeError: Failed to execute 'evaluate' on 'Document': The 3rd argument is not a resolver function..
PASS document.evaluate('/body', document, 'a resolver', 0, null) threw exception TypeError: Failed to execute 'evaluate' on 'Document': The 3rd argument is not a resolver function..
PASS document.evaluate('/body', document, 5, 0, null) threw exception TypeError: Failed to execute 'evaluate' on 'Document': The 3rd argument provided is either null, or an invalid XPathNSResolver object..
PASS document.evaluate('/body', document, 'a resolver', 0, null) threw exception TypeError: Failed to execute 'evaluate' on 'Document': The 3rd argument provided is either null, or an invalid XPathNSResolver object..
PASS document.evaluate('/body', document, Date, 0, null).toString() is "[object XPathResult]"
PASS successfullyParsed is true

Expand Down
Loading

0 comments on commit 8ae0cd1

Please sign in to comment.