Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | <!-- |
michael@0 | 2 | Copyright (c) 2011 The Chromium Authors. All rights reserved. |
michael@0 | 3 | Use of this source code is governed by a BSD-style license that can be |
michael@0 | 4 | found in the LICENSE file. |
michael@0 | 5 | --> |
michael@0 | 6 | <!DOCTYPE html> |
michael@0 | 7 | <html> |
michael@0 | 8 | <head> |
michael@0 | 9 | <meta charset="utf-8"> |
michael@0 | 10 | <title>WebGL instanceof test.</title> |
michael@0 | 11 | <link rel="stylesheet" href="../../resources/js-test-style.css"/> |
michael@0 | 12 | <script src="../../resources/js-test-pre.js"></script> |
michael@0 | 13 | <script src="../resources/webgl-test.js"> </script> |
michael@0 | 14 | <script src="../resources/webgl-test-utils.js"> </script> |
michael@0 | 15 | </head> |
michael@0 | 16 | <body> |
michael@0 | 17 | <canvas id="canvas" width="2" height="2" style="width: 40px; height: 40px;"></canvas> |
michael@0 | 18 | <div id="description"></div> |
michael@0 | 19 | <div id="console"></div> |
michael@0 | 20 | <script id="vshader" type="x-shader/x-vertex"> |
michael@0 | 21 | attribute vec4 vPosition; |
michael@0 | 22 | varying vec2 texCoord; |
michael@0 | 23 | void main() |
michael@0 | 24 | { |
michael@0 | 25 | gl_Position = vPosition; |
michael@0 | 26 | } |
michael@0 | 27 | </script> |
michael@0 | 28 | |
michael@0 | 29 | <script id="fshader" type="x-shader/x-fragment"> |
michael@0 | 30 | precision mediump float; |
michael@0 | 31 | uniform vec4 color; |
michael@0 | 32 | void main() |
michael@0 | 33 | { |
michael@0 | 34 | gl_FragColor = color; |
michael@0 | 35 | } |
michael@0 | 36 | </script> |
michael@0 | 37 | <script> |
michael@0 | 38 | var wtu = WebGLTestUtils; |
michael@0 | 39 | description(document.title); |
michael@0 | 40 | debug("Tests that instanceof works on WebGL objects."); |
michael@0 | 41 | debug(""); |
michael@0 | 42 | var gl = wtu.create3DContext("canvas"); |
michael@0 | 43 | shouldBeTrue('gl instanceof WebGLRenderingContext'); |
michael@0 | 44 | shouldBeTrue('gl.createBuffer() instanceof WebGLBuffer'); |
michael@0 | 45 | shouldBeTrue('gl.createFramebuffer() instanceof WebGLFramebuffer'); |
michael@0 | 46 | shouldBeTrue('gl.createProgram() instanceof WebGLProgram'); |
michael@0 | 47 | shouldBeTrue('gl.createRenderbuffer() instanceof WebGLRenderbuffer'); |
michael@0 | 48 | shouldBeTrue('gl.createShader(gl.VERTEX_SHADER) instanceof WebGLShader'); |
michael@0 | 49 | shouldBeTrue('gl.createTexture() instanceof WebGLTexture'); |
michael@0 | 50 | |
michael@0 | 51 | var program = wtu.setupProgram(gl, ['vshader', 'fshader'], ['vPosition'], [0]); |
michael@0 | 52 | |
michael@0 | 53 | shouldBeTrue('gl.getUniformLocation(program, "color") instanceof WebGLUniformLocation'); |
michael@0 | 54 | shouldBeTrue('gl.getActiveAttrib(program, 0) instanceof WebGLActiveInfo'); |
michael@0 | 55 | shouldBeTrue('gl.getActiveUniform(program, 0) instanceof WebGLActiveInfo'); |
michael@0 | 56 | |
michael@0 | 57 | debug(""); |
michael@0 | 58 | debug("Tests that those WebGL objects can not be constructed through new operator"); |
michael@0 | 59 | debug(""); |
michael@0 | 60 | |
michael@0 | 61 | function shouldThrowWithNew(objectType, objectName) |
michael@0 | 62 | { |
michael@0 | 63 | try { |
michael@0 | 64 | new objectType; |
michael@0 | 65 | testFailed('new ' + objectName + ' did not throw'); |
michael@0 | 66 | } catch (e) { |
michael@0 | 67 | testPassed('new ' + objectName + ' threw an error'); |
michael@0 | 68 | } |
michael@0 | 69 | } |
michael@0 | 70 | |
michael@0 | 71 | shouldThrowWithNew(window.WebGLRenderingContext, 'WebGLRenderingContext'); |
michael@0 | 72 | shouldThrowWithNew(window.WebGLActiveInfo, 'WebGLActiveInfo'); |
michael@0 | 73 | shouldThrowWithNew(window.WebGLBuffer, 'WebGLBuffer'); |
michael@0 | 74 | shouldThrowWithNew(window.WebGLFramebuffer, 'WebGLFramebuffer'); |
michael@0 | 75 | shouldThrowWithNew(window.WebGLProgram, 'WebGLProgram'); |
michael@0 | 76 | shouldThrowWithNew(window.WebGLRenderbuffer, 'WebGLRenderbuffer'); |
michael@0 | 77 | shouldThrowWithNew(window.WebGLShader, 'WebGLShader'); |
michael@0 | 78 | shouldThrowWithNew(window.WebGLTexture, 'WebGLTexture'); |
michael@0 | 79 | shouldThrowWithNew(window.WebGLUniformLocation, 'WebGLUniformLocation'); |
michael@0 | 80 | shouldThrowWithNew(window.WebGLShaderPrecisionFormat, 'WebGLShaderPrecisionFormat'); |
michael@0 | 81 | |
michael@0 | 82 | successfullyParsed = true; |
michael@0 | 83 | </script> |
michael@0 | 84 | <script>finishTest();</script> |
michael@0 | 85 | |
michael@0 | 86 | </body> |
michael@0 | 87 | </html> |
michael@0 | 88 | |
michael@0 | 89 |