| <!-- |
| |
| /* |
| ** Copyright (c) 2012 The Khronos Group Inc. |
| ** |
| ** Permission is hereby granted, free of charge, to any person obtaining a |
| ** copy of this software and/or associated documentation files (the |
| ** "Materials"), to deal in the Materials without restriction, including |
| ** without limitation the rights to use, copy, modify, merge, publish, |
| ** distribute, sublicense, and/or sell copies of the Materials, and to |
| ** permit persons to whom the Materials are furnished to do so, subject to |
| ** the following conditions: |
| ** |
| ** The above copyright notice and this permission notice shall be included |
| ** in all copies or substantial portions of the Materials. |
| ** |
| ** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
| ** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
| ** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
| ** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY |
| ** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, |
| ** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE |
| ** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. |
| */ |
| |
| --> |
| |
| <!DOCTYPE html> |
| <html> |
| <head> |
| <meta charset="utf-8"> |
| <link rel="stylesheet" href="../../resources/js-test-style.css"/> |
| <script src="../../resources/js-test-pre.js"></script> |
| <script src="../resources/webgl-test-utils.js"></script> |
| </head> |
| <body> |
| <div id="description"></div> |
| <div id="console"></div> |
| |
| <script> |
| "use strict"; |
| var wtu = WebGLTestUtils; |
| description("Tests calling WebGL APIs with wrong argument types"); |
| |
| var context = wtu.create3DContext(); |
| var program = wtu.loadStandardProgram(context); |
| var shader = wtu.loadStandardVertexShader(context); |
| |
| function mayThrow(expression) { |
| wtu.shouldThrowOrGenerateGLError(context, [context.NO_ERROR, context.INVALID_VALUE, context.INVALID_OPERATION, context.INVALID_ENUM], expression); |
| } |
| |
| assertMsg(program != null, "Program Compiled"); |
| assertMsg(shader != null, "Shader Compiled"); |
| |
| var loc = context.getUniformLocation(program, "u_modelViewProjMatrix"); |
| assertMsg(loc != null, "getUniformLocation succeeded"); |
| |
| var testArguments = [ |
| { value: "foo", |
| throws: "yes" }, |
| { value: 0, |
| throws: "yes" }, |
| { value: null, |
| throws: "maybe" }, |
| { value: undefined, |
| throws: "maybe" } |
| ]; |
| |
| var argument; |
| |
| for (var i = 0; i < testArguments.length; ++i) { |
| var func, func2; |
| if (testArguments[i].throws == "yes") { |
| func = shouldThrow; |
| func2 = shouldThrow; |
| } else { |
| func = mayThrow; |
| func2 = shouldBeUndefined; |
| } |
| argument = testArguments[i].value; |
| func("context.compileShader(argument)"); |
| func("context.linkProgram(argument)"); |
| func("context.attachShader(program, argument)"); |
| func("context.attachShader(argument, shader)"); |
| func("context.detachShader(program, argument)"); |
| func("context.detachShader(argument, shader)"); |
| func("context.shaderSource(argument, 'foo')"); |
| func("context.bindAttribLocation(argument, 0, 'foo')"); |
| func("context.getProgramInfoLog(argument)"); |
| func("context.getProgramParameter(argument, 0)"); |
| func("context.getShaderInfoLog(argument)"); |
| func("context.getShaderParameter(argument, 0)"); |
| func("context.getShaderSource(argument)"); |
| func("context.getUniform(argument, loc)"); |
| func("context.getUniform(program, argument)"); |
| func("context.getUniformLocation(argument, 'u_modelViewProjMatrix')"); |
| |
| func2("context.useProgram(argument)"); |
| func2("context.bindBuffer(context.ARRAY_BUFFER, argument)"); |
| func2("context.bindFramebuffer(context.FRAMEBUFFER, argument)"); |
| func2("context.bindRenderbuffer(context.RENDERBUFFER, argument)"); |
| func2("context.bindTexture(context.TEXTURE_2D, argument)"); |
| func2("context.framebufferRenderbuffer(context.FRAMEBUFFER, context.DEPTH_ATTACHMENT, context.RENDERBUFFER, argument)"); |
| func2("context.framebufferTexture2D(context.FRAMEBUFFER, context.COLOR_ATTACHMENT0, context.TEXTURE_2D, argument, 0)"); |
| func2("context.uniform2fv(argument, new Float32Array([0.0, 0.0]))"); |
| func2("context.uniform2iv(argument, new Int32Array([0, 0]))"); |
| func2("context.uniformMatrix2fv(argument, false, new Float32Array([0.0, 0.0, 0.0, 0.0]))"); |
| } |
| |
| var successfullyParsed = true; |
| </script> |
| |
| <script src="../../resources/js-test-post.js"></script> |
| </body> |
| </html> |