328fd46649aaa403c2a0bdb30d7cce555510abe9
[framework/web/webkit-efl.git] / LayoutTests / fast / canvas / webgl / bad-arguments-test.html
1 <html>
2 <head>
3 <link rel="stylesheet" href="../../js/resources/js-test-style.css"/>
4 <script src="../../js/resources/js-test-pre.js"></script>
5 <script src="resources/webgl-test.js"></script>
6 <script src="resources/webgl-test-utils.js"></script>
7 </head>
8 <body>
9 <div id="description"></div>
10 <div id="console"></div>
11
12 <script>
13 var wtu = WebGLTestUtils;
14 description("Tests calling WebGL APIs with wrong argument types");
15
16 var context = wtu.create3DContext();
17 var program = wtu.loadStandardProgram(context);
18 var shader = wtu.loadStandardVertexShader(context);
19 var shouldGenerateGLError = wtu.shouldGenerateGLError;
20
21 assertMsg(program != null, "Program Compiled");
22 assertMsg(shader != null, "Shader Compiled");
23
24 var loc = context.getUniformLocation(program, "u_modelViewProjMatrix");
25 assertMsg(loc != null, "getUniformLocation succeeded");
26
27 var arguments = [
28   { value: "foo",
29     throw: true },
30   { value: 0,
31     throw: true },
32   { value: null,
33     throw: false },
34   { value: undefined,
35     throw: false }
36 ];
37
38 var argument;
39
40 function shouldBeEmptyString(command) {
41   shouldBe(command, "''");
42 }
43
44 for (var i = 0; i < arguments.length; ++i) {
45   var func, func2, func3;
46   if (arguments[i].throw) {
47     func = shouldThrow;
48     func2 = shouldThrow;
49     func3 = shouldThrow;
50   } else {
51     func = shouldBeUndefined;
52     func2 = shouldBeNull;
53     func3 = shouldBeEmptyString;
54   }
55   argument = arguments[i].value;
56   func("context.compileShader(argument)");
57   func("context.linkProgram(argument)");
58   func("context.attachShader(program, argument)");
59   func("context.attachShader(argument, shader)");
60   func("context.detachShader(program, argument)");
61   func("context.detachShader(argument, shader)");
62   func("context.useProgram(argument)");
63   func("context.shaderSource(argument, 'foo')");
64   func("context.bindAttribLocation(argument, 0, 'foo')");
65   func("context.bindBuffer(context.ARRAY_BUFFER, argument)");
66   func("context.bindFramebuffer(context.FRAMEBUFFER, argument)");
67   func("context.bindRenderbuffer(context.RENDERBUFFER, argument)");
68   func("context.bindTexture(context.TEXTURE_2D, argument)");
69   func("context.framebufferRenderbuffer(context.FRAMEBUFFER, context.DEPTH_ATTACHMENT, context.RENDERBUFFER, argument)");
70   func("context.framebufferTexture2D(context.FRAMEBUFFER, context.COLOR_ATTACHMENT0, context.TEXTURE_2D, argument, 0)");
71   func("context.uniform2fv(argument, new Float32Array([0.0, 0.0]))");
72   func("context.uniform2iv(argument, new Int32Array([0, 0]))");
73   func("context.uniformMatrix2fv(argument, false, new Float32Array([0.0, 0.0, 0.0, 0.0]))");
74
75   func2("context.getProgramParameter(argument, 0)");
76   func2("context.getShaderParameter(argument, 0)");
77   func2("context.getUniform(argument, loc)");
78   func2("context.getUniform(program, argument)");
79   func2("context.getUniformLocation(argument, 'u_modelViewProjMatrix')");
80
81   func3("context.getProgramInfoLog(argument)");
82   func3("context.getShaderInfoLog(argument)");
83   func3("context.getShaderSource(argument)");
84 }
85
86 successfullyParsed = true;
87 </script>
88
89 <script src="../../js/resources/js-test-post.js"></script>
90 </body>
91 </html>