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 | <!DOCTYPE HTML> |
michael@0 | 2 | <meta http-equiv="content-type" content="text/html; charset=utf-8" /> |
michael@0 | 3 | |
michael@0 | 4 | <title>WebGL test: Drawing with a null program</title> |
michael@0 | 5 | |
michael@0 | 6 | <script src="/tests/SimpleTest/SimpleTest.js"></script> |
michael@0 | 7 | <link rel="stylesheet" href="/tests/SimpleTest/test.css"> |
michael@0 | 8 | <script src="driver-info.js"></script> |
michael@0 | 9 | <script src="webgl-util.js"></script> |
michael@0 | 10 | |
michael@0 | 11 | |
michael@0 | 12 | <script id="vs" type="x-shader/x-vertex"> |
michael@0 | 13 | |
michael@0 | 14 | void main(void) { |
michael@0 | 15 | gl_PointSize = 16.0; |
michael@0 | 16 | gl_Position = vec4(0.0, 0.0, 0.0, 1.0); |
michael@0 | 17 | } |
michael@0 | 18 | |
michael@0 | 19 | </script> |
michael@0 | 20 | <script id="fs" type="x-shader/x-fragment"> |
michael@0 | 21 | |
michael@0 | 22 | precision mediump float; |
michael@0 | 23 | |
michael@0 | 24 | void main(void) { |
michael@0 | 25 | gl_FragColor = vec4(0.0, 1.0, 0.0, 1.0); |
michael@0 | 26 | } |
michael@0 | 27 | |
michael@0 | 28 | </script> |
michael@0 | 29 | <body> |
michael@0 | 30 | <canvas id="c" width="64" height="64"></canvas> |
michael@0 | 31 | <script> |
michael@0 | 32 | |
michael@0 | 33 | // Give ourselves a scope to return early from: |
michael@0 | 34 | (function() { |
michael@0 | 35 | var gl = WebGLUtil.getWebGL('c'); |
michael@0 | 36 | if (!gl) { |
michael@0 | 37 | todo(false, 'WebGL is unavailable.'); |
michael@0 | 38 | return; |
michael@0 | 39 | } |
michael@0 | 40 | |
michael@0 | 41 | function errorFunc(str) { |
michael@0 | 42 | ok(false, 'Error: ' + str); |
michael@0 | 43 | } |
michael@0 | 44 | WebGLUtil.setErrorFunc(errorFunc); |
michael@0 | 45 | WebGLUtil.setWarningFunc(errorFunc); |
michael@0 | 46 | |
michael@0 | 47 | gl.disable(gl.DEPTH_TEST); |
michael@0 | 48 | |
michael@0 | 49 | var prog = WebGLUtil.createProgramByIds(gl, 'vs', 'fs'); |
michael@0 | 50 | if (!prog) { |
michael@0 | 51 | ok(false, 'Program linking should succeed.'); |
michael@0 | 52 | return; |
michael@0 | 53 | } |
michael@0 | 54 | |
michael@0 | 55 | function checkGLError(func, info, refValue) { |
michael@0 | 56 | if (!refValue) |
michael@0 | 57 | refValue = 0; |
michael@0 | 58 | |
michael@0 | 59 | var error = gl.getError(); |
michael@0 | 60 | func(error == refValue, |
michael@0 | 61 | '[' + info + '] gl.getError should be 0x' + refValue.toString(16) + |
michael@0 | 62 | ', was 0x' + error.toString(16) + '.'); |
michael@0 | 63 | } |
michael@0 | 64 | |
michael@0 | 65 | // Start drawing |
michael@0 | 66 | checkGLError(ok, 'after setup'); |
michael@0 | 67 | |
michael@0 | 68 | gl.useProgram(prog); |
michael@0 | 69 | gl.drawArrays(gl.POINTS, 0, 1); |
michael@0 | 70 | checkGLError(ok, 'after non-null-program DrawArrays'); |
michael@0 | 71 | |
michael@0 | 72 | gl.useProgram(null); |
michael@0 | 73 | gl.drawArrays(gl.POINTS, 0, 1); |
michael@0 | 74 | checkGLError(ok, 'after null-program DrawArrays', gl.INVALID_OPERATION); |
michael@0 | 75 | |
michael@0 | 76 | ok(true, 'Test complete.'); |
michael@0 | 77 | })(); |
michael@0 | 78 | |
michael@0 | 79 | </script> |
michael@0 | 80 |