| OLD | NEW |
| 1 <!DOCTYPE HTML> | 1 <!DOCTYPE HTML> |
| 2 <html> | 2 <html> |
| 3 <head> | 3 <head> |
| 4 <meta charset=utf8> | 4 <meta charset=utf8> |
| 5 <script src="../resources/js-test.js"></script> | 5 <script src="../resources/js-test.js"></script> |
| 6 <style> | 6 <style> |
| 7 @supports (width: 0) { | 7 @supports (width: 0) { |
| 8 s { width: 0; } | 8 s { width: 0; } |
| 9 @supports (width: 1) { | 9 @supports (width: 1) { |
| 10 s { color: #000; } | 10 s { color: #000; } |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 </head> | 51 </head> |
| 52 <body> | 52 <body> |
| 53 <script> | 53 <script> |
| 54 description("Test CSSSupportRule."); | 54 description("Test CSSSupportRule."); |
| 55 | 55 |
| 56 | 56 |
| 57 shouldBeDefined("CSSRule.SUPPORTS_RULE"); | 57 shouldBeDefined("CSSRule.SUPPORTS_RULE"); |
| 58 | 58 |
| 59 evalAndLog("rules = document.styleSheets[1].cssRules"); | 59 evalAndLog("rules = document.styleSheets[1].cssRules"); |
| 60 shouldEvaluateTo("rules.length", 4); | 60 shouldEvaluateTo("rules.length", 4); |
| 61 shouldBeType("rules[0]", "CSSSupportsRule"); |
| 61 shouldBe("rules[0].type", "CSSRule.SUPPORTS_RULE"); | 62 shouldBe("rules[0].type", "CSSRule.SUPPORTS_RULE"); |
| 62 shouldEvaluateTo("rules[0].cssRules.length", 2); | 63 shouldEvaluateTo("rules[0].cssRules.length", 2); |
| 63 shouldBe("rules[0].cssRules[0].type", "CSSRule.STYLE_RULE"); | 64 shouldBe("rules[0].cssRules[0].type", "CSSRule.STYLE_RULE"); |
| 65 shouldBeType("rules[0].cssRules[1]", "CSSSupportsRule"); |
| 64 shouldBe("rules[0].cssRules[1].type", "CSSRule.SUPPORTS_RULE"); | 66 shouldBe("rules[0].cssRules[1].type", "CSSRule.SUPPORTS_RULE"); |
| 65 shouldEvaluateTo("rules[0].cssRules[1].cssRules.length", 1); | 67 shouldEvaluateTo("rules[0].cssRules[1].cssRules.length", 1); |
| 66 shouldBe("rules[0].cssRules[1].cssRules[0].type", "CSSRule.STYLE_RULE"); | 68 shouldBe("rules[0].cssRules[1].cssRules[0].type", "CSSRule.STYLE_RULE"); |
| 67 shouldBeEqualToString("rules[0].conditionText", "(width: 0)"); | 69 shouldBeEqualToString("rules[0].conditionText", "(width: 0)"); |
| 68 shouldBeEqualToString("rules[0].cssText", | 70 shouldBeEqualToString("rules[0].cssText", |
| 69 "@supports (width: 0) {\n" + | 71 "@supports (width: 0) {\n" + |
| 70 " s { width: 0px; }\n" + | 72 " s { width: 0px; }\n" + |
| 71 " @supports (width: 1) {\n" + | 73 " @supports (width: 1) {\n" + |
| 72 " s { color: rgb(0, 0, 0); }\n" + | 74 " s { color: rgb(0, 0, 0); }\n" + |
| 73 "}\n" + | 75 "}\n" + |
| 74 "}"); | 76 "}"); |
| 75 | 77 |
| 76 debug("\nInserting and deleting rules."); | 78 debug("\nInserting and deleting rules."); |
| 77 evalAndLog("rules[0].insertRule('@media all { #s { width: 0px; } }', 2)"); | 79 evalAndLog("rules[0].insertRule('@media all { #s { width: 0px; } }', 2)"); |
| 78 shouldEvaluateTo("rules[0].cssRules.length", 3); | 80 shouldEvaluateTo("rules[0].cssRules.length", 3); |
| 79 shouldBe("rules[0].cssRules[2].type", "CSSRule.MEDIA_RULE"); | 81 shouldBe("rules[0].cssRules[2].type", "CSSRule.MEDIA_RULE"); |
| 80 evalAndLog("rules[0].deleteRule(2)"); | 82 evalAndLog("rules[0].deleteRule(2)"); |
| 81 shouldEvaluateTo("rules[0].cssRules.length", 2); | 83 shouldEvaluateTo("rules[0].cssRules.length", 2); |
| 82 | 84 |
| 83 evalAndLog("rules[0].cssRules[1].insertRule('@supports (display: rainbow) {}
', 1)"); | 85 evalAndLog("rules[0].cssRules[1].insertRule('@supports (display: rainbow) {}
', 1)"); |
| 84 shouldEvaluateTo("rules[0].cssRules[1].cssRules.length", 2); | 86 shouldEvaluateTo("rules[0].cssRules[1].cssRules.length", 2); |
| 87 shouldBeType("rules[0].cssRules[1].cssRules[1]", "CSSSupportsRule"); |
| 85 shouldBe("rules[0].cssRules[1].cssRules[1].type", "CSSRule.SUPPORTS_RULE"); | 88 shouldBe("rules[0].cssRules[1].cssRules[1].type", "CSSRule.SUPPORTS_RULE"); |
| 86 evalAndLog("rules[0].cssRules[1].deleteRule(1)"); | 89 evalAndLog("rules[0].cssRules[1].deleteRule(1)"); |
| 87 shouldEvaluateTo("rules[0].cssRules.length", 2); | 90 shouldEvaluateTo("rules[0].cssRules.length", 2); |
| 88 | 91 |
| 89 debug("\n@charset, @namespace, @import rules are not allowed inside @support
s.") | 92 debug("\n@charset, @namespace, @import rules are not allowed inside @support
s.") |
| 90 shouldThrow("rules[0].insertRule('@charset \"UTF-8\"', 2)", '"SyntaxError: F
ailed to execute \'insertRule\' on \'CSSSupportsRule\': the rule \'@charset \\"U
TF-8\\"\' is invalid and cannot be parsed."'); | 93 shouldThrow("rules[0].insertRule('@charset \"UTF-8\"', 2)", '"SyntaxError: F
ailed to execute \'insertRule\' on \'CSSSupportsRule\': the rule \'@charset \\"U
TF-8\\"\' is invalid and cannot be parsed."'); |
| 91 shouldThrow("rules[0].insertRule('@namespace \"\"', 2)", '"SyntaxError: Fail
ed to execute \'insertRule\' on \'CSSSupportsRule\': the rule \'@namespace \\"\\
"\' is invalid and cannot be parsed."'); | 94 shouldThrow("rules[0].insertRule('@namespace \"\"', 2)", '"SyntaxError: Fail
ed to execute \'insertRule\' on \'CSSSupportsRule\': the rule \'@namespace \\"\\
"\' is invalid and cannot be parsed."'); |
| 92 shouldThrow("rules[0].insertRule('@import url(\"../fast/cssom/resources/impo
rt.css\")', 2)", '"HierarchyRequestError: Failed to execute \'insertRule\' on \'
CSSSupportsRule\': \'@import\' rules cannot be inserted inside a group rule."'); | 95 shouldThrow("rules[0].insertRule('@import url(\"../fast/cssom/resources/impo
rt.css\")', 2)", '"HierarchyRequestError: Failed to execute \'insertRule\' on \'
CSSSupportsRule\': \'@import\' rules cannot be inserted inside a group rule."'); |
| 93 | 96 |
| 94 | 97 |
| 95 debug("\nWhitespace and formatting should be preserved within the condition,
whitespace outside the condition should be trimmed."); | 98 debug("\nWhitespace and formatting should be preserved within the condition,
whitespace outside the condition should be trimmed."); |
| 96 shouldBeEqualToString("rules[1].conditionText", "(( ( padding: 0) an
d (display: none)) or (display: rainbow))"); | 99 shouldBeEqualToString("rules[1].conditionText", "(( ( padding: 0) an
d (display: none)) or (display: rainbow))"); |
| 97 | 100 |
| 98 | 101 |
| 99 debug("\n@supports rule nested inside a media rule."); | 102 debug("\n@supports rule nested inside a media rule."); |
| 100 shouldBe("rules[2].type", "CSSRule.MEDIA_RULE"); | 103 shouldBe("rules[2].type", "CSSRule.MEDIA_RULE"); |
| 101 shouldEvaluateTo("rules[2].cssRules.length", 1); | 104 shouldEvaluateTo("rules[2].cssRules.length", 1); |
| 105 shouldBeType("rules[2].cssRules[0]", "CSSSupportsRule"); |
| 102 shouldBe("rules[2].cssRules[0].type", "CSSRule.SUPPORTS_RULE"); | 106 shouldBe("rules[2].cssRules[0].type", "CSSRule.SUPPORTS_RULE"); |
| 103 shouldBeEqualToString("rules[2].cssRules[0].conditionText", "( padding: 0)")
; | 107 shouldBeEqualToString("rules[2].cssRules[0].conditionText", "( padding: 0)")
; |
| 104 shouldEvaluateTo("rules[0].cssRules[1].cssRules.length", 1); | 108 shouldEvaluateTo("rules[0].cssRules[1].cssRules.length", 1); |
| 105 shouldBe("rules[2].cssRules[0].cssRules[0].type", "CSSRule.PAGE_RULE"); | 109 shouldBe("rules[2].cssRules[0].cssRules[0].type", "CSSRule.PAGE_RULE"); |
| 106 shouldBeEqualToString("rules[2].cssText", | 110 shouldBeEqualToString("rules[2].cssText", |
| 107 "@media all { \n" + | 111 "@media all { \n" + |
| 108 " @supports ( padding: 0) {\n" + | 112 " @supports ( padding: 0) {\n" + |
| 109 " @page :left { top: 0px; }\n" + | 113 " @page :left { top: 0px; }\n" + |
| 110 "}\n" + | 114 "}\n" + |
| 111 "}"); | 115 "}"); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 122 shouldEvaluateTo("rules[0].cssRules.length", 2); | 126 shouldEvaluateTo("rules[0].cssRules.length", 2); |
| 123 shouldBe("rules[0].cssRules[0].type", "CSSRule.STYLE_RULE"); | 127 shouldBe("rules[0].cssRules[0].type", "CSSRule.STYLE_RULE"); |
| 124 shouldBe("rules[0].cssRules[1].type", "CSSRule.SUPPORTS_RULE"); | 128 shouldBe("rules[0].cssRules[1].type", "CSSRule.SUPPORTS_RULE"); |
| 125 shouldEvaluateTo("rules[0].cssRules[1].cssRules.length", 1); | 129 shouldEvaluateTo("rules[0].cssRules[1].cssRules.length", 1); |
| 126 shouldBe("rules[0].cssRules[1].cssRules[0].type", "CSSRule.STYLE_RULE"); | 130 shouldBe("rules[0].cssRules[1].cssRules[0].type", "CSSRule.STYLE_RULE"); |
| 127 | 131 |
| 128 </script> | 132 </script> |
| 129 </body> | 133 </body> |
| 130 </html> | 134 </html> |
| 131 | 135 |
| OLD | NEW |