content/canvas/test/reftest/webgl-hanging-fb-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 /* Hanging Framebuffer Test
     9  *
    10  * Clear the canvas to green, but create and bind a new framebuffer
    11  * before returning. This will fail if we blindly read from the bound
    12  * framebuffer, instead of binding to the screen and reading from that.
    13  *
    14  * How failure looks isn't well defined, since this is an empty framebuffer,
    15  * thus is incomplete, and should cause errors if it's read from.
    16  */
    18 "use strict";
    20 function renderGL(gl) {
    21   gl.clearColor(0.0, 1.0, 0.0, 1.0);
    22   gl.clear(gl.COLOR_BUFFER_BIT);
    24   var fb = gl.createFramebuffer();
    25   gl.bindFramebuffer(gl.FRAMEBUFFER, fb);
    27   gl.finish();
    28 }
    30 function renderFailure(canvas) {
    31   // This will also trigger RAF for us.
    32   var context = canvas.getContext("2d");
    33   context.fillText('WebGL failed.', 64, 64);
    34 }
    36 function runTest() {
    37   var canvas = document.getElementById("canvas");
    38   var gl = initGL(canvas);
    40   if (gl)
    41     renderGL(gl);
    42   else
    43     renderFailure(canvas);
    45   waitForComposite(testComplete);
    46 }
    48 function testComplete() {
    49   document.documentElement.removeAttribute("class");
    50 }
    51 </script>
    52 </head>
    54 <body onload="rAF(runTest);">
    55   <canvas id="canvas" width="256" height="256"></canvas>
    56 </body>
    58 </html>

mercurial