| 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 setting and re-serialization of some CSS selectors."); | 8 description("This tests setting and re-serialization of some CSS selectors."); |
| 9 | 9 |
| 10 var bogusSelector = "_foo"; | 10 var bogusSelector = "_foo"; |
| 11 | 11 |
| 12 function setThenReadSelectorText(selector) | 12 function setThenReadSelectorText(selector) |
| 13 { | 13 { |
| 14 var styleElement = document.getElementById("style"); | 14 var styleElement = document.getElementById("style"); |
| 15 var head = document.getElementById("head"); | 15 var head = document.getElementById("head"); |
| 16 if (styleElement) | 16 if (styleElement) |
| 17 head.removeChild(styleElement); | 17 head.removeChild(styleElement); |
| 18 | 18 |
| 19 styleElement = document.createElement("style"); | 19 styleElement = document.createElement("style"); |
| 20 styleElement.id = "style"; | 20 styleElement.id = "style"; |
| 21 var head = document.getElementById("head"); | 21 var head = document.getElementById("head"); |
| 22 head.appendChild(styleElement); | 22 head.appendChild(styleElement); |
| 23 | 23 |
| 24 // First, create a rule with a bogus selector. | 24 // First, create a rule with a bogus selector. |
| 25 styleElement.appendChild(document.createTextNode(bogusSelector + " { }")); | 25 styleElement.appendChild(document.createTextNode("@namespace n url(test); "
+ bogusSelector + " { }")); |
| 26 // Now, set the desired selector text. | 26 // Now, set the desired selector text. |
| 27 styleElement.sheet.cssRules[0].selectorText = selector; | 27 styleElement.sheet.cssRules[1].selectorText = selector; |
| 28 return styleElement.sheet.cssRules[0].selectorText; | 28 return styleElement.sheet.cssRules[1].selectorText; |
| 29 } | 29 } |
| 30 | 30 |
| 31 function testSelectorRoundTrip(selector, expectFailure) | 31 function testSelectorRoundTrip(selector, expectFailure) |
| 32 { | 32 { |
| 33 shouldBe("setThenReadSelectorText('" + selector + "')", "'" + (expectFailure
? bogusSelector : selector) + "'"); | 33 shouldBe("setThenReadSelectorText('" + selector + "')", "'" + (expectFailure
? bogusSelector : selector) + "'"); |
| 34 } | 34 } |
| 35 | 35 |
| 36 testSelectorRoundTrip('', true); | 36 testSelectorRoundTrip('', true); |
| 37 testSelectorRoundTrip('123', true); | 37 testSelectorRoundTrip('123', true); |
| 38 testSelectorRoundTrip('-', true); | 38 testSelectorRoundTrip('-', true); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 59 testSelectorRoundTrip('[a*="b"]'); | 59 testSelectorRoundTrip('[a*="b"]'); |
| 60 | 60 |
| 61 debug(''); | 61 debug(''); |
| 62 | 62 |
| 63 testSelectorRoundTrip('*|a'); | 63 testSelectorRoundTrip('*|a'); |
| 64 testSelectorRoundTrip('n|a'); | 64 testSelectorRoundTrip('n|a'); |
| 65 testSelectorRoundTrip('*|*'); | 65 testSelectorRoundTrip('*|*'); |
| 66 testSelectorRoundTrip('n|*'); | 66 testSelectorRoundTrip('n|*'); |
| 67 testSelectorRoundTrip('[*|a]'); | 67 testSelectorRoundTrip('[*|a]'); |
| 68 testSelectorRoundTrip('[n|a]'); | 68 testSelectorRoundTrip('[n|a]'); |
| 69 testSelectorRoundTrip('unresolved|a', true); |
| 70 testSelectorRoundTrip('unresolved|*', true); |
| 71 testSelectorRoundTrip('[unresolved|a]', true); |
| 69 | 72 |
| 70 debug(''); | 73 debug(''); |
| 71 | 74 |
| 72 testSelectorRoundTrip('a:active'); | 75 testSelectorRoundTrip('a:active'); |
| 73 testSelectorRoundTrip('a b'); | 76 testSelectorRoundTrip('a b'); |
| 74 testSelectorRoundTrip('a + b'); | 77 testSelectorRoundTrip('a + b'); |
| 75 testSelectorRoundTrip('a ~ b'); | 78 testSelectorRoundTrip('a ~ b'); |
| 76 testSelectorRoundTrip('a > b'); | 79 testSelectorRoundTrip('a > b'); |
| 77 | 80 |
| 78 debug(''); | 81 debug(''); |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 174 shouldBe("setThenReadSelectorText(':before')", "'::before'"); | 177 shouldBe("setThenReadSelectorText(':before')", "'::before'"); |
| 175 shouldBe("setThenReadSelectorText(':first-letter')", "'::first-letter'"); | 178 shouldBe("setThenReadSelectorText(':first-letter')", "'::first-letter'"); |
| 176 shouldBe("setThenReadSelectorText(':first-line')", "'::first-line'"); | 179 shouldBe("setThenReadSelectorText(':first-line')", "'::first-line'"); |
| 177 shouldBe("setThenReadSelectorText(':-webkit-any( a.class1 , #id,[att
r] )')","':-webkit-any(a.class1,#id,[attr])'"); | 180 shouldBe("setThenReadSelectorText(':-webkit-any( a.class1 , #id,[att
r] )')","':-webkit-any(a.class1,#id,[attr])'"); |
| 178 | 181 |
| 179 debug(''); | 182 debug(''); |
| 180 | 183 |
| 181 </script> | 184 </script> |
| 182 </body> | 185 </body> |
| 183 </html> | 186 </html> |
| OLD | NEW |