1 description("Series of tests for canvas alpha");
4 testRunner.dumpAsTextWithPixelResults();
6 var canvas1 = document.getElementById("canvas1");
7 var canvas2 = document.getElementById("canvas2");
8 var canvas3 = document.getElementById("canvas3");
9 var canvas4 = document.getElementById("canvas4");
11 var ctx1 = canvas1.getContext("2d");
12 var ctx2 = canvas2.getContext("2d", {} );
13 var ctx3 = canvas3.getContext("2d", { alpha: false } );
14 var ctx4 = canvas4.getContext("2d", { alpha: true } );
16 shouldBe("ctx1.getContextAttributes().alpha", "true");
17 var imgData1 = ctx1.getImageData(0, 0, 1, 1);
18 shouldBe("imgData1.data[0]", "0");
19 shouldBe("imgData1.data[1]", "0");
20 shouldBe("imgData1.data[2]", "0");
21 shouldBe("imgData1.data[3]", "0");
23 shouldBe("ctx2.getContextAttributes().alpha", "true");
24 var imgData2 = ctx2.getImageData(0, 0, 1, 1);
25 shouldBe("imgData2.data[0]", "0");
26 shouldBe("imgData2.data[1]", "0");
27 shouldBe("imgData2.data[2]", "0");
28 shouldBe("imgData2.data[3]", "0");
30 shouldBe("ctx3.getContextAttributes().alpha", "false");
32 shouldBe("ctx4.getContextAttributes().alpha", "true");
33 var imgData4 = ctx4.getImageData(0, 0, 1, 1);
34 shouldBe("imgData4.data[0]", "0");
35 shouldBe("imgData4.data[1]", "0");
36 shouldBe("imgData4.data[2]", "0");
37 shouldBe("imgData4.data[3]", "0");
39 // Check that mutating the returned value of getContextAttributes() doesn't
40 // affect the existing canvas, or the values of subsequent calls to
41 // getContextAttributes().
42 var attrs = ctx4.getContextAttributes();
43 shouldBe("attrs.alpha", "true");
45 var imgData4 = ctx4.getImageData(0, 0, 1, 1);
46 shouldBe("ctx4.getContextAttributes().alpha", "true");
47 shouldBe("imgData4.data[0]", "0");
48 shouldBe("imgData4.data[1]", "0");
49 shouldBe("imgData4.data[2]", "0");
50 shouldBe("imgData4.data[3]", "0");