|
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 addLoadEvent(function () { |
|
11 |
|
12 var canvas = document.getElementById('c'); |
|
13 var ctx = canvas.getContext('2d'); |
|
14 |
|
15 ctx.fillStyle = 'rgb(50, 50, 50)'; |
|
16 ctx.fillRect(0, 0, 100, 50); |
|
17 ctx.translate(25, 25); |
|
18 |
|
19 SpecialPowers.wrap(ctx).demote(); |
|
20 |
|
21 setTimeout(function() { |
|
22 ctx.fillStyle = 'rgb(127, 127, 127)'; |
|
23 ctx.fillRect(0, 0, 10, 10); |
|
24 |
|
25 var pixels = ctx.getImageData(0, 0, 1, 1); |
|
26 |
|
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]); |
|
30 |
|
31 pixels = ctx.getImageData(25, 25, 1, 1); |
|
32 |
|
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]); |
|
36 |
|
37 SimpleTest.finish(); |
|
38 }, 50); |
|
39 |
|
40 |
|
41 }); |
|
42 </script> |
|
43 |