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 #000000. | 15 // The default for fill is rgb(0, 0, 0). |
16 shouldBeEqualToString("document.defaultView.getComputedStyle(rect, null).fill",
"#000000"); | 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",
"#008000"); | 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 shouldBeNull("document.defaultView.getComputedStyle(rect, null).fill"); |
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",
"#008000"); | 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 shouldBeNull("document.defaultView.getComputedStyle(rect, null).fill"); |
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",
"#008000"); | 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 shouldBeNull("document.defaultView.getComputedStyle(rect, null).fill"); |
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",
"#008000"); | 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 shouldBeNull("document.defaultView.getComputedStyle(rect, null).fill"); |
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",
"#008000"); | 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",
"#000000"); | 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",
"#008000"); | 51 shouldBeEqualToString("document.defaultView.getComputedStyle(rect, null).fill",
"rgb(0, 128, 0)"); |
52 | 52 |
53 rect.setAttribute("fill", "url(#reference)"); | 53 rect.setAttribute("fill", "url(#reference)"); |
54 shouldBeEqualToString("document.defaultView.getComputedStyle(rect, null).fill",
"url(#reference)"); | 54 shouldBeEqualToString("document.defaultView.getComputedStyle(rect, null).fill",
"url(#reference)"); |
55 // Reset to green. | 55 // Reset to green. |
56 rect.setAttribute("fill", "green"); | 56 rect.setAttribute("fill", "green"); |
57 shouldBeEqualToString("document.defaultView.getComputedStyle(rect, null).fill",
"#008000"); | 57 shouldBeEqualToString("document.defaultView.getComputedStyle(rect, null).fill",
"rgb(0, 128, 0)"); |
58 | 58 |
59 rect.setAttribute("fill", "url(#reference) green"); | 59 rect.setAttribute("fill", "url(#reference) green"); |
60 shouldBeEqualToString("document.defaultView.getComputedStyle(rect, null).fill",
"url(#reference) #008000"); | 60 shouldBeEqualToString("document.defaultView.getComputedStyle(rect, null).fill",
"url(#reference) rgb(0, 128, 0)"); |
61 // Reset to green. | 61 // Reset to green. |
62 rect.setAttribute("fill", "green"); | 62 rect.setAttribute("fill", "green"); |
63 shouldBeEqualToString("document.defaultView.getComputedStyle(rect, null).fill",
"#008000"); | 63 shouldBeEqualToString("document.defaultView.getComputedStyle(rect, null).fill",
"rgb(0, 128, 0)"); |
64 | 64 |
65 | 65 |
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"
, "#008000"); | 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 shouldBeNull("document.defaultView.getComputedStyle(rect, null).stroke"); |
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"
, "#008000"); | 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 shouldBeNull("document.defaultView.getComputedStyle(rect, null).stroke"); |
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"
, "#008000"); | 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 shouldBeNull("document.defaultView.getComputedStyle(rect, null).stroke"); |
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"
, "#008000"); | 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 shouldBeNull("document.defaultView.getComputedStyle(rect, null).stroke"); |
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"
, "#008000"); | 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"
, "#008000"); | 103 shouldBeEqualToString("document.defaultView.getComputedStyle(rect, null).stroke"
, "rgb(0, 128, 0)"); |
104 | 104 |
105 rect.setAttribute("stroke", "url(#reference)"); | 105 rect.setAttribute("stroke", "url(#reference)"); |
106 shouldBeEqualToString("document.defaultView.getComputedStyle(rect, null).stroke"
, "url(#reference)"); | 106 shouldBeEqualToString("document.defaultView.getComputedStyle(rect, null).stroke"
, "url(#reference)"); |
107 // Reset to green. | 107 // Reset to green. |
108 rect.setAttribute("stroke", "green"); | 108 rect.setAttribute("stroke", "green"); |
109 shouldBeEqualToString("document.defaultView.getComputedStyle(rect, null).stroke"
, "#008000"); | 109 shouldBeEqualToString("document.defaultView.getComputedStyle(rect, null).stroke"
, "rgb(0, 128, 0)"); |
110 | 110 |
111 rect.setAttribute("stroke", "url(#reference) green"); | 111 rect.setAttribute("stroke", "url(#reference) green"); |
112 shouldBeEqualToString("document.defaultView.getComputedStyle(rect, null).stroke"
, "url(#reference) #008000"); | 112 shouldBeEqualToString("document.defaultView.getComputedStyle(rect, null).stroke"
, "url(#reference) rgb(0, 128, 0)"); |
113 // Reset to green. | 113 // Reset to green. |
114 rect.setAttribute("stroke", "green"); | 114 rect.setAttribute("stroke", "green"); |
115 shouldBeEqualToString("document.defaultView.getComputedStyle(rect, null).stroke"
, "#008000"); | 115 shouldBeEqualToString("document.defaultView.getComputedStyle(rect, null).stroke"
, "rgb(0, 128, 0)"); |
116 | 116 |
117 | 117 |
118 // Testing 'color' | 118 // Testing 'color' |
119 // The default for color is rgb(0, 0, 0). | 119 // The default for color is rgb(0, 0, 0). |
120 shouldBeEqualToString("document.defaultView.getComputedStyle(rect, null).color",
"rgb(0, 0, 0)"); | 120 shouldBeEqualToString("document.defaultView.getComputedStyle(rect, null).color",
"rgb(0, 0, 0)"); |
121 | 121 |
122 // Set color to green. | 122 // Set color to green. |
123 rect.setAttribute("color", "green"); | 123 rect.setAttribute("color", "green"); |
124 shouldBeEqualToString("document.defaultView.getComputedStyle(rect, null).color",
"rgb(0, 128, 0)"); | 124 shouldBeEqualToString("document.defaultView.getComputedStyle(rect, null).color",
"rgb(0, 128, 0)"); |
125 | 125 |
(...skipping 104 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 |