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.

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

mercurial