tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

webgl-disable-test.html (1553B)


      1 <!DOCTYPE html>
      2 <html class="reftest-wait">
      3 <head>
      4 <meta charset="UTF-8">
      5 
      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 */
     23 
     24 "use strict";
     25 
     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 }
     31 
     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 }
     37 
     38 function runTest() {
     39  var canvas = document.getElementById("canvas");
     40  var gl = initGL(canvas);
     41 
     42  if (gl)
     43    renderGL(gl);
     44  else
     45    renderBackup(canvas);
     46 
     47  waitForComposite(testComplete);
     48 }
     49 
     50 function testComplete() {
     51  document.documentElement.removeAttribute("class");
     52 }
     53 </script>
     54 </head>
     55 
     56 <body onload="rAF(runTest);">
     57  <canvas id="canvas" width="256" height="256"></canvas>
     58 </body>
     59 
     60 </html>