4 https://bugzilla.mozilla.org/show_bug.cgi?id=517056
7 <title>Test for Bug
517056</title>
8 <script src=
"/tests/SimpleTest/SimpleTest.js"></script>
9 <link rel=
"stylesheet" type=
"text/css" href=
"/tests/SimpleTest/test.css"/>
12 <a target=
"_blank" href=
"https://bugzilla.mozilla.org/show_bug.cgi?id=517056">Mozilla Bug
517056</a>
14 <canvas id=
"c" width=
"1" height=
"1"></canvas>
16 <div id=
"content" style=
"display: none">
20 <script type=
"application/javascript">
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");
42 SimpleTest.waitForExplicitFinish();
43 img.onload = function() {
44 ctx.drawImage(img,
0,
0);
45 var loadData = ctx.getImageData(
0,
0,
1,
1).data;
46 is(loadData[
0],
0,
"Red channel of green should be 0");
47 is(loadData[
1],
255,
"Green channel of green should be 255");
48 is(loadData[
2],
0,
"Blue channel of green should be 0")
49 is(loadData[
3],
255,
"Alpha channel of green should be opaque");