|
1 <!DOCTYPE HTML> |
|
2 <html> |
|
3 <!-- |
|
4 https://bugzilla.mozilla.org/show_bug.cgi?id=517056 |
|
5 --> |
|
6 <head> |
|
7 <title>Test for Bug 517056</title> |
|
8 <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> |
|
9 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> |
|
10 </head> |
|
11 <body> |
|
12 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=517056">Mozilla Bug 517056</a> |
|
13 <p id="display"> |
|
14 <canvas id="c" width="1" height="1"></canvas> |
|
15 </p> |
|
16 <div id="content" style="display: none"> |
|
17 |
|
18 </div> |
|
19 <pre id="test"> |
|
20 <script type="application/javascript"> |
|
21 |
|
22 /** Test for Bug 517056 **/ |
|
23 var ctx = $("c").getContext('2d'); |
|
24 ctx.fillStyle = "black"; |
|
25 ctx.fillRect(0, 0, 1, 1); |
|
26 var data = ctx.getImageData(0, 0, 1, 1).data; |
|
27 is(data[0], 0, "Red channel of black should be 0"); |
|
28 is(data[1], 0, "Green channel of black should be 0"); |
|
29 is(data[2], 0, "Blue channel of black should be 0") |
|
30 is(data[3], 255, "Alpha channel of black should be opaque"); |
|
31 var img = new Image(); |
|
32 // Force a new URI every time, so that we don't run into stupid caching issues. |
|
33 img.src = "image_green-1x1.png?" + (new Date + 0) + Math.random(); |
|
34 // This shouldn't throw |
|
35 ctx.drawImage(img, 0, 0); |
|
36 var data = ctx.getImageData(0, 0, 1, 1).data; |
|
37 is(data[0], 0, "Red channel of black should be 0 and image should have been ignored"); |
|
38 is(data[1], 0, "Green channel of black should be 0 and image should have been ignored"); |
|
39 is(data[2], 0, "Blue channel of black should be 0 and image should have been ignored") |
|
40 is(data[3], 255, "Alpha channel of black should be opaque and image should have been ignored"); |
|
41 |
|
42 SimpleTest.waitForExplicitFinish(); |
|
43 img.onload = function() { |
|
44 ctx.drawImage(img, 0, 0); |
|
45 var data = ctx.getImageData(0, 0, 1, 1).data; |
|
46 is(data[0], 0, "Red channel of green should be 0"); |
|
47 is(data[1], 255, "Green channel of green should be 255"); |
|
48 is(data[2], 0, "Blue channel of green should be 0") |
|
49 is(data[3], 255, "Alpha channel of green should be opaque"); |
|
50 |
|
51 SimpleTest.finish(); |
|
52 } |
|
53 |
|
54 |
|
55 |
|
56 </script> |
|
57 </pre> |
|
58 </body> |
|
59 </html> |