Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(330)

Side by Side Diff: LayoutTests/fast/canvas/alpha.js

Issue 200003002: Canvas element that use the alpha attribute don't display correctly. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: rebase Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « LayoutTests/TestExpectations ('k') | Source/core/html/HTMLCanvasElement.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 description("Series of tests for canvas alpha"); 1 description("Series of tests for canvas alpha");
2 2
3 if (window.testRunner)
4 testRunner.dumpAsTextWithPixelResults();
5
3 var canvas1 = document.getElementById("canvas1"); 6 var canvas1 = document.getElementById("canvas1");
4 var canvas2 = document.getElementById("canvas2"); 7 var canvas2 = document.getElementById("canvas2");
5 var canvas3 = document.getElementById("canvas3"); 8 var canvas3 = document.getElementById("canvas3");
6 var canvas4 = document.getElementById("canvas4"); 9 var canvas4 = document.getElementById("canvas4");
7 10
8 var ctx1 = canvas1.getContext("2d"); 11 var ctx1 = canvas1.getContext("2d");
9 var ctx2 = canvas2.getContext("2d", {} ); 12 var ctx2 = canvas2.getContext("2d", {} );
10 var ctx3 = canvas3.getContext("2d", { alpha: false } ); 13 var ctx3 = canvas3.getContext("2d", { alpha: false } );
11 var ctx4 = canvas4.getContext("2d", { alpha: true } ); 14 var ctx4 = canvas4.getContext("2d", { alpha: true } );
12 15
13 shouldBe("ctx1.getContextAttributes().alpha", "true"); 16 shouldBe("ctx1.getContextAttributes().alpha", "true");
14 var imgData1 = ctx1.getImageData(0, 0, 1, 1); 17 var imgData1 = ctx1.getImageData(0, 0, 1, 1);
15 shouldBe("imgData1.data[0]", "0"); 18 shouldBe("imgData1.data[0]", "0");
16 shouldBe("imgData1.data[1]", "0"); 19 shouldBe("imgData1.data[1]", "0");
17 shouldBe("imgData1.data[2]", "0"); 20 shouldBe("imgData1.data[2]", "0");
18 shouldBe("imgData1.data[3]", "0"); 21 shouldBe("imgData1.data[3]", "0");
19 22
20 shouldBe("ctx2.getContextAttributes().alpha", "true"); 23 shouldBe("ctx2.getContextAttributes().alpha", "true");
21 var imgData2 = ctx2.getImageData(0, 0, 1, 1); 24 var imgData2 = ctx2.getImageData(0, 0, 1, 1);
22 shouldBe("imgData2.data[0]", "0"); 25 shouldBe("imgData2.data[0]", "0");
23 shouldBe("imgData2.data[1]", "0"); 26 shouldBe("imgData2.data[1]", "0");
24 shouldBe("imgData2.data[2]", "0"); 27 shouldBe("imgData2.data[2]", "0");
25 shouldBe("imgData2.data[3]", "0"); 28 shouldBe("imgData2.data[3]", "0");
26 29
27 shouldBe("ctx3.getContextAttributes().alpha", "false"); 30 shouldBe("ctx3.getContextAttributes().alpha", "false");
28 var imgData3 = ctx3.getImageData(0, 0, 1, 1);
29 shouldBe("imgData3.data[0]", "0");
30 shouldBe("imgData3.data[1]", "0");
31 shouldBe("imgData3.data[2]", "0");
32 shouldBe("imgData3.data[3]", "255");
33 31
34 shouldBe("ctx4.getContextAttributes().alpha", "true"); 32 shouldBe("ctx4.getContextAttributes().alpha", "true");
35 var imgData4 = ctx4.getImageData(0, 0, 1, 1); 33 var imgData4 = ctx4.getImageData(0, 0, 1, 1);
36 shouldBe("imgData4.data[0]", "0"); 34 shouldBe("imgData4.data[0]", "0");
37 shouldBe("imgData4.data[1]", "0"); 35 shouldBe("imgData4.data[1]", "0");
38 shouldBe("imgData4.data[2]", "0"); 36 shouldBe("imgData4.data[2]", "0");
39 shouldBe("imgData4.data[3]", "0"); 37 shouldBe("imgData4.data[3]", "0");
40 38
41 // Check that mutating the returned value of getContextAttributes() doesn't 39 // Check that mutating the returned value of getContextAttributes() doesn't
42 // affect the existing canvas, or the values of subsequent calls to 40 // affect the existing canvas, or the values of subsequent calls to
43 // getContextAttributes(). 41 // getContextAttributes().
44 var attrs = ctx4.getContextAttributes(); 42 var attrs = ctx4.getContextAttributes();
45 shouldBe("attrs.alpha", "true"); 43 shouldBe("attrs.alpha", "true");
46 attrs.alpha = false; 44 attrs.alpha = false;
47 var imgData4 = ctx4.getImageData(0, 0, 1, 1); 45 var imgData4 = ctx4.getImageData(0, 0, 1, 1);
48 shouldBe("ctx4.getContextAttributes().alpha", "true"); 46 shouldBe("ctx4.getContextAttributes().alpha", "true");
49 shouldBe("imgData4.data[0]", "0"); 47 shouldBe("imgData4.data[0]", "0");
50 shouldBe("imgData4.data[1]", "0"); 48 shouldBe("imgData4.data[1]", "0");
51 shouldBe("imgData4.data[2]", "0"); 49 shouldBe("imgData4.data[2]", "0");
52 shouldBe("imgData4.data[3]", "0"); 50 shouldBe("imgData4.data[3]", "0");
OLDNEW
« no previous file with comments | « LayoutTests/TestExpectations ('k') | Source/core/html/HTMLCanvasElement.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698