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

Side by Side Diff: third_party/WebKit/LayoutTests/fast/canvas/canvas-save-restore.html

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

Powered by Google App Engine
This is Rietveld 408576698