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

Side by Side Diff: third_party/WebKit/LayoutTests/fast/canvas/script-tests/canvas-save-restore.js

Issue 2696023002: Use testharness.js instead of js-test.js in LayoutTests/fast/canvas tests. (Closed)
Patch Set: Rebaseline Created 3 years, 10 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
OLDNEW
(Empty)
1 description("Test of save and restore on canvas graphics context.");
2
3 var canvas = document.createElement("canvas");
4 var context = canvas.getContext('2d');
5
6 function hex(number)
7 {
8 var hexDigits = "0123456789abcdef";
9 return hexDigits[number >> 4] + hexDigits[number & 0xF];
10 }
11
12 function pixel()
13 {
14 var imageData = context.getImageData(0, 0, 1, 1);
15 return "#" + hex(imageData.data[0]) + hex(imageData.data[1]) + hex(imageData .data[2]);
16 }
17
18 var black="#000000";
19 var red = "#ff0000";
20 var green = "#008000";
21
22 // (save set restore)
23 context.fillStyle = "black";
24 context.fillRect(0, 0, 1, 1);
25 shouldBe("pixel()", "black");
26
27 context.save();
28 context.fillStyle = "red";
29 context.fillRect(0, 0, 1, 1);
30 shouldBe("pixel()", "red");
31
32 context.restore();
33 context.fillRect(0, 0, 1, 1);
34 shouldBe("pixel()", "black");
35
36
37 // (save (save set restore) restore)
38 context.fillStyle = "black";
39 context.fillRect(0, 0, 1, 1);
40 shouldBe("pixel()", "black");
41
42 context.save();
43
44 context.save();
45 context.fillStyle = "red";
46 context.fillRect(0, 0, 1, 1);
47 shouldBe("pixel()", "red");
48
49 context.restore();
50 context.fillRect(0, 0, 1, 1);
51 shouldBe("pixel()", "black");
52
53 context.restore();
54 context.fillRect(0, 0, 1, 1);
55 shouldBe("pixel()", "black");
56
57
58 // (save (save restore) set restore)
59 context.fillStyle = "black";
60 context.fillRect(0, 0, 1, 1);
61 shouldBe("pixel()", "black");
62
63 context.save();
64 context.restore();
65
66 context.save();
67 context.fillStyle = "red";
68 context.fillRect(0, 0, 1, 1);
69 shouldBe("pixel()", "red");
70
71 context.restore();
72 context.fillRect(0, 0, 1, 1);
73 shouldBe("pixel()", "black");
74
75
76 // (save (save (save set restore) set (save set restore) restore) restore)
77 context.fillStyle = "black";
78 context.fillRect(0, 0, 1, 1);
79 shouldBe("pixel()", "black");
80
81 context.save();
82 context.fillRect(0, 0, 1, 1);
83 shouldBe("pixel()", "black");
84
85 context.save();
86 context.fillStyle = "red";
87 context.fillRect(0, 0, 1, 1);
88 shouldBe("pixel()", "red");
89
90 context.restore();
91 context.fillRect(0, 0, 1, 1);
92 shouldBe("pixel()", "black");
93
94 context.fillStyle = "green";
95 context.fillRect(0, 0, 1, 1);
96 shouldBe("pixel()", "green");
97
98 context.save();
99 context.fillRect(0, 0, 1, 1);
100 shouldBe("pixel()", "green");
101
102 context.fillStyle = "red";
103 context.fillRect(0, 0, 1, 1);
104 shouldBe("pixel()", "red");
105
106 context.restore();
107 context.fillRect(0, 0, 1, 1);
108 shouldBe("pixel()", "green");
109
110 context.restore();
111 context.fillRect(0, 0, 1, 1);
112 shouldBe("pixel()", "black");
113
114 context.restore();
115 context.fillRect(0, 0, 1, 1);
116 shouldBe("pixel()", "black");
117
118
119 // (save (save set (save (save set restore) restore) set restore) restore)
120 context.fillStyle = "black";
121 context.fillRect(0, 0, 1, 1);
122 shouldBe("pixel()", "black");
123
124 context.save();
125 context.fillRect(0, 0, 1, 1);
126 shouldBe("pixel()", "black");
127
128 context.save();
129 context.fillStyle = "red";
130 context.fillRect(0, 0, 1, 1);
131 shouldBe("pixel()", "red");
132
133 context.save();
134 context.fillRect(0, 0, 1, 1);
135 shouldBe("pixel()", "red");
136
137 context.save();
138 context.fillStyle = "green";
139 context.fillRect(0, 0, 1, 1);
140 shouldBe("pixel()", "green");
141
142 context.restore();
143 context.fillRect(0, 0, 1, 1);
144 shouldBe("pixel()", "red");
145
146 context.restore();
147 context.fillRect(0, 0, 1, 1);
148 shouldBe("pixel()", "red");
149
150 context.fillStyle = "green";
151 context.fillRect(0, 0, 1, 1);
152 shouldBe("pixel()", "green");
153
154 context.restore();
155 context.fillRect(0, 0, 1, 1);
156 shouldBe("pixel()", "black");
157
158 context.restore();
159 context.fillRect(0, 0, 1, 1);
160 shouldBe("pixel()", "black");
161
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698