| OLD | NEW |
| (Empty) |
| 1 <!-- | |
| 2 Copyright (c) 2011 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> | |
| 7 <html> | |
| 8 <head> | |
| 9 <meta charset="utf-8"> | |
| 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 precision mediump float; | |
| 31 uniform vec4 color; | |
| 32 void main() | |
| 33 { | |
| 34 gl_FragColor = color; | |
| 35 } | |
| 36 </script> | |
| 37 <script> | |
| 38 var wtu = WebGLTestUtils; | |
| 39 debug("Tests that instanceof works on WebGL objects."); | |
| 40 debug(""); | |
| 41 var gl = create3DContext(document.getElementById("canvas")); | |
| 42 shouldBeTrue('gl instanceof WebGLRenderingContext'); | |
| 43 shouldBeTrue('gl.createBuffer() instanceof WebGLBuffer'); | |
| 44 shouldBeTrue('gl.createFramebuffer() instanceof WebGLFramebuffer'); | |
| 45 shouldBeTrue('gl.createProgram() instanceof WebGLProgram'); | |
| 46 shouldBeTrue('gl.createRenderbuffer() instanceof WebGLRenderbuffer'); | |
| 47 shouldBeTrue('gl.createShader(gl.VERTEX_SHADER) instanceof WebGLShader'); | |
| 48 shouldBeTrue('gl.createTexture() instanceof WebGLTexture'); | |
| 49 | |
| 50 var program = wtu.setupProgram( | |
| 51 gl, | |
| 52 [wtu.loadShaderFromScript(gl, 'vshader', gl.VERTEX_SHADER), | |
| 53 wtu.loadShaderFromScript(gl, 'fshader', gl.FRAGMENT_SHADER)], | |
| 54 ['vPosition'], [0]); | |
| 55 | |
| 56 shouldBeTrue('gl.getUniformLocation(program, "color") instanceof WebGLUniformLoc
ation'); | |
| 57 shouldBeTrue('gl.getActiveAttrib(program, 0) instanceof WebGLActiveInfo'); | |
| 58 shouldBeTrue('gl.getActiveUniform(program, 0) instanceof WebGLActiveInfo'); | |
| 59 | |
| 60 debug(""); | |
| 61 debug("Tests that those WebGL objects can not be constructed through new operato
r"); | |
| 62 debug(""); | |
| 63 | |
| 64 function shouldThrowWithNew(objectType, objectName) | |
| 65 { | |
| 66 try { | |
| 67 new objectType; | |
| 68 testFailed('new ' + objectName + ' did not throw'); | |
| 69 } catch (e) { | |
| 70 testPassed('new ' + objectName + ' threw an error'); | |
| 71 } | |
| 72 } | |
| 73 | |
| 74 shouldThrowWithNew(WebGLRenderingContext, 'WebGLRenderingContext'); | |
| 75 shouldThrowWithNew(WebGLActiveInfo, 'WebGLActiveInfo'); | |
| 76 shouldThrowWithNew(WebGLBuffer, 'WebGLBuffer'); | |
| 77 shouldThrowWithNew(WebGLFramebuffer, 'WebGLFramebuffer'); | |
| 78 shouldThrowWithNew(WebGLProgram, 'WebGLProgram'); | |
| 79 shouldThrowWithNew(WebGLRenderbuffer, 'WebGLRenderbuffer'); | |
| 80 shouldThrowWithNew(WebGLShader, 'WebGLShader'); | |
| 81 shouldThrowWithNew(WebGLTexture, 'WebGLTexture'); | |
| 82 shouldThrowWithNew(WebGLUniformLocation, 'WebGLUniformLocation'); | |
| 83 | |
| 84 successfullyParsed = true; | |
| 85 </script> | |
| 86 <script src="../resources/js-test-post.js"></script> | |
| 87 | |
| 88 </body> | |
| 89 </html> | |
| 90 | |
| 91 | |
| OLD | NEW |