JS Test Harness: Insert the stylesheet dynamically
[WebKit-https.git] / LayoutTests / fast / canvas / webgl / instanceof-test.html
1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"\r
2   "http://www.w3.org/TR/html4/loose.dtd">\r
3 <html>\r
4 <head>\r
5 <title>WebGL instanceof test.</title>\r
6 <script src="../../js/resources/js-test-pre.js"></script>\r
7 <script src="resources/webgl-test.js"> </script>\r
8 <script src="resources/webgl-test-utils.js"> </script>\r
9 </head>\r
10 <body>\r
11 <canvas id="canvas" width="2" height="2" style="width: 40px; height: 40px;"></canvas>\r
12 <script id="vshader" type="x-shader/x-vertex">\r
13 attribute vec4 vPosition;\r
14 varying vec2 texCoord;\r
15 void main()\r
16 {\r
17     gl_Position = vPosition;\r
18 }\r
19 </script>\r
20 \r
21 <script id="fshader" type="x-shader/x-fragment">\r
22 #ifdef GL_ES\r
23 precision mediump float;\r
24 #endif\r
25 uniform vec4 color;\r
26 void main()\r
27 {\r
28     gl_FragColor = color;\r
29 }\r
30 </script>\r
31 <script>\r
32 var wtu = WebGLTestUtils;\r
33 debug("Tests that instanceof works on WebGL objects.");\r
34 debug("");\r
35 var gl = create3DContext(document.getElementById("canvas"));\r
36 shouldBeTrue('gl instanceof WebGLRenderingContext');\r
37 shouldBeTrue('gl.createBuffer() instanceof WebGLBuffer');\r
38 shouldBeTrue('gl.createFramebuffer() instanceof WebGLFramebuffer');\r
39 shouldBeTrue('gl.createProgram() instanceof WebGLProgram');\r
40 shouldBeTrue('gl.createRenderbuffer() instanceof WebGLRenderbuffer');\r
41 shouldBeTrue('gl.createShader(gl.VERTEX_SHADER) instanceof WebGLShader');\r
42 shouldBeTrue('gl.createTexture() instanceof WebGLTexture');\r
43 \r
44 var program = wtu.setupProgram(\r
45     gl,\r
46     [wtu.loadShaderFromScript(gl, 'vshader', gl.VERTEX_SHADER),\r
47      wtu.loadShaderFromScript(gl, 'fshader', gl.FRAGMENT_SHADER)],\r
48     ['vPosition'], [0]);\r
49 \r
50 shouldBeTrue('gl.getUniformLocation(program, "color") instanceof WebGLUniformLocation');\r
51 shouldBeTrue('gl.getActiveAttrib(program, 0) instanceof WebGLActiveInfo');\r
52 shouldBeTrue('gl.getActiveUniform(program, 0) instanceof WebGLActiveInfo');\r
53 \r
54 debug("");\r
55 debug("Tests that those WebGL objects can not be constructed through new operator");\r
56 debug("");\r
57 \r
58 function shouldThrowWithNew(objectType, objectName)\r
59 {\r
60     try {\r
61         new objectType;\r
62         testFailed('new ' + objectName + ' did not throw');\r
63     } catch (e) {\r
64         testPassed('new ' + objectName + ' threw an error');\r
65     }\r
66 }\r
67 \r
68 shouldThrowWithNew(WebGLRenderingContext, 'WebGLRenderingContext');\r
69 shouldThrowWithNew(WebGLActiveInfo, 'WebGLActiveInfo');\r
70 shouldThrowWithNew(WebGLBuffer, 'WebGLBuffer');\r
71 shouldThrowWithNew(WebGLFramebuffer, 'WebGLFramebuffer');\r
72 shouldThrowWithNew(WebGLProgram, 'WebGLProgram');\r
73 shouldThrowWithNew(WebGLRenderbuffer, 'WebGLRenderbuffer');\r
74 shouldThrowWithNew(WebGLShader, 'WebGLShader');\r
75 shouldThrowWithNew(WebGLTexture, 'WebGLTexture');\r
76 shouldThrowWithNew(WebGLUniformLocation, 'WebGLUniformLocation');\r
77 \r
78 successfullyParsed = true;\r
79 </script>\r
80 </body>\r
81 <script src="../../js/resources/js-test-post.js"></script>\r
82 \r
83 <script>\r
84 </script>\r
85 \r
86 </body>\r
87 </html>\r
88 \r
89 \r