| OLD | NEW |
| (Empty) |
| 1 | |
| 2 <!DOCTYPE html> | |
| 3 <html> | |
| 4 <head> | |
| 5 <meta charset="utf-8"> | |
| 6 <title>WebGL instanceof test.</title> | |
| 7 <script src="../../../resources/js-test.js"></script> | |
| 8 <script src="resources/webgl-test.js"> </script> | |
| 9 <script src="resources/webgl-test-utils.js"> </script> | |
| 10 </head> | |
| 11 <body> | |
| 12 <canvas id="canvas" width="2" height="2" style="width: 40px; height: 40px;"></ca
nvas> | |
| 13 <div id="description"></div> | |
| 14 <div id="console"></div> | |
| 15 <script id="vshader" type="x-shader/x-vertex"> | |
| 16 attribute vec4 vPosition; | |
| 17 varying vec2 texCoord; | |
| 18 void main() | |
| 19 { | |
| 20 gl_Position = vPosition; | |
| 21 } | |
| 22 </script> | |
| 23 | |
| 24 <script id="fshader" type="x-shader/x-fragment"> | |
| 25 precision mediump float; | |
| 26 uniform vec4 color; | |
| 27 void main() | |
| 28 { | |
| 29 gl_FragColor = color; | |
| 30 } | |
| 31 </script> | |
| 32 <script> | |
| 33 var wtu = WebGLTestUtils; | |
| 34 description(document.title); | |
| 35 debug("Tests that instanceof works on WebGL objects."); | |
| 36 debug(""); | |
| 37 var gl = create3DContext(document.getElementById("canvas")); | |
| 38 shouldBeTrue('gl instanceof WebGLRenderingContext'); | |
| 39 shouldBeTrue('gl.createBuffer() instanceof WebGLBuffer'); | |
| 40 shouldBeTrue('gl.createFramebuffer() instanceof WebGLFramebuffer'); | |
| 41 shouldBeTrue('gl.createProgram() instanceof WebGLProgram'); | |
| 42 shouldBeTrue('gl.createRenderbuffer() instanceof WebGLRenderbuffer'); | |
| 43 shouldBeTrue('gl.createShader(gl.VERTEX_SHADER) instanceof WebGLShader'); | |
| 44 shouldBeTrue('gl.createTexture() instanceof WebGLTexture'); | |
| 45 | |
| 46 var program = wtu.setupProgram( | |
| 47 gl, | |
| 48 [wtu.loadShaderFromScript(gl, 'vshader', gl.VERTEX_SHADER), | |
| 49 wtu.loadShaderFromScript(gl, 'fshader', gl.FRAGMENT_SHADER)], | |
| 50 ['vPosition'], [0]); | |
| 51 | |
| 52 shouldBeTrue('gl.getUniformLocation(program, "color") instanceof WebGLUniformLoc
ation'); | |
| 53 shouldBeTrue('gl.getActiveAttrib(program, 0) instanceof WebGLActiveInfo'); | |
| 54 shouldBeTrue('gl.getActiveUniform(program, 0) instanceof WebGLActiveInfo'); | |
| 55 | |
| 56 debug(""); | |
| 57 debug("Tests that those WebGL objects can not be constructed through new operato
r"); | |
| 58 debug(""); | |
| 59 | |
| 60 function shouldThrowWithNew(objectType, objectName) | |
| 61 { | |
| 62 try { | |
| 63 new objectType; | |
| 64 testFailed('new ' + objectName + ' did not throw'); | |
| 65 } catch (e) { | |
| 66 testPassed('new ' + objectName + ' threw an error'); | |
| 67 } | |
| 68 } | |
| 69 | |
| 70 shouldThrowWithNew(window.WebGLRenderingContext, 'WebGLRenderingContext'); | |
| 71 shouldThrowWithNew(window.WebGLActiveInfo, 'WebGLActiveInfo'); | |
| 72 shouldThrowWithNew(window.WebGLBuffer, 'WebGLBuffer'); | |
| 73 shouldThrowWithNew(window.WebGLFramebuffer, 'WebGLFramebuffer'); | |
| 74 shouldThrowWithNew(window.WebGLProgram, 'WebGLProgram'); | |
| 75 shouldThrowWithNew(window.WebGLRenderbuffer, 'WebGLRenderbuffer'); | |
| 76 shouldThrowWithNew(window.WebGLShader, 'WebGLShader'); | |
| 77 shouldThrowWithNew(window.WebGLTexture, 'WebGLTexture'); | |
| 78 shouldThrowWithNew(window.WebGLUniformLocation, 'WebGLUniformLocation'); | |
| 79 shouldThrowWithNew(window.WebGLShaderPrecisionFormat, 'WebGLShaderPrecisionForma
t'); | |
| 80 | |
| 81 successfullyParsed = true; | |
| 82 </script> | |
| 83 | |
| 84 </body> | |
| 85 </html> | |
| 86 | |
| 87 | |
| OLD | NEW |