tizen beta release
[profile/ivi/webkit-efl.git] / LayoutTests / fast / canvas / webgl / null-object-behaviour.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 without providing the necessary objects");
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 shouldGenerateGLError(context, context.INVALID_VALUE, "context.compileShader(undefined)");
23 shouldGenerateGLError(context, context.INVALID_VALUE, "context.linkProgram(undefined)");
24 shouldGenerateGLError(context, context.INVALID_VALUE, "context.attachShader(undefined, undefined)");
25 shouldGenerateGLError(context, context.INVALID_VALUE, "context.attachShader(program, undefined)");
26 shouldGenerateGLError(context, context.INVALID_VALUE, "context.attachShader(undefined, shader)");
27 shouldGenerateGLError(context, context.INVALID_VALUE, "context.detachShader(program, undefined)");
28 shouldGenerateGLError(context, context.INVALID_VALUE, "context.detachShader(undefined, shader)");
29 shouldGenerateGLError(context, context.INVALID_VALUE, "context.shaderSource(undefined, undefined)");
30 shouldGenerateGLError(context, context.INVALID_VALUE, "context.shaderSource(undefined, 'foo')");
31 shouldGenerateGLError(context, context.INVALID_VALUE, "context.bindAttribLocation(undefined, 0, 'foo')");
32 shouldThrow("context.bindBuffer(context.ARRAY_BUFFER, 0)");
33 shouldThrow("context.bindFramebuffer(context.FRAMEBUFFER, 0)");
34 shouldThrow("context.bindRenderbuffer(context.RENDERBUFFER, 0)");
35 shouldThrow("context.bindTexture(context.TEXTURE_2D, 0)");
36 shouldGenerateGLError(context, context.NO_ERROR, "context.bindBuffer(context.ARRAY_BUFFER, null)");
37 shouldGenerateGLError(context, context.NO_ERROR, "context.bindFramebuffer(context.FRAMEBUFFER, null)");
38 shouldGenerateGLError(context, context.NO_ERROR, "context.bindRenderbuffer(context.RENDERBUFFER, null)");
39 shouldGenerateGLError(context, context.NO_ERROR, "context.bindTexture(context.TEXTURE_2D, null)");
40 shouldGenerateGLError(context, context.NO_ERROR, "context.bindBuffer(context.ARRAY_BUFFER, undefined)");
41 shouldGenerateGLError(context, context.NO_ERROR, "context.bindFramebuffer(context.FRAMEBUFFER, undefined)");
42 shouldGenerateGLError(context, context.NO_ERROR, "context.bindRenderbuffer(context.RENDERBUFFER, undefined)");
43 shouldGenerateGLError(context, context.NO_ERROR, "context.bindTexture(context.TEXTURE_2D, undefined)");
44 shouldGenerateGLError(context, context.INVALID_OPERATION, "context.framebufferRenderbuffer(context.FRAMEBUFFER, context.DEPTH_ATTACHMENT, context.RENDERBUFFER, null)");
45 shouldGenerateGLError(context, context.INVALID_OPERATION, "context.framebufferTexture2D(context.FRAMEBUFFER, context.COLOR_ATTACHMENT0, context.TEXTURE_2D, null, 0)");
46 shouldGenerateGLError(context, context.INVALID_VALUE, "context.getProgramParameter(undefined, 0)");
47 shouldGenerateGLError(context, context.INVALID_VALUE, "context.getProgramInfoLog(undefined, 0)");
48 shouldGenerateGLError(context, context.INVALID_VALUE, "context.getShaderParameter(undefined, 0)");
49 shouldGenerateGLError(context, context.INVALID_VALUE, "context.getShaderInfoLog(undefined, 0)");
50 shouldGenerateGLError(context, context.INVALID_VALUE, "context.getShaderSource(undefined)");
51 shouldGenerateGLError(context, context.INVALID_VALUE, "context.getUniform(undefined, null)");
52 shouldGenerateGLError(context, context.INVALID_VALUE, "context.getUniformLocation(undefined, 'foo')");
53
54 debug("");
55 debug("check with bindings");
56 context.bindBuffer(context.ARRAY_BUFFER, context.createBuffer());
57 context.bindTexture(context.TEXTURE_2D, context.createTexture());
58 shouldGenerateGLError(context, context.NO_ERROR, "context.bufferData(context.ARRAY_BUFFER, 1, context.STATIC_DRAW)");
59 shouldGenerateGLError(context, context.NO_ERROR, "context.getBufferParameter(context.ARRAY_BUFFER, context.BUFFER_SIZE)");
60 shouldGenerateGLError(context, context.NO_ERROR, "context.texImage2D(context.TEXTURE_2D, 0, context.RGBA, 1, 1, 0, context.RGBA, context.UNSIGNED_BYTE, new Uint8Array([0,0,0,0]))");
61 shouldGenerateGLError(context, context.NO_ERROR, "context.texParameteri(context.TEXTURE_2D, context.TEXTURE_MIN_FILTER, context.NEAREST)");
62 shouldGenerateGLError(context, context.NO_ERROR, "context.getTexParameter(context.TEXTURE_2D, context.TEXTURE_MIN_FILTER)");
63
64 debug("");
65 debug("check without bindings");
66 context.bindBuffer(context.ARRAY_BUFFER, null);
67 context.bindTexture(context.TEXTURE_2D, null);
68 shouldGenerateGLError(context, context.INVALID_OPERATION, "context.bufferData(context.ARRAY_BUFFER, 1, context.STATIC_DRAW)");
69 shouldGenerateGLError(context, context.INVALID_OPERATION, "context.getBufferParameter(context.ARRAY_BUFFER, context.BUFFER_SIZE)");
70 shouldGenerateGLError(context, context.INVALID_OPERATION, "context.texImage2D(context.TEXTURE_2D, 0, context.RGBA, 1, 1, 0, context.RGBA, context.UNSIGNED_BYTE, new Uint8Array([0,0,0,0]))");
71 shouldGenerateGLError(context, context.INVALID_OPERATION, "context.texParameteri(context.TEXTURE_2D, context.TEXTURE_MIN_FILTER, context.NEAREST)");
72 shouldGenerateGLError(context, context.INVALID_OPERATION, "context.getTexParameter(context.TEXTURE_2D, context.TEXTURE_MIN_FILTER)");
73 </script>
74
75 <script src="../../js/resources/js-test-post.js"></script>
76 </body>
77 </html>