OLD | NEW |
(Empty) | |
| 1 <!-- |
| 2 |
| 3 /* |
| 4 ** Copyright (c) 2012 The Khronos Group Inc. |
| 5 ** |
| 6 ** Permission is hereby granted, free of charge, to any person obtaining a |
| 7 ** copy of this software and/or associated documentation files (the |
| 8 ** "Materials"), to deal in the Materials without restriction, including |
| 9 ** without limitation the rights to use, copy, modify, merge, publish, |
| 10 ** distribute, sublicense, and/or sell copies of the Materials, and to |
| 11 ** permit persons to whom the Materials are furnished to do so, subject to |
| 12 ** the following conditions: |
| 13 ** |
| 14 ** The above copyright notice and this permission notice shall be included |
| 15 ** in all copies or substantial portions of the Materials. |
| 16 ** |
| 17 ** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
| 18 ** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
| 19 ** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
| 20 ** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY |
| 21 ** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, |
| 22 ** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE |
| 23 ** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. |
| 24 */ |
| 25 |
| 26 --> |
| 27 |
| 28 <!DOCTYPE html> |
| 29 <html> |
| 30 <head> |
| 31 <meta charset="utf-8"> |
| 32 <link rel="stylesheet" href="../../resources/js-test-style.css"/> |
| 33 <script src="../../resources/js-test-pre.js"></script> |
| 34 <script src="../resources/webgl-test.js"></script> |
| 35 <script src="../resources/webgl-test-utils.js"></script> |
| 36 </head> |
| 37 <body> |
| 38 <div id="description"></div> |
| 39 <div id="console"></div> |
| 40 |
| 41 <script> |
| 42 "use strict"; |
| 43 var wtu = WebGLTestUtils; |
| 44 description("Tests calling WebGL APIs with wrong argument types"); |
| 45 |
| 46 var context = wtu.create3DContext(); |
| 47 var program = wtu.loadStandardProgram(context); |
| 48 var shader = wtu.loadStandardVertexShader(context); |
| 49 var shouldGenerateGLError = wtu.shouldGenerateGLError; |
| 50 |
| 51 assertMsg(program != null, "Program Compiled"); |
| 52 assertMsg(shader != null, "Shader Compiled"); |
| 53 |
| 54 var loc = context.getUniformLocation(program, "u_modelViewProjMatrix"); |
| 55 assertMsg(loc != null, "getUniformLocation succeeded"); |
| 56 |
| 57 var testArguments = [ |
| 58 { value: "foo", |
| 59 throws: true }, |
| 60 { value: 0, |
| 61 throws: true }, |
| 62 { value: null, |
| 63 throws: false }, |
| 64 { value: undefined, |
| 65 throws: false } |
| 66 ]; |
| 67 |
| 68 var argument; |
| 69 |
| 70 function shouldBeEmptyString(command) { |
| 71 shouldBe(command, "''"); |
| 72 } |
| 73 |
| 74 for (var i = 0; i < testArguments.length; ++i) { |
| 75 var func, func2, func3; |
| 76 if (testArguments[i].throws) { |
| 77 func = shouldThrow; |
| 78 func2 = shouldThrow; |
| 79 func3 = shouldThrow; |
| 80 } else { |
| 81 func = shouldBeUndefined; |
| 82 func2 = shouldBeNull; |
| 83 func3 = shouldBeEmptyString; |
| 84 } |
| 85 argument = testArguments[i].value; |
| 86 func("context.compileShader(argument)"); |
| 87 func("context.linkProgram(argument)"); |
| 88 func("context.attachShader(program, argument)"); |
| 89 func("context.attachShader(argument, shader)"); |
| 90 func("context.detachShader(program, argument)"); |
| 91 func("context.detachShader(argument, shader)"); |
| 92 func("context.useProgram(argument)"); |
| 93 func("context.shaderSource(argument, 'foo')"); |
| 94 func("context.bindAttribLocation(argument, 0, 'foo')"); |
| 95 func("context.bindBuffer(context.ARRAY_BUFFER, argument)"); |
| 96 func("context.bindFramebuffer(context.FRAMEBUFFER, argument)"); |
| 97 func("context.bindRenderbuffer(context.RENDERBUFFER, argument)"); |
| 98 func("context.bindTexture(context.TEXTURE_2D, argument)"); |
| 99 func("context.framebufferRenderbuffer(context.FRAMEBUFFER, context.DEPTH_ATTAC
HMENT, context.RENDERBUFFER, argument)"); |
| 100 func("context.framebufferTexture2D(context.FRAMEBUFFER, context.COLOR_ATTACHME
NT0, context.TEXTURE_2D, argument, 0)"); |
| 101 func("context.uniform2fv(argument, new Float32Array([0.0, 0.0]))"); |
| 102 func("context.uniform2iv(argument, new Int32Array([0, 0]))"); |
| 103 func("context.uniformMatrix2fv(argument, false, new Float32Array([0.0, 0.0, 0.
0, 0.0]))"); |
| 104 |
| 105 func2("context.getProgramParameter(argument, 0)"); |
| 106 func2("context.getShaderParameter(argument, 0)"); |
| 107 func2("context.getUniform(argument, loc)"); |
| 108 func2("context.getUniform(program, argument)"); |
| 109 func2("context.getUniformLocation(argument, 'u_modelViewProjMatrix')"); |
| 110 |
| 111 func3("context.getProgramInfoLog(argument)"); |
| 112 func3("context.getShaderInfoLog(argument)"); |
| 113 func3("context.getShaderSource(argument)"); |
| 114 } |
| 115 |
| 116 var successfullyParsed = true; |
| 117 </script> |
| 118 |
| 119 <script src="../../resources/js-test-post.js"></script> |
| 120 </body> |
| 121 </html> |
OLD | NEW |