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

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

Issue 14298018: This CL implements the first draft of Canvas 2D Context Attributes, aka getContext('2d', { alpha: f… (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebased to ToT; test cleanup Created 7 years, 7 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 | Annotate | Revision Log
« no previous file with comments | « LayoutTests/fast/canvas/alpha.html ('k') | LayoutTests/fast/canvas/alpha-expected.txt » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 description("Series of tests for canvas alpha");
2
3 var canvas1 = document.getElementById("canvas1");
4 var canvas2 = document.getElementById("canvas2");
5 var canvas3 = document.getElementById("canvas3");
6 var canvas4 = document.getElementById("canvas4");
7
8 var ctx1 = canvas1.getContext("2d");
9 var ctx2 = canvas2.getContext("2d", {} );
10 var ctx3 = canvas3.getContext("2d", { alpha: false } );
11 var ctx4 = canvas4.getContext("2d", { alpha: true } );
12
13 shouldBe("ctx1.getContextAttributes().alpha", "true");
14 var imgData1 = ctx1.getImageData(0, 0, 1, 1);
15 shouldBe("imgData1.data[0]", "0");
16 shouldBe("imgData1.data[1]", "0");
17 shouldBe("imgData1.data[2]", "0");
18 shouldBe("imgData1.data[3]", "0");
19
20 shouldBe("ctx2.getContextAttributes().alpha", "true");
21 var imgData2 = ctx2.getImageData(0, 0, 1, 1);
22 shouldBe("imgData2.data[0]", "0");
23 shouldBe("imgData2.data[1]", "0");
24 shouldBe("imgData2.data[2]", "0");
25 shouldBe("imgData2.data[3]", "0");
26
27 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
34 shouldBe("ctx4.getContextAttributes().alpha", "true");
35 var imgData4 = ctx4.getImageData(0, 0, 1, 1);
36 shouldBe("imgData4.data[0]", "0");
37 shouldBe("imgData4.data[1]", "0");
38 shouldBe("imgData4.data[2]", "0");
39 shouldBe("imgData4.data[3]", "0");
40
41 // Check that mutating the returned value of getContextAttributes() doesn't
42 // affect the existing canvas, or the values of subsequent calls to
43 // getContextAttributes().
44 var attrs = ctx4.getContextAttributes();
45 shouldBe("attrs.alpha", "true");
46 attrs.alpha = false;
47 var imgData4 = ctx4.getImageData(0, 0, 1, 1);
48 shouldBe("ctx4.getContextAttributes().alpha", "true");
49 shouldBe("imgData4.data[0]", "0");
50 shouldBe("imgData4.data[1]", "0");
51 shouldBe("imgData4.data[2]", "0");
52 shouldBe("imgData4.data[3]", "0");
OLDNEW
« no previous file with comments | « LayoutTests/fast/canvas/alpha.html ('k') | LayoutTests/fast/canvas/alpha-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698