OLD | NEW |
1 if (window.testRunner) | 1 if (window.testRunner) |
2 testRunner.dumpAsText(); | 2 testRunner.dumpAsText(); |
3 | 3 |
4 description("Test strict color parsing on SVG presentation attributes.") | 4 description("Test strict color parsing on SVG presentation attributes.") |
5 createSVGTestCase(); | 5 createSVGTestCase(); |
6 | 6 |
7 var rect = createSVGElement("rect"); | 7 var rect = createSVGElement("rect"); |
8 rect.setAttribute("id", "rect"); | 8 rect.setAttribute("id", "rect"); |
9 rect.setAttribute("width", "100px"); | 9 rect.setAttribute("width", "100px"); |
10 rect.setAttribute("height", "100px"); | 10 rect.setAttribute("height", "100px"); |
11 rootSVGElement.appendChild(rect); | 11 rootSVGElement.appendChild(rect); |
12 | 12 |
13 | 13 |
14 // Testing 'fill' | 14 // Testing 'fill' |
15 // The default for fill is rgb(0, 0, 0). | 15 // The default for fill is rgb(0, 0, 0). |
16 shouldBeEqualToString("document.defaultView.getComputedStyle(rect, null).fill",
"rgb(0, 0, 0)"); | 16 shouldBeEqualToString("document.defaultView.getComputedStyle(rect, null).fill",
"rgb(0, 0, 0)"); |
17 | 17 |
18 // Set the fill color to green. | 18 // Set the fill color to green. |
19 rect.setAttribute("fill", "green"); | 19 rect.setAttribute("fill", "green"); |
20 shouldBeEqualToString("document.defaultView.getComputedStyle(rect, null).fill",
"rgb(0, 128, 0)"); | 20 shouldBeEqualToString("document.defaultView.getComputedStyle(rect, null).fill",
"rgb(0, 128, 0)"); |
21 | 21 |
22 // Set following colors should be invalid. | 22 // Set following colors should be invalid. |
23 rect.setAttribute("fill", "f00"); | 23 rect.setAttribute("fill", "f00"); |
24 shouldBeNull("document.defaultView.getComputedStyle(rect, null).fill"); | 24 shouldBeEqualToString("document.defaultView.getComputedStyle(rect, null).fill",
"rgb(0, 0, 0)"); |
25 // Reset to green. | 25 // Reset to green. |
26 rect.setAttribute("fill", "green"); | 26 rect.setAttribute("fill", "green"); |
27 shouldBeEqualToString("document.defaultView.getComputedStyle(rect, null).fill",
"rgb(0, 128, 0)"); | 27 shouldBeEqualToString("document.defaultView.getComputedStyle(rect, null).fill",
"rgb(0, 128, 0)"); |
28 | 28 |
29 rect.setAttribute("fill", "ff00"); | 29 rect.setAttribute("fill", "ff00"); |
30 shouldBeNull("document.defaultView.getComputedStyle(rect, null).fill"); | 30 shouldBeEqualToString("document.defaultView.getComputedStyle(rect, null).fill",
"rgb(0, 0, 0)"); |
31 // Reset to green. | 31 // Reset to green. |
32 rect.setAttribute("fill", "green"); | 32 rect.setAttribute("fill", "green"); |
33 shouldBeEqualToString("document.defaultView.getComputedStyle(rect, null).fill",
"rgb(0, 128, 0)"); | 33 shouldBeEqualToString("document.defaultView.getComputedStyle(rect, null).fill",
"rgb(0, 128, 0)"); |
34 | 34 |
35 rect.setAttribute("fill", "ff0000"); | 35 rect.setAttribute("fill", "ff0000"); |
36 shouldBeNull("document.defaultView.getComputedStyle(rect, null).fill"); | 36 shouldBeEqualToString("document.defaultView.getComputedStyle(rect, null).fill",
"rgb(0, 0, 0)"); |
37 // Reset to green. | 37 // Reset to green. |
38 rect.setAttribute("fill", "green"); | 38 rect.setAttribute("fill", "green"); |
39 shouldBeEqualToString("document.defaultView.getComputedStyle(rect, null).fill",
"rgb(0, 128, 0)"); | 39 shouldBeEqualToString("document.defaultView.getComputedStyle(rect, null).fill",
"rgb(0, 128, 0)"); |
40 | 40 |
41 rect.setAttribute("fill", "ff00"); | 41 rect.setAttribute("fill", "ff00"); |
42 shouldBeNull("document.defaultView.getComputedStyle(rect, null).fill"); | 42 shouldBeEqualToString("document.defaultView.getComputedStyle(rect, null).fill",
"rgb(0, 0, 0)"); |
43 // Reset to green. | 43 // Reset to green. |
44 rect.setAttribute("fill", "green"); | 44 rect.setAttribute("fill", "green"); |
45 shouldBeEqualToString("document.defaultView.getComputedStyle(rect, null).fill",
"rgb(0, 128, 0)"); | 45 shouldBeEqualToString("document.defaultView.getComputedStyle(rect, null).fill",
"rgb(0, 128, 0)"); |
46 | 46 |
47 rect.setAttribute("fill", ""); | 47 rect.setAttribute("fill", ""); |
48 shouldBeEqualToString("document.defaultView.getComputedStyle(rect, null).fill",
"rgb(0, 0, 0)"); | 48 shouldBeEqualToString("document.defaultView.getComputedStyle(rect, null).fill",
"rgb(0, 0, 0)"); |
49 // Reset to green. | 49 // Reset to green. |
50 rect.setAttribute("fill", "green"); | 50 rect.setAttribute("fill", "green"); |
51 shouldBeEqualToString("document.defaultView.getComputedStyle(rect, null).fill",
"rgb(0, 128, 0)"); | 51 shouldBeEqualToString("document.defaultView.getComputedStyle(rect, null).fill",
"rgb(0, 128, 0)"); |
52 | 52 |
(...skipping 13 matching lines...) Expand all Loading... |
66 // Testing 'stroke' | 66 // Testing 'stroke' |
67 // The default stroke value should be 'none'. | 67 // The default stroke value should be 'none'. |
68 shouldBeEqualToString("document.defaultView.getComputedStyle(rect, null).stroke"
, "none"); | 68 shouldBeEqualToString("document.defaultView.getComputedStyle(rect, null).stroke"
, "none"); |
69 | 69 |
70 // Set the stroke color to green. | 70 // Set the stroke color to green. |
71 rect.setAttribute("stroke", "green"); | 71 rect.setAttribute("stroke", "green"); |
72 shouldBeEqualToString("document.defaultView.getComputedStyle(rect, null).stroke"
, "rgb(0, 128, 0)"); | 72 shouldBeEqualToString("document.defaultView.getComputedStyle(rect, null).stroke"
, "rgb(0, 128, 0)"); |
73 | 73 |
74 // Set following colors should be invalid. | 74 // Set following colors should be invalid. |
75 rect.setAttribute("stroke", "f00"); | 75 rect.setAttribute("stroke", "f00"); |
76 shouldBeNull("document.defaultView.getComputedStyle(rect, null).stroke"); | 76 shouldBeEqualToString("document.defaultView.getComputedStyle(rect, null).stroke"
, "none"); |
77 // Reset to green. | 77 // Reset to green. |
78 rect.setAttribute("stroke", "green"); | 78 rect.setAttribute("stroke", "green"); |
79 shouldBeEqualToString("document.defaultView.getComputedStyle(rect, null).stroke"
, "rgb(0, 128, 0)"); | 79 shouldBeEqualToString("document.defaultView.getComputedStyle(rect, null).stroke"
, "rgb(0, 128, 0)"); |
80 | 80 |
81 rect.setAttribute("stroke", "ff00"); | 81 rect.setAttribute("stroke", "ff00"); |
82 shouldBeNull("document.defaultView.getComputedStyle(rect, null).stroke"); | 82 shouldBeEqualToString("document.defaultView.getComputedStyle(rect, null).stroke"
, "none"); |
83 // Reset to green. | 83 // Reset to green. |
84 rect.setAttribute("stroke", "green"); | 84 rect.setAttribute("stroke", "green"); |
85 shouldBeEqualToString("document.defaultView.getComputedStyle(rect, null).stroke"
, "rgb(0, 128, 0)"); | 85 shouldBeEqualToString("document.defaultView.getComputedStyle(rect, null).stroke"
, "rgb(0, 128, 0)"); |
86 | 86 |
87 rect.setAttribute("stroke", "ff0000"); | 87 rect.setAttribute("stroke", "ff0000"); |
88 shouldBeNull("document.defaultView.getComputedStyle(rect, null).stroke"); | 88 shouldBeEqualToString("document.defaultView.getComputedStyle(rect, null).stroke"
, "none"); |
89 // Reset to green. | 89 // Reset to green. |
90 rect.setAttribute("stroke", "green"); | 90 rect.setAttribute("stroke", "green"); |
91 shouldBeEqualToString("document.defaultView.getComputedStyle(rect, null).stroke"
, "rgb(0, 128, 0)"); | 91 shouldBeEqualToString("document.defaultView.getComputedStyle(rect, null).stroke"
, "rgb(0, 128, 0)"); |
92 | 92 |
93 rect.setAttribute("stroke", "ff00"); | 93 rect.setAttribute("stroke", "ff00"); |
94 shouldBeNull("document.defaultView.getComputedStyle(rect, null).stroke"); | 94 shouldBeEqualToString("document.defaultView.getComputedStyle(rect, null).stroke"
, "none"); |
95 // Reset to green. | 95 // Reset to green. |
96 rect.setAttribute("stroke", "green"); | 96 rect.setAttribute("stroke", "green"); |
97 shouldBeEqualToString("document.defaultView.getComputedStyle(rect, null).stroke"
, "rgb(0, 128, 0)"); | 97 shouldBeEqualToString("document.defaultView.getComputedStyle(rect, null).stroke"
, "rgb(0, 128, 0)"); |
98 | 98 |
99 rect.setAttribute("stroke", ""); | 99 rect.setAttribute("stroke", ""); |
100 shouldBeEqualToString("document.defaultView.getComputedStyle(rect, null).stroke"
, "none"); | 100 shouldBeEqualToString("document.defaultView.getComputedStyle(rect, null).stroke"
, "none"); |
101 // Reset to green. | 101 // Reset to green. |
102 rect.setAttribute("stroke", "green"); | 102 rect.setAttribute("stroke", "green"); |
103 shouldBeEqualToString("document.defaultView.getComputedStyle(rect, null).stroke"
, "rgb(0, 128, 0)"); | 103 shouldBeEqualToString("document.defaultView.getComputedStyle(rect, null).stroke"
, "rgb(0, 128, 0)"); |
104 | 104 |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
230 | 230 |
231 rect.setAttribute("flood-color", ""); | 231 rect.setAttribute("flood-color", ""); |
232 shouldBeEqualToString("document.defaultView.getComputedStyle(rect, null).floodCo
lor", "rgb(0, 0, 0)"); | 232 shouldBeEqualToString("document.defaultView.getComputedStyle(rect, null).floodCo
lor", "rgb(0, 0, 0)"); |
233 // Reset to green. | 233 // Reset to green. |
234 rect.setAttribute("flood-color", "green"); | 234 rect.setAttribute("flood-color", "green"); |
235 shouldBeEqualToString("document.defaultView.getComputedStyle(rect, null).floodCo
lor", "rgb(0, 128, 0)"); | 235 shouldBeEqualToString("document.defaultView.getComputedStyle(rect, null).floodCo
lor", "rgb(0, 128, 0)"); |
236 | 236 |
237 var successfullyParsed = true; | 237 var successfullyParsed = true; |
238 | 238 |
239 completeTest(); | 239 completeTest(); |
OLD | NEW |