tor-browser

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

test_bug902651.html (1331B)


      1 <!DOCTYPE HTML>
      2 <title>Canvas test: canvas demotion</title>
      3 <script src="/tests/SimpleTest/SimpleTest.js"></script>
      4 <link rel="stylesheet" href="/tests/SimpleTest/test.css">
      5 <body>
      6 <canvas id="c" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
      7 <script>
      8 
      9 SimpleTest.waitForExplicitFinish();
     10 SimpleTest.requestFlakyTimeout("untriaged");
     11 addLoadEvent(function () {
     12 
     13 var canvas = document.getElementById('c');
     14 var ctx = canvas.getContext('2d');
     15 
     16 ctx.fillStyle = 'rgb(50, 50, 50)';
     17 ctx.fillRect(0, 0, 100, 50);
     18 ctx.translate(25, 25);
     19 
     20 SpecialPowers.wrap(ctx).demote();
     21 
     22 setTimeout(function() {
     23  ctx.fillStyle = 'rgb(127, 127, 127)';
     24  ctx.fillRect(0, 0, 10, 10);
     25 
     26  var pixels = ctx.getImageData(0, 0, 1, 1);
     27 
     28  ok(pixels.data[0] === 50, "pixels.data[0] expected 50, got " + pixels.data[0]);
     29  ok(pixels.data[1] === 50, "pixels.data[1] expected 50, got " + pixels.data[1]);
     30  ok(pixels.data[2] === 50, "pixels.data[2] expected 50, got " + pixels.data[2]);
     31 
     32  pixels = ctx.getImageData(25, 25, 1, 1);
     33 
     34  ok(pixels.data[0] === 127, "pixels.data[0] expected 127, got " + pixels.data[0]);
     35  ok(pixels.data[1] === 127, "pixels.data[1] expected 127, got " + pixels.data[1]);
     36  ok(pixels.data[2] === 127, "pixels.data[2] expected 127, got " + pixels.data[2]);
     37 
     38  SimpleTest.finish();
     39 }, 50);
     40 
     41 
     42 });
     43 </script>