content/canvas/test/test_bug902651.html

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/content/canvas/test/test_bug902651.html	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,43 @@
     1.4 +<!DOCTYPE HTML>
     1.5 +<title>Canvas test: canvas demotion</title>
     1.6 +<script src="/tests/SimpleTest/SimpleTest.js"></script>
     1.7 +<link rel="stylesheet" href="/tests/SimpleTest/test.css">
     1.8 +<body>
     1.9 +<canvas id="c" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
    1.10 +<script>
    1.11 +
    1.12 +SimpleTest.waitForExplicitFinish();
    1.13 +addLoadEvent(function () {
    1.14 +
    1.15 +var canvas = document.getElementById('c');
    1.16 +var ctx = canvas.getContext('2d');
    1.17 +
    1.18 +ctx.fillStyle = 'rgb(50, 50, 50)';
    1.19 +ctx.fillRect(0, 0, 100, 50);
    1.20 +ctx.translate(25, 25);
    1.21 +
    1.22 +SpecialPowers.wrap(ctx).demote();
    1.23 +
    1.24 +setTimeout(function() {
    1.25 +  ctx.fillStyle = 'rgb(127, 127, 127)';
    1.26 +  ctx.fillRect(0, 0, 10, 10);
    1.27 +
    1.28 +  var pixels = ctx.getImageData(0, 0, 1, 1);
    1.29 +
    1.30 +  ok(pixels.data[0] === 50, "pixels.data[0] expected 50, got " + pixels.data[0]);
    1.31 +  ok(pixels.data[1] === 50, "pixels.data[1] expected 50, got " + pixels.data[1]);
    1.32 +  ok(pixels.data[2] === 50, "pixels.data[2] expected 50, got " + pixels.data[2]);
    1.33 +
    1.34 +  pixels = ctx.getImageData(25, 25, 1, 1);
    1.35 +
    1.36 +  ok(pixels.data[0] === 127, "pixels.data[0] expected 127, got " + pixels.data[0]);
    1.37 +  ok(pixels.data[1] === 127, "pixels.data[1] expected 127, got " + pixels.data[1]);
    1.38 +  ok(pixels.data[2] === 127, "pixels.data[2] expected 127, got " + pixels.data[2]);
    1.39 +
    1.40 +  SimpleTest.finish();
    1.41 +}, 50);
    1.42 +
    1.43 +
    1.44 +});
    1.45 +</script>
    1.46 +

mercurial