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