OLD | NEW |
| (Empty) |
1 <!-- | |
2 Copyright (c) 2009 The Chromium Authors. All rights reserved. | |
3 Use of this source code is governed by a BSD-style license that can be | |
4 found in the LICENSE file. | |
5 --> | |
6 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" | |
7 "http://www.w3.org/TR/html4/loose.dtd"> | |
8 <html> | |
9 <head> | |
10 <title>WebGL instanceof test.</title> | |
11 <link rel="stylesheet" href="../resources/js-test-style.css"/> | |
12 <script src="../resources/js-test-pre.js"></script> | |
13 <script src="resources/webgl-test.js"> </script> | |
14 <script src="resources/webgl-test-utils.js"> </script> | |
15 </head> | |
16 <body> | |
17 <canvas id="canvas" width="2" height="2" style="width: 40px; height: 40px;"></ca
nvas> | |
18 <div id="description"></div> | |
19 <div id="console"></div> | |
20 <script id="vshader" type="x-shader/x-vertex"> | |
21 attribute vec4 vPosition; | |
22 varying vec2 texCoord; | |
23 void main() | |
24 { | |
25 gl_Position = vPosition; | |
26 } | |
27 </script> | |
28 | |
29 <script id="fshader" type="x-shader/x-fragment"> | |
30 #ifdef GL_ES | |
31 precision mediump float; | |
32 #endif | |
33 uniform vec4 color; | |
34 void main() | |
35 { | |
36 gl_FragColor = color; | |
37 } | |
38 </script> | |
39 <script> | |
40 var wtu = WebGLTestUtils; | |
41 debug("Tests that instanceof works on WebGL objects."); | |
42 debug(""); | |
43 var gl = create3DContext(document.getElementById("canvas")); | |
44 shouldBeTrue('gl instanceof WebGLRenderingContext'); | |
45 shouldBeTrue('gl.createBuffer() instanceof WebGLBuffer'); | |
46 shouldBeTrue('gl.createFramebuffer() instanceof WebGLFramebuffer'); | |
47 shouldBeTrue('gl.createProgram() instanceof WebGLProgram'); | |
48 shouldBeTrue('gl.createRenderbuffer() instanceof WebGLRenderbuffer'); | |
49 shouldBeTrue('gl.createShader(gl.VERTEX_SHADER) instanceof WebGLShader'); | |
50 shouldBeTrue('gl.createTexture() instanceof WebGLTexture'); | |
51 | |
52 var program = wtu.setupProgram( | |
53 gl, | |
54 [wtu.loadShaderFromScript(gl, 'vshader', gl.VERTEX_SHADER), | |
55 wtu.loadShaderFromScript(gl, 'fshader', gl.FRAGMENT_SHADER)], | |
56 ['vPosition'], [0]); | |
57 | |
58 shouldBeTrue('gl.getUniformLocation(program, "color") instanceof WebGLUniformLoc
ation'); | |
59 shouldBeTrue('gl.getActiveAttrib(program, 0) instanceof WebGLActiveInfo'); | |
60 shouldBeTrue('gl.getActiveUniform(program, 0) instanceof WebGLActiveInfo'); | |
61 | |
62 debug(""); | |
63 debug("Tests that those WebGL objects can not be constructed through new operato
r"); | |
64 debug(""); | |
65 | |
66 function shouldThrowWithNew(objectType, objectName) | |
67 { | |
68 try { | |
69 new objectType; | |
70 testFailed('new ' + objectName + ' did not throw'); | |
71 } catch (e) { | |
72 testPassed('new ' + objectName + ' threw an error'); | |
73 } | |
74 } | |
75 | |
76 shouldThrowWithNew(WebGLRenderingContext, 'WebGLRenderingContext'); | |
77 shouldThrowWithNew(WebGLActiveInfo, 'WebGLActiveInfo'); | |
78 shouldThrowWithNew(WebGLBuffer, 'WebGLBuffer'); | |
79 shouldThrowWithNew(WebGLFramebuffer, 'WebGLFramebuffer'); | |
80 shouldThrowWithNew(WebGLProgram, 'WebGLProgram'); | |
81 shouldThrowWithNew(WebGLRenderbuffer, 'WebGLRenderbuffer'); | |
82 shouldThrowWithNew(WebGLShader, 'WebGLShader'); | |
83 shouldThrowWithNew(WebGLTexture, 'WebGLTexture'); | |
84 shouldThrowWithNew(WebGLUniformLocation, 'WebGLUniformLocation'); | |
85 | |
86 successfullyParsed = true; | |
87 </script> | |
88 </body> | |
89 <script src="../resources/js-test-post.js"></script> | |
90 | |
91 <script> | |
92 </script> | |
93 | |
94 </body> | |
95 </html> | |
96 | |
97 | |
OLD | NEW |