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

Tue, 06 Jan 2015 21:39:09 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Tue, 06 Jan 2015 21:39:09 +0100
branch
TOR_BUG_9701
changeset 8
97036ab72558
permissions
-rw-r--r--

Conditionally force memory storage according to privacy.thirdparty.isolate;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.

     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