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: LayoutTests/fast/canvas/script-tests/canvas-color-serialization.js

Issue 408813007: Remove non-standard API entry points in CanvasRenderingContext2D (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: remove some unnecessary mac/virtual/gpu baselines Created 6 years, 1 month 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
OLDNEW
1 description("Test that getting color properties from a CanvasRenderingContext2D returns properly formatted values."); 1 description("Test that getting color properties from a CanvasRenderingContext2D returns properly formatted values.");
2 2
3 ctx = document.createElement('canvas').getContext('2d'); 3 ctx = document.createElement('canvas').getContext('2d');
4 4
5 function trySettingStrokeStyle(value) { 5 function trySettingStrokeStyle(value) {
6 ctx.strokeStyle = '#666'; 6 ctx.strokeStyle = '#666';
7 ctx.strokeStyle = value; 7 ctx.strokeStyle = value;
8 return ctx.strokeStyle; 8 return ctx.strokeStyle;
9 } 9 }
10 10
11 function trySettingFillStyle(value) { 11 function trySettingFillStyle(value) {
12 ctx.fillStyle = '#666'; 12 ctx.fillStyle = '#666';
13 ctx.fillStyle = value; 13 ctx.fillStyle = value;
14 return ctx.fillStyle; 14 return ctx.fillStyle;
15 } 15 }
16 16
17 function trySettingShadowColor(value) { 17 function trySettingShadowColor(value) {
18 ctx.shadowColor = '#666'; 18 ctx.shadowColor = '#666';
19 ctx.shadowColor = value; 19 ctx.shadowColor = value;
20 return ctx.shadowColor; 20 return ctx.shadowColor;
21 } 21 }
22 22
23 function trySettingColor(value, expected) { 23 function trySettingColor(value, expected) {
24 shouldBe("trySettingStrokeStyle(" + value + ")", expected); 24 shouldBe("trySettingStrokeStyle(" + value + ")", expected);
25 shouldBe("trySettingFillStyle(" + value + ")", expected); 25 shouldBe("trySettingFillStyle(" + value + ")", expected);
26 shouldBe("trySettingShadowColor(" + value + ")", expected); 26 shouldBe("trySettingShadowColor(" + value + ")", expected);
27 } 27 }
28 28
29 function trySettingStrokeColorWithSetter(value) {
30 ctx.strokeStyle = '#666';
31 ctx.setStrokeColor(value);
32 return ctx.strokeStyle;
33 }
34
35 function trySettingFillColorWithSetter(value) {
36 ctx.fillStyle = '#666';
37 ctx.setFillColor(value);
38 return ctx.fillStyle;
39 }
40
41 function trySettingShadowWithSetter(value) {
42 ctx.shadowColor = '#666';
43 ctx.setShadow(0, 0, 0, value);
44 return ctx.shadowColor;
45 }
46
47 function trySettingColorWithSetter(value, expected) {
48 shouldBe("trySettingStrokeColorWithSetter(" + value + ")", expected);
49 shouldBe("trySettingFillColorWithSetter(" + value + ")", expected);
50 shouldBe("trySettingShadowWithSetter(" + value + ")", expected);
51 }
52
53 function trySettingFillColorRGBA(r, g, b, a) {
54 ctx.fillStyle = '#666';
55 ctx.setFillColor(r, g, b, a);
56 return ctx.fillStyle;
57 }
58
59 function trySettingStrokeColorRGBA(r, g, b, a) {
60 ctx.strokeStyle = '#666';
61 ctx.setStrokeColor(r, g, b, a);
62 return ctx.strokeStyle;
63 }
64
65 function trySettingShadowRGBA(r, g, b, a) {
66 ctx.strokeStyle = '#666';
67 ctx.setStrokeColor(r, g, b, a);
68 return ctx.strokeStyle;
69 }
70
71 function trySettingRGBA(r, g, b, a, expected) {
72 shouldBe("trySettingFillColorRGBA(" + r + ", " + g + ", " + b + ", " + a + " )", expected);
73 shouldBe("trySettingStrokeColorRGBA(" + r + ", " + g + ", " + b + ", " + a + ")", expected);
74 shouldBe("trySettingShadowRGBA(" + r + ", " + g + ", " + b + ", " + a + ")", expected);
75 }
76
77 function trySettingFillColorCMYKA(c, m, y, k, a) {
78 ctx.fillStyle = '#666';
79 ctx.setFillColor(c, m, y, k, a);
80 return ctx.fillStyle;
81 }
82
83 function trySettingStrokeColorCMYKA(c, m, y, k, a) {
84 ctx.strokeStyle = '#666';
85 ctx.setStrokeColor(c, m, y, k, a);
86 return ctx.strokeStyle;
87 }
88
89 function trySettingShadowCMYKA(c, m, y, k, a) {
90 ctx.strokeStyle = '#666';
91 ctx.setStrokeColor(c, m, y, k, a);
92 return ctx.strokeStyle;
93 }
94
95 function trySettingCMYKA(c, m, y, k, a, expected) {
96 shouldBe("trySettingFillColorCMYKA(" + c + ", " + m + ", " + y + ", " + k + ", " + a + ")", expected);
97 shouldBe("trySettingStrokeColorCMYKA(" + c + ", " + m + ", " + y + ", " + k + ", " + a + ")", expected);
98 shouldBe("trySettingShadowCMYKA(" + c + ", " + m + ", " + y + ", " + k + ", " + a + ")", expected);
99 }
100
101 function trySettingFillColorWithOverrideAlpha(color, alpha) {
102 ctx.fillStyle = '#666';
103 ctx.setFillColor(color, alpha);
104 return ctx.fillStyle;
105 }
106
107 function trySettingStrokeColorWithOverrideAlpha(color, alpha) {
108 ctx.strokeStyle = '#666';
109 ctx.setStrokeColor(color, alpha);
110 return ctx.strokeStyle;
111 }
112
113 function trySettingShadowWithOverrideAlpha(color, alpha) {
114 ctx.shadowColor = '#666';
115 ctx.setShadow(0, 0, 0, color, alpha);
116 return ctx.shadowColor;
117 }
118
119 function trySettingColorWithOverrideAlpha(color, alpha, expected) {
120 shouldBe("trySettingFillColorWithOverrideAlpha(" + color + ", " + alpha + ") ", expected);
121 shouldBe("trySettingStrokeColorWithOverrideAlpha(" + color + ", " + alpha + ")", expected);
122 shouldBe("trySettingShadowWithOverrideAlpha(" + color + ", " + alpha + ")", expected);
123 }
124
125 function trySettingFillColorGrayLevel(grayLevel) {
126 ctx.fillStyle = '#666';
127 ctx.setFillColor(grayLevel);
128 return ctx.fillStyle;
129 }
130
131 function trySettingStrokeColorGrayLevel(grayLevel) {
132 ctx.strokeStyle = '#666';
133 ctx.setStrokeColor(grayLevel);
134 return ctx.strokeStyle;
135 }
136
137 function trySettingShadowGrayLevel(grayLevel) {
138 ctx.shadowColor = '#666';
139 ctx.setShadow(0, 0, 0, grayLevel);
140 return ctx.shadowColor;
141 }
142
143 function trySettingGrayLevel(grayLevel, expected) {
144 shouldBe("trySettingFillColorGrayLevel(" + grayLevel + ")", expected);
145 shouldBe("trySettingStrokeColorGrayLevel(" + grayLevel + ")", expected);
146 shouldBe("trySettingShadowGrayLevel(" + grayLevel + ")", expected);
147 }
148
149 function trySettingFillColorGrayLevelWithAlpha(grayLevel, alpha) {
150 ctx.fillStyle = '#666';
151 ctx.setFillColor(grayLevel, alpha);
152 return ctx.fillStyle;
153 }
154
155 function trySettingStrokeColorGrayLevelWithAlpha(grayLevel, alpha) {
156 ctx.strokeStyle = '#666';
157 ctx.setStrokeColor(grayLevel, alpha);
158 return ctx.strokeStyle;
159 }
160
161 function trySettingShadowGrayLevelWithAlpha(grayLevel, alpha) {
162 ctx.shadowColor = '#666';
163 ctx.setShadow(0, 0, 0, grayLevel, alpha);
164 return ctx.shadowColor;
165 }
166
167 function trySettingGrayLevelWithAlpha(grayLevel, alpha, expected) {
168 shouldBe("trySettingFillColorGrayLevelWithAlpha(" + grayLevel + ", " + alpha + ")", expected);
169 shouldBe("trySettingStrokeColorGrayLevelWithAlpha(" + grayLevel + ", " + alp ha + ")", expected);
170 shouldBe("trySettingShadowGrayLevelWithAlpha(" + grayLevel + ", " + alpha + ")", expected);
171 }
172
173 function tryClearShadowAfterSettingColor(value) {
174 ctx.shadowColor = value;
175 ctx.clearShadow();
176 return ctx.shadowColor;
177 }
178
179 function checkDefaultValue(value) { 29 function checkDefaultValue(value) {
180 return value; 30 return value;
181 } 31 }
182 32
183 shouldBe("checkDefaultValue(ctx.strokeStyle)", "'#000000'"); 33 shouldBe("checkDefaultValue(ctx.strokeStyle)", "'#000000'");
184 shouldBe("checkDefaultValue(ctx.fillStyle)", "'#000000'"); 34 shouldBe("checkDefaultValue(ctx.fillStyle)", "'#000000'");
185 shouldBe("checkDefaultValue(ctx.shadowColor)", "'rgba(0, 0, 0, 0)'"); 35 shouldBe("checkDefaultValue(ctx.shadowColor)", "'rgba(0, 0, 0, 0)'");
186 36
187 trySettingColorWithOverrideAlpha("'red'", 0, "'rgba(255, 0, 0, 0)'");
188 trySettingColorWithOverrideAlpha("'black'", 1, "'#000000'");
189
190 trySettingRGBA(0, 0, 0, 0.0, "'rgba(0, 0, 0, 0)'");
191 trySettingRGBA(255, 255, 255, 1.0, "'#ffffff'");
192 trySettingRGBA(255, 0, 0, 0.0, "'rgba(255, 0, 0, 0)'");
193 trySettingRGBA(255, 0, 0, 0.4, "'rgba(255, 0, 0, 0.4)'");
194
195 trySettingCMYKA(0, 0, 0, 0, 0.0, "'rgba(255, 255, 255, 0)'");
196 trySettingCMYKA(0, 0, 0, 0, 1.0, "'#ffffff'");
197 trySettingCMYKA(0, 1, 0, 0, 0.0, "'rgba(255, 0, 255, 0)'");
198 trySettingCMYKA(0, 1, 0, 0, 1.0, "'#ff00ff'");
199 trySettingCMYKA(0, 0, 0, 1, 0.0, "'rgba(0, 0, 0, 0)'");
200 trySettingCMYKA(0, 0, 0, 1, 1.0, "'#000000'");
201
202 trySettingGrayLevel(0.0, "'#000000'");
203 trySettingGrayLevel(0.5, "'#808080'");
204 trySettingGrayLevel(1.0, "'#ffffff'");
205
206 trySettingGrayLevelWithAlpha(0.0, 0.0, "'rgba(0, 0, 0, 0)'");
207 trySettingGrayLevelWithAlpha(0.0, 0.4, "'rgba(0, 0, 0, 0.4)'");
208 trySettingGrayLevelWithAlpha(0.0, 1.0, "'#000000'");
209 trySettingGrayLevelWithAlpha(0.5, 0.0, "'rgba(128, 128, 128, 0)'");
210 trySettingGrayLevelWithAlpha(0.5, 0.4, "'rgba(128, 128, 128, 0.4)'");
211 trySettingGrayLevelWithAlpha(0.5, 1.0, "'#808080'");
212 trySettingGrayLevelWithAlpha(1.0, 0.0, "'rgba(255, 255, 255, 0)'");
213 trySettingGrayLevelWithAlpha(1.0, 0.4, "'rgba(255, 255, 255, 0.4)'");
214 trySettingGrayLevelWithAlpha(1.0, 1.0, "'#ffffff'");
215
216 trySettingColor("'transparent'", "'rgba(0, 0, 0, 0)'"); 37 trySettingColor("'transparent'", "'rgba(0, 0, 0, 0)'");
217 trySettingColor("'red'", "'#ff0000'"); 38 trySettingColor("'red'", "'#ff0000'");
218 trySettingColor("'white'", "'#ffffff'"); 39 trySettingColor("'white'", "'#ffffff'");
219 trySettingColor("''", "'#666666'"); 40 trySettingColor("''", "'#666666'");
220 trySettingColor("'RGBA(0, 0, 0, 0)'", "'rgba(0, 0, 0, 0)'"); 41 trySettingColor("'RGBA(0, 0, 0, 0)'", "'rgba(0, 0, 0, 0)'");
221 trySettingColor("'rgba(0,255,0,1.0)'", "'#00ff00'"); 42 trySettingColor("'rgba(0,255,0,1.0)'", "'#00ff00'");
222 trySettingColor("'rgba(1,2,3,0.4)'", "'rgba(1, 2, 3, 0.4)'"); 43 trySettingColor("'rgba(1,2,3,0.4)'", "'rgba(1, 2, 3, 0.4)'");
223 trySettingColor("'RgB(1,2,3)'", "'#010203'"); 44 trySettingColor("'RgB(1,2,3)'", "'#010203'");
224 trySettingColor("'rGbA(1,2,3,0)'", "'rgba(1, 2, 3, 0)'"); 45 trySettingColor("'rGbA(1,2,3,0)'", "'rgba(1, 2, 3, 0)'");
225 trySettingColor("true", "'#666666'"); 46 trySettingColor("true", "'#666666'");
226 trySettingColor("false", "'#666666'"); 47 trySettingColor("false", "'#666666'");
227 trySettingColor("0", "'#666666'"); 48 trySettingColor("0", "'#666666'");
228 trySettingColor("1", "'#666666'"); 49 trySettingColor("1", "'#666666'");
229 trySettingColor("-1", "'#666666'"); 50 trySettingColor("-1", "'#666666'");
230 trySettingColor("NaN", "'#666666'"); 51 trySettingColor("NaN", "'#666666'");
231 trySettingColor("Infinity", "'#666666'"); 52 trySettingColor("Infinity", "'#666666'");
232 trySettingColor("null", "'#666666'"); 53 trySettingColor("null", "'#666666'");
233 54
234 trySettingColorWithSetter("'transparent'", "'rgba(0, 0, 0, 0)'");
235 trySettingColorWithSetter("'red'", "'#ff0000'");
236 trySettingColorWithSetter("'white'", "'#ffffff'");
237 trySettingColorWithSetter("''", "'#666666'");
238 trySettingColorWithSetter("'RGBA(0, 0, 0, 0)'", "'rgba(0, 0, 0, 0)'");
239 trySettingColorWithSetter("'rgba(0,255,0,1.0)'", "'#00ff00'");
240 trySettingColorWithSetter("'rgba(1,2,3,0.4)'", "'rgba(1, 2, 3, 0.4)'");
241 trySettingColorWithSetter("'RgB(1,2,3)'", "'#010203'");
242 trySettingColorWithSetter("'rGbA(1,2,3,0)'", "'rgba(1, 2, 3, 0)'");
243
244 shouldBe("tryClearShadowAfterSettingColor('red')", "'rgba(0, 0, 0, 0)'");
245 shouldBe("tryClearShadowAfterSettingColor('rgba(0, 5, 10, 0.4)')", "'rgba(0, 0, 0, 0)'");
OLDNEW
« no previous file with comments | « LayoutTests/fast/canvas/resources/shadow-offset.js ('k') | LayoutTests/fast/canvas/script-tests/canvas-currentColor.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698