content/canvas/test/reftest/webgl-disable-test.html

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

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 <html class="reftest-wait">
michael@0 3 <head>
michael@0 4 <meta charset="UTF-8">
michael@0 5
michael@0 6 <script type="text/javascript" src="webgl-utils.js"></script>
michael@0 7 <script type="text/javascript">
michael@0 8 /* Disable Test
michael@0 9 *
michael@0 10 * If we succeed in getting a WebGL context, we will fill
michael@0 11 * the canvas with red. If we fail to acquire a WebGL context,
michael@0 12 * we will use Canvas2D to instead fill it with green.
michael@0 13 *
michael@0 14 * Note that this test differs from the others in that
michael@0 15 * it will draw differently if it receives a WebGL context.
michael@0 16 * Other tests are designed to fallback silently to Canvas2D.
michael@0 17 *
michael@0 18 * We use this test to assure that when we disable WebGL,
michael@0 19 * WebGL does not function. This is trivially true for systems
michael@0 20 * that don't support WebGL. This test is not viable for testing
michael@0 21 * that WebGL works, as blocklisted systems will always draw green.
michael@0 22 */
michael@0 23
michael@0 24 "use strict";
michael@0 25
michael@0 26 function renderGL(gl) {
michael@0 27 gl.clearColor(1.0, 0.0, 0.0, 1.0);
michael@0 28 gl.clear(gl.COLOR_BUFFER_BIT);
michael@0 29 gl.finish();
michael@0 30 }
michael@0 31
michael@0 32 function renderBackup(canvas) {
michael@0 33 var context = canvas.getContext("2d");
michael@0 34 context.fillStyle = "rgba(0, 255, 0, 1.0)";
michael@0 35 context.fillRect(0, 0, 256, 256);
michael@0 36 }
michael@0 37
michael@0 38 function runTest() {
michael@0 39 var canvas = document.getElementById("canvas");
michael@0 40 var gl = initGL(canvas);
michael@0 41
michael@0 42 if (gl)
michael@0 43 renderGL(gl);
michael@0 44 else
michael@0 45 renderBackup(canvas);
michael@0 46
michael@0 47 waitForComposite(testComplete);
michael@0 48 }
michael@0 49
michael@0 50 function testComplete() {
michael@0 51 document.documentElement.removeAttribute("class");
michael@0 52 }
michael@0 53 </script>
michael@0 54 </head>
michael@0 55
michael@0 56 <body onload="rAF(runTest);">
michael@0 57 <canvas id="canvas" width="256" height="256"></canvas>
michael@0 58 </body>
michael@0 59
michael@0 60 </html>

mercurial