OLD | NEW |
| (Empty) |
1 <!-- | |
2 Copyright (C) 2009 Apple Computer, Inc. All rights reserved. | |
3 | |
4 Redistribution and use in source and binary forms, with or without | |
5 modification, are permitted provided that the following conditions | |
6 are met: | |
7 1. Redistributions of source code must retain the above copyright | |
8 notice, this list of conditions and the following disclaimer. | |
9 2. Redistributions in binary form must reproduce the above copyright | |
10 notice, this list of conditions and the following disclaimer in the | |
11 documentation and/or other materials provided with the distribution. | |
12 | |
13 THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY | |
14 EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
15 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | |
16 PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR | |
17 CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | |
18 EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | |
19 PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | |
20 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY | |
21 OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
22 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |
23 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
24 --> | |
25 <html> | |
26 <head> | |
27 <link rel="stylesheet" href="../resources/js-test-style.css"/> | |
28 <script src="../resources/js-test-pre.js"></script> | |
29 <script src="resources/webgl-test.js"></script> | |
30 <script src="resources/webgl-test-utils.js"></script> | |
31 </head> | |
32 <body> | |
33 <div id="description"></div> | |
34 <div id="console"></div> | |
35 | |
36 <script> | |
37 var wtu = WebGLTestUtils; | |
38 description("Tests calling WebGL APIs with wrong argument types"); | |
39 | |
40 var context = wtu.create3DContext(); | |
41 var program = wtu.loadStandardProgram(context); | |
42 var shader = wtu.loadStandardVertexShader(context); | |
43 var shouldGenerateGLError = wtu.shouldGenerateGLError; | |
44 | |
45 assertMsg(program != null, "Program Compiled"); | |
46 assertMsg(shader != null, "Shader Compiled"); | |
47 | |
48 var loc = context.getUniformLocation(program, "u_modelViewProjMatrix"); | |
49 assertMsg(loc != null, "getUniformLocation succeeded"); | |
50 | |
51 var arguments = [ | |
52 { value: "foo", | |
53 throws: true }, | |
54 { value: 0, | |
55 throws: true }, | |
56 { value: null, | |
57 throws: false }, | |
58 { value: undefined, | |
59 throws: false } | |
60 ]; | |
61 | |
62 var argument; | |
63 | |
64 function shouldBeEmptyString(command) { | |
65 shouldBe(command, "''"); | |
66 } | |
67 | |
68 for (var i = 0; i < arguments.length; ++i) { | |
69 var func, func2, func3; | |
70 if (arguments[i].throws) { | |
71 func = shouldThrow; | |
72 func2 = shouldThrow; | |
73 func3 = shouldThrow; | |
74 } else { | |
75 func = shouldBeUndefined; | |
76 func2 = shouldBeNull; | |
77 func3 = shouldBeEmptyString; | |
78 } | |
79 argument = arguments[i].value; | |
80 func("context.compileShader(argument)"); | |
81 func("context.linkProgram(argument)"); | |
82 func("context.attachShader(program, argument)"); | |
83 func("context.attachShader(argument, shader)"); | |
84 func("context.detachShader(program, argument)"); | |
85 func("context.detachShader(argument, shader)"); | |
86 func("context.useProgram(argument)"); | |
87 func("context.shaderSource(argument, 'foo')"); | |
88 func("context.bindAttribLocation(argument, 0, 'foo')"); | |
89 func("context.bindBuffer(context.ARRAY_BUFFER, argument)"); | |
90 func("context.bindFramebuffer(context.FRAMEBUFFER, argument)"); | |
91 func("context.bindRenderbuffer(context.RENDERBUFFER, argument)"); | |
92 func("context.bindTexture(context.TEXTURE_2D, argument)"); | |
93 func("context.framebufferRenderbuffer(context.FRAMEBUFFER, context.DEPTH_ATTAC
HMENT, context.RENDERBUFFER, argument)"); | |
94 func("context.framebufferTexture2D(context.FRAMEBUFFER, context.COLOR_ATTACHME
NT0, context.TEXTURE_2D, argument, 0)"); | |
95 func("context.uniform2fv(argument, new Float32Array([0.0, 0.0]))"); | |
96 func("context.uniform2iv(argument, new Int32Array([0, 0]))"); | |
97 func("context.uniformMatrix2fv(argument, false, new Float32Array([0.0, 0.0, 0.
0, 0.0]))"); | |
98 | |
99 func2("context.getProgramParameter(argument, 0)"); | |
100 func2("context.getShaderParameter(argument, 0)"); | |
101 func2("context.getUniform(argument, loc)"); | |
102 func2("context.getUniform(program, argument)"); | |
103 func2("context.getUniformLocation(argument, 'u_modelViewProjMatrix')"); | |
104 | |
105 func3("context.getProgramInfoLog(argument)"); | |
106 func3("context.getShaderInfoLog(argument)"); | |
107 func3("context.getShaderSource(argument)"); | |
108 } | |
109 | |
110 successfullyParsed = true; | |
111 </script> | |
112 | |
113 <script src="../resources/js-test-post.js"></script> | |
114 </body> | |
115 </html> | |
OLD | NEW |