content/canvas/test/test_bug902651.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 <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>
     9 SimpleTest.waitForExplicitFinish();
    10 addLoadEvent(function () {
    12 var canvas = document.getElementById('c');
    13 var ctx = canvas.getContext('2d');
    15 ctx.fillStyle = 'rgb(50, 50, 50)';
    16 ctx.fillRect(0, 0, 100, 50);
    17 ctx.translate(25, 25);
    19 SpecialPowers.wrap(ctx).demote();
    21 setTimeout(function() {
    22   ctx.fillStyle = 'rgb(127, 127, 127)';
    23   ctx.fillRect(0, 0, 10, 10);
    25   var pixels = ctx.getImageData(0, 0, 1, 1);
    27   ok(pixels.data[0] === 50, "pixels.data[0] expected 50, got " + pixels.data[0]);
    28   ok(pixels.data[1] === 50, "pixels.data[1] expected 50, got " + pixels.data[1]);
    29   ok(pixels.data[2] === 50, "pixels.data[2] expected 50, got " + pixels.data[2]);
    31   pixels = ctx.getImageData(25, 25, 1, 1);
    33   ok(pixels.data[0] === 127, "pixels.data[0] expected 127, got " + pixels.data[0]);
    34   ok(pixels.data[1] === 127, "pixels.data[1] expected 127, got " + pixels.data[1]);
    35   ok(pixels.data[2] === 127, "pixels.data[2] expected 127, got " + pixels.data[2]);
    37   SimpleTest.finish();
    38 }, 50);
    41 });
    42 </script>

mercurial