OLD | NEW |
1 <html> | 1 <html> |
2 <head id="head"> | 2 <head id="head"> |
3 <script src="../../resources/js-test.js"></script> | 3 <script src="../../resources/js-test.js"></script> |
4 </head> | 4 </head> |
5 <body> | 5 <body> |
6 <script> | 6 <script> |
7 | 7 |
8 description("This tests parsing and re-serialization of some CSS selectors."); | 8 description("This tests parsing and re-serialization of some CSS selectors."); |
9 | 9 |
10 function parseThenSerializeRule(rule) | 10 function parseThenSerializeRule(rule) |
11 { | 11 { |
12 var styleElement = document.getElementById("style"); | 12 var styleElement = document.getElementById("style"); |
13 var head = document.getElementById("head"); | 13 var head = document.getElementById("head"); |
14 if (styleElement) | 14 if (styleElement) |
15 head.removeChild(styleElement); | 15 head.removeChild(styleElement); |
16 | 16 |
17 styleElement = document.createElement("style"); | 17 styleElement = document.createElement("style"); |
18 styleElement.id = "style"; | 18 styleElement.id = "style"; |
19 var head = document.getElementById("head"); | 19 var head = document.getElementById("head"); |
20 head.appendChild(styleElement); | 20 head.appendChild(styleElement); |
21 | 21 |
| 22 styleElement.appendChild(document.createTextNode("@namespace n url('test');"
)); |
22 styleElement.appendChild(document.createTextNode(rule)); | 23 styleElement.appendChild(document.createTextNode(rule)); |
23 return styleElement.sheet.cssRules[0].cssText; | 24 return styleElement.sheet.cssRules[1].cssText; |
24 } | 25 } |
25 | 26 |
26 function testSelectorRoundTrip(selector) | 27 function testSelectorRoundTrip(selector) |
27 { | 28 { |
28 shouldBe("parseThenSerializeRule('" + selector + " { }')", "'" + selector +
" { }'"); | 29 shouldBe("parseThenSerializeRule('" + selector + " { }')", "'" + selector +
" { }'"); |
29 } | 30 } |
30 | 31 |
31 testSelectorRoundTrip('*'); | 32 testSelectorRoundTrip('*'); |
32 testSelectorRoundTrip('a'); | 33 testSelectorRoundTrip('a'); |
33 testSelectorRoundTrip('#a'); | 34 testSelectorRoundTrip('#a'); |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 shouldBe("parseThenSerializeRule(':before { }')", "'::before { }'"); | 158 shouldBe("parseThenSerializeRule(':before { }')", "'::before { }'"); |
158 shouldBe("parseThenSerializeRule(':first-letter { }')", "'::first-letter { }'"); | 159 shouldBe("parseThenSerializeRule(':first-letter { }')", "'::first-letter { }'"); |
159 shouldBe("parseThenSerializeRule(':first-line { }')", "'::first-line { }'"); | 160 shouldBe("parseThenSerializeRule(':first-line { }')", "'::first-line { }'"); |
160 shouldBe("parseThenSerializeRule(':-webkit-any( a.class1 , #id,[att
r] ) { }')","':-webkit-any(a.class1,#id,[attr]) { }'"); | 161 shouldBe("parseThenSerializeRule(':-webkit-any( a.class1 , #id,[att
r] ) { }')","':-webkit-any(a.class1,#id,[attr]) { }'"); |
161 | 162 |
162 debug(''); | 163 debug(''); |
163 | 164 |
164 </script> | 165 </script> |
165 </body> | 166 </body> |
166 </html> | 167 </html> |
OLD | NEW |