content/canvas/test/test_bug902651.html

Wed, 31 Dec 2014 13:27:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 13:27:57 +0100
branch
TOR_BUG_3246
changeset 6
8bccb770b82d
permissions
-rw-r--r--

Ignore runtime configuration files generated during quality assurance.

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

mercurial