OLD | NEW |
| (Empty) |
1 <html> | |
2 <head> | |
3 <script src="../../../resources/js-test.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 if (window.internals) | |
16 window.internals.settings.setWebGLErrorsToConsoleEnabled(false); | |
17 | |
18 var context = wtu.create3DContext(); | |
19 var program = wtu.loadStandardProgram(context); | |
20 var shader = wtu.loadStandardVertexShader(context); | |
21 var shouldGenerateGLError = wtu.shouldGenerateGLError; | |
22 | |
23 assertMsg(program != null, "Program Compiled"); | |
24 assertMsg(shader != null, "Shader Compiled"); | |
25 shouldGenerateGLError(context, context.INVALID_VALUE, "context.compileShader(und
efined)"); | |
26 shouldGenerateGLError(context, context.INVALID_VALUE, "context.linkProgram(undef
ined)"); | |
27 shouldGenerateGLError(context, context.INVALID_VALUE, "context.attachShader(unde
fined, undefined)"); | |
28 shouldGenerateGLError(context, context.INVALID_VALUE, "context.attachShader(prog
ram, undefined)"); | |
29 shouldGenerateGLError(context, context.INVALID_VALUE, "context.attachShader(unde
fined, shader)"); | |
30 shouldGenerateGLError(context, context.INVALID_VALUE, "context.detachShader(prog
ram, undefined)"); | |
31 shouldGenerateGLError(context, context.INVALID_VALUE, "context.detachShader(unde
fined, shader)"); | |
32 shouldGenerateGLError(context, context.INVALID_VALUE, "context.shaderSource(unde
fined, undefined)"); | |
33 shouldGenerateGLError(context, context.INVALID_VALUE, "context.shaderSource(unde
fined, 'foo')"); | |
34 shouldGenerateGLError(context, context.INVALID_VALUE, "context.bindAttribLocatio
n(undefined, 0, 'foo')"); | |
35 shouldThrow("context.bindBuffer(context.ARRAY_BUFFER, 0)"); | |
36 shouldThrow("context.bindFramebuffer(context.FRAMEBUFFER, 0)"); | |
37 shouldThrow("context.bindRenderbuffer(context.RENDERBUFFER, 0)"); | |
38 shouldThrow("context.bindTexture(context.TEXTURE_2D, 0)"); | |
39 shouldGenerateGLError(context, context.NO_ERROR, "context.bindBuffer(context.ARR
AY_BUFFER, null)"); | |
40 shouldGenerateGLError(context, context.NO_ERROR, "context.bindFramebuffer(contex
t.FRAMEBUFFER, null)"); | |
41 shouldGenerateGLError(context, context.NO_ERROR, "context.bindRenderbuffer(conte
xt.RENDERBUFFER, null)"); | |
42 shouldGenerateGLError(context, context.NO_ERROR, "context.bindTexture(context.TE
XTURE_2D, null)"); | |
43 shouldGenerateGLError(context, context.NO_ERROR, "context.bindBuffer(context.ARR
AY_BUFFER, undefined)"); | |
44 shouldGenerateGLError(context, context.NO_ERROR, "context.bindFramebuffer(contex
t.FRAMEBUFFER, undefined)"); | |
45 shouldGenerateGLError(context, context.NO_ERROR, "context.bindRenderbuffer(conte
xt.RENDERBUFFER, undefined)"); | |
46 shouldGenerateGLError(context, context.NO_ERROR, "context.bindTexture(context.TE
XTURE_2D, undefined)"); | |
47 shouldGenerateGLError(context, context.INVALID_OPERATION, "context.framebufferRe
nderbuffer(context.FRAMEBUFFER, context.DEPTH_ATTACHMENT, context.RENDERBUFFER,
null)"); | |
48 shouldGenerateGLError(context, context.INVALID_OPERATION, "context.framebufferTe
xture2D(context.FRAMEBUFFER, context.COLOR_ATTACHMENT0, context.TEXTURE_2D, null
, 0)"); | |
49 shouldGenerateGLError(context, context.INVALID_VALUE, "context.getProgramParamet
er(undefined, 0)"); | |
50 shouldGenerateGLError(context, context.INVALID_VALUE, "context.getProgramInfoLog
(undefined, 0)"); | |
51 shouldGenerateGLError(context, context.INVALID_VALUE, "context.getShaderParamete
r(undefined, 0)"); | |
52 shouldGenerateGLError(context, context.INVALID_VALUE, "context.getShaderInfoLog(
undefined, 0)"); | |
53 shouldGenerateGLError(context, context.INVALID_VALUE, "context.getShaderSource(u
ndefined)"); | |
54 shouldGenerateGLError(context, context.INVALID_VALUE, "context.getUniform(undefi
ned, null)"); | |
55 shouldGenerateGLError(context, context.INVALID_VALUE, "context.getUniformLocatio
n(undefined, 'foo')"); | |
56 | |
57 debug(""); | |
58 debug("check with bindings"); | |
59 context.bindBuffer(context.ARRAY_BUFFER, context.createBuffer()); | |
60 context.bindTexture(context.TEXTURE_2D, context.createTexture()); | |
61 shouldGenerateGLError(context, context.NO_ERROR, "context.bufferData(context.ARR
AY_BUFFER, 1, context.STATIC_DRAW)"); | |
62 shouldGenerateGLError(context, context.NO_ERROR, "context.getBufferParameter(con
text.ARRAY_BUFFER, context.BUFFER_SIZE)"); | |
63 shouldGenerateGLError(context, context.NO_ERROR, "context.texImage2D(context.TEX
TURE_2D, 0, context.RGBA, 1, 1, 0, context.RGBA, context.UNSIGNED_BYTE, new Uint
8Array([0,0,0,0]))"); | |
64 shouldGenerateGLError(context, context.NO_ERROR, "context.texParameteri(context.
TEXTURE_2D, context.TEXTURE_MIN_FILTER, context.NEAREST)"); | |
65 shouldGenerateGLError(context, context.NO_ERROR, "context.getTexParameter(contex
t.TEXTURE_2D, context.TEXTURE_MIN_FILTER)"); | |
66 | |
67 debug(""); | |
68 debug("check without bindings"); | |
69 context.bindBuffer(context.ARRAY_BUFFER, null); | |
70 context.bindTexture(context.TEXTURE_2D, null); | |
71 shouldGenerateGLError(context, context.INVALID_OPERATION, "context.bufferData(co
ntext.ARRAY_BUFFER, 1, context.STATIC_DRAW)"); | |
72 shouldGenerateGLError(context, context.INVALID_OPERATION, "context.getBufferPara
meter(context.ARRAY_BUFFER, context.BUFFER_SIZE)"); | |
73 shouldGenerateGLError(context, context.INVALID_OPERATION, "context.texImage2D(co
ntext.TEXTURE_2D, 0, context.RGBA, 1, 1, 0, context.RGBA, context.UNSIGNED_BYTE,
new Uint8Array([0,0,0,0]))"); | |
74 shouldGenerateGLError(context, context.INVALID_OPERATION, "context.texParameteri
(context.TEXTURE_2D, context.TEXTURE_MIN_FILTER, context.NEAREST)"); | |
75 shouldGenerateGLError(context, context.INVALID_OPERATION, "context.getTexParamet
er(context.TEXTURE_2D, context.TEXTURE_MIN_FILTER)"); | |
76 </script> | |
77 | |
78 </body> | |
79 </html> | |
OLD | NEW |