2 testRunner
.dumpAsText();
4 description("Test strict color parsing on SVG presentation attributes.")
7 var rect
= createSVGElement("rect");
8 rect
.setAttribute("id", "rect");
9 rect
.setAttribute("width", "100px");
10 rect
.setAttribute("height", "100px");
11 rootSVGElement
.appendChild(rect
);
15 // The default for fill is rgb(0, 0, 0).
16 shouldBeEqualToString("document.defaultView.getComputedStyle(rect, null).fill", "rgb(0, 0, 0)");
18 // Set the fill color to green.
19 rect
.setAttribute("fill", "green");
20 shouldBeEqualToString("document.defaultView.getComputedStyle(rect, null).fill", "rgb(0, 128, 0)");
22 // Set following colors should be invalid.
23 rect
.setAttribute("fill", "f00");
24 shouldBeEqualToString("document.defaultView.getComputedStyle(rect, null).fill", "rgb(0, 0, 0)");
26 rect
.setAttribute("fill", "green");
27 shouldBeEqualToString("document.defaultView.getComputedStyle(rect, null).fill", "rgb(0, 128, 0)");
29 rect
.setAttribute("fill", "ff00");
30 shouldBeEqualToString("document.defaultView.getComputedStyle(rect, null).fill", "rgb(0, 0, 0)");
32 rect
.setAttribute("fill", "green");
33 shouldBeEqualToString("document.defaultView.getComputedStyle(rect, null).fill", "rgb(0, 128, 0)");
35 rect
.setAttribute("fill", "ff0000");
36 shouldBeEqualToString("document.defaultView.getComputedStyle(rect, null).fill", "rgb(0, 0, 0)");
38 rect
.setAttribute("fill", "green");
39 shouldBeEqualToString("document.defaultView.getComputedStyle(rect, null).fill", "rgb(0, 128, 0)");
41 rect
.setAttribute("fill", "ff00");
42 shouldBeEqualToString("document.defaultView.getComputedStyle(rect, null).fill", "rgb(0, 0, 0)");
44 rect
.setAttribute("fill", "green");
45 shouldBeEqualToString("document.defaultView.getComputedStyle(rect, null).fill", "rgb(0, 128, 0)");
47 rect
.setAttribute("fill", "");
48 shouldBeEqualToString("document.defaultView.getComputedStyle(rect, null).fill", "rgb(0, 0, 0)");
50 rect
.setAttribute("fill", "green");
51 shouldBeEqualToString("document.defaultView.getComputedStyle(rect, null).fill", "rgb(0, 128, 0)");
53 rect
.setAttribute("fill", "url(#reference)");
54 shouldBeEqualToString("document.defaultView.getComputedStyle(rect, null).fill", "url(#reference)");
56 rect
.setAttribute("fill", "green");
57 shouldBeEqualToString("document.defaultView.getComputedStyle(rect, null).fill", "rgb(0, 128, 0)");
59 rect
.setAttribute("fill", "url(#reference) green");
60 shouldBeEqualToString("document.defaultView.getComputedStyle(rect, null).fill", "url(#reference) rgb(0, 128, 0)");
62 rect
.setAttribute("fill", "green");
63 shouldBeEqualToString("document.defaultView.getComputedStyle(rect, null).fill", "rgb(0, 128, 0)");
67 // The default stroke value should be 'none'.
68 shouldBeEqualToString("document.defaultView.getComputedStyle(rect, null).stroke", "none");
70 // Set the stroke color to green.
71 rect
.setAttribute("stroke", "green");
72 shouldBeEqualToString("document.defaultView.getComputedStyle(rect, null).stroke", "rgb(0, 128, 0)");
74 // Set following colors should be invalid.
75 rect
.setAttribute("stroke", "f00");
76 shouldBeEqualToString("document.defaultView.getComputedStyle(rect, null).stroke", "none");
78 rect
.setAttribute("stroke", "green");
79 shouldBeEqualToString("document.defaultView.getComputedStyle(rect, null).stroke", "rgb(0, 128, 0)");
81 rect
.setAttribute("stroke", "ff00");
82 shouldBeEqualToString("document.defaultView.getComputedStyle(rect, null).stroke", "none");
84 rect
.setAttribute("stroke", "green");
85 shouldBeEqualToString("document.defaultView.getComputedStyle(rect, null).stroke", "rgb(0, 128, 0)");
87 rect
.setAttribute("stroke", "ff0000");
88 shouldBeEqualToString("document.defaultView.getComputedStyle(rect, null).stroke", "none");
90 rect
.setAttribute("stroke", "green");
91 shouldBeEqualToString("document.defaultView.getComputedStyle(rect, null).stroke", "rgb(0, 128, 0)");
93 rect
.setAttribute("stroke", "ff00");
94 shouldBeEqualToString("document.defaultView.getComputedStyle(rect, null).stroke", "none");
96 rect
.setAttribute("stroke", "green");
97 shouldBeEqualToString("document.defaultView.getComputedStyle(rect, null).stroke", "rgb(0, 128, 0)");
99 rect
.setAttribute("stroke", "");
100 shouldBeEqualToString("document.defaultView.getComputedStyle(rect, null).stroke", "none");
102 rect
.setAttribute("stroke", "green");
103 shouldBeEqualToString("document.defaultView.getComputedStyle(rect, null).stroke", "rgb(0, 128, 0)");
105 rect
.setAttribute("stroke", "url(#reference)");
106 shouldBeEqualToString("document.defaultView.getComputedStyle(rect, null).stroke", "url(#reference)");
108 rect
.setAttribute("stroke", "green");
109 shouldBeEqualToString("document.defaultView.getComputedStyle(rect, null).stroke", "rgb(0, 128, 0)");
111 rect
.setAttribute("stroke", "url(#reference) green");
112 shouldBeEqualToString("document.defaultView.getComputedStyle(rect, null).stroke", "url(#reference) rgb(0, 128, 0)");
114 rect
.setAttribute("stroke", "green");
115 shouldBeEqualToString("document.defaultView.getComputedStyle(rect, null).stroke", "rgb(0, 128, 0)");
119 // The default for color is rgb(0, 0, 0).
120 shouldBeEqualToString("document.defaultView.getComputedStyle(rect, null).color", "rgb(0, 0, 0)");
122 // Set color to green.
123 rect
.setAttribute("color", "green");
124 shouldBeEqualToString("document.defaultView.getComputedStyle(rect, null).color", "rgb(0, 128, 0)");
126 // Set following colors should be invalid.
127 rect
.setAttribute("color", "f00");
128 shouldBeEqualToString("document.defaultView.getComputedStyle(rect, null).color", "rgb(0, 0, 0)");
130 rect
.setAttribute("color", "green");
131 shouldBeEqualToString("document.defaultView.getComputedStyle(rect, null).color", "rgb(0, 128, 0)");
133 rect
.setAttribute("color", "ff00");
134 shouldBeEqualToString("document.defaultView.getComputedStyle(rect, null).color", "rgb(0, 0, 0)");
136 rect
.setAttribute("color", "green");
137 shouldBeEqualToString("document.defaultView.getComputedStyle(rect, null).color", "rgb(0, 128, 0)");
139 rect
.setAttribute("color", "ff0000");
140 shouldBeEqualToString("document.defaultView.getComputedStyle(rect, null).color", "rgb(0, 0, 0)");
142 rect
.setAttribute("color", "green");
143 shouldBeEqualToString("document.defaultView.getComputedStyle(rect, null).color", "rgb(0, 128, 0)");
145 rect
.setAttribute("color", "ff00");
146 shouldBeEqualToString("document.defaultView.getComputedStyle(rect, null).color", "rgb(0, 0, 0)");
148 rect
.setAttribute("color", "green");
149 shouldBeEqualToString("document.defaultView.getComputedStyle(rect, null).color", "rgb(0, 128, 0)");
151 rect
.setAttribute("color", "");
152 shouldBeEqualToString("document.defaultView.getComputedStyle(rect, null).color", "rgb(0, 0, 0)");
154 rect
.setAttribute("color", "green");
155 shouldBeEqualToString("document.defaultView.getComputedStyle(rect, null).color", "rgb(0, 128, 0)");
158 // Testing 'stop-color'
159 // The default for stop-color is rgb(0, 0, 0).
160 shouldBeEqualToString("document.defaultView.getComputedStyle(rect, null).stopColor", "rgb(0, 0, 0)");
162 // Set color to green.
163 rect
.setAttribute("stop-color", "green");
164 shouldBeEqualToString("document.defaultView.getComputedStyle(rect, null).stopColor", "rgb(0, 128, 0)");
166 // Set following colors should be invalid.
167 rect
.setAttribute("stop-color", "f00");
168 shouldBeEqualToString("document.defaultView.getComputedStyle(rect, null).stopColor", "rgb(0, 0, 0)");
170 rect
.setAttribute("stop-color", "green");
171 shouldBeEqualToString("document.defaultView.getComputedStyle(rect, null).stopColor", "rgb(0, 128, 0)");
173 rect
.setAttribute("stop-color", "ff00");
174 shouldBeEqualToString("document.defaultView.getComputedStyle(rect, null).stopColor", "rgb(0, 0, 0)");
176 rect
.setAttribute("stop-color", "green");
177 shouldBeEqualToString("document.defaultView.getComputedStyle(rect, null).stopColor", "rgb(0, 128, 0)");
179 rect
.setAttribute("stop-color", "ff0000");
180 shouldBeEqualToString("document.defaultView.getComputedStyle(rect, null).stopColor", "rgb(0, 0, 0)");
182 rect
.setAttribute("stop-color", "green");
183 shouldBeEqualToString("document.defaultView.getComputedStyle(rect, null).stopColor", "rgb(0, 128, 0)");
185 rect
.setAttribute("stop-color", "ff00");
186 shouldBeEqualToString("document.defaultView.getComputedStyle(rect, null).stopColor", "rgb(0, 0, 0)");
188 rect
.setAttribute("stop-color", "green");
189 shouldBeEqualToString("document.defaultView.getComputedStyle(rect, null).stopColor", "rgb(0, 128, 0)");
191 rect
.setAttribute("stop-color", "");
192 shouldBeEqualToString("document.defaultView.getComputedStyle(rect, null).stopColor", "rgb(0, 0, 0)");
194 rect
.setAttribute("stop-color", "green");
195 shouldBeEqualToString("document.defaultView.getComputedStyle(rect, null).stopColor", "rgb(0, 128, 0)");
198 // Testing 'flood-color'
199 // The default for flood-color is rgb(0, 0, 0).
200 shouldBeEqualToString("document.defaultView.getComputedStyle(rect, null).floodColor", "rgb(0, 0, 0)");
202 // Set color to green.
203 rect
.setAttribute("flood-color", "green");
204 shouldBeEqualToString("document.defaultView.getComputedStyle(rect, null).floodColor", "rgb(0, 128, 0)");
206 // Set following colors should be invalid.
207 rect
.setAttribute("flood-color", "f00");
208 shouldBeEqualToString("document.defaultView.getComputedStyle(rect, null).floodColor", "rgb(0, 0, 0)");
210 rect
.setAttribute("flood-color", "green");
211 shouldBeEqualToString("document.defaultView.getComputedStyle(rect, null).floodColor", "rgb(0, 128, 0)");
213 rect
.setAttribute("flood-color", "ff00");
214 shouldBeEqualToString("document.defaultView.getComputedStyle(rect, null).floodColor", "rgb(0, 0, 0)");
216 rect
.setAttribute("flood-color", "green");
217 shouldBeEqualToString("document.defaultView.getComputedStyle(rect, null).floodColor", "rgb(0, 128, 0)");
219 rect
.setAttribute("flood-color", "ff0000");
220 shouldBeEqualToString("document.defaultView.getComputedStyle(rect, null).floodColor", "rgb(0, 0, 0)");
222 rect
.setAttribute("flood-color", "green");
223 shouldBeEqualToString("document.defaultView.getComputedStyle(rect, null).floodColor", "rgb(0, 128, 0)");
225 rect
.setAttribute("flood-color", "ff00");
226 shouldBeEqualToString("document.defaultView.getComputedStyle(rect, null).floodColor", "rgb(0, 0, 0)");
228 rect
.setAttribute("flood-color", "green");
229 shouldBeEqualToString("document.defaultView.getComputedStyle(rect, null).floodColor", "rgb(0, 128, 0)");
231 rect
.setAttribute("flood-color", "");
232 shouldBeEqualToString("document.defaultView.getComputedStyle(rect, null).floodColor", "rgb(0, 0, 0)");
234 rect
.setAttribute("flood-color", "green");
235 shouldBeEqualToString("document.defaultView.getComputedStyle(rect, null).floodColor", "rgb(0, 128, 0)");
237 var successfullyParsed
= true;