OLD | NEW |
1 description("Test the parsing of the -webkit-filter property."); | 1 description("Test the parsing of the -webkit-filter property."); |
2 | 2 |
3 // These have to be global for the test helpers to see them. | 3 // These have to be global for the test helpers to see them. |
4 var stylesheet, cssRule, declaration; | 4 var stylesheet, cssRule, declaration; |
5 var styleElement = document.createElement("style"); | 5 var styleElement = document.createElement("style"); |
6 document.head.appendChild(styleElement); | 6 document.head.appendChild(styleElement); |
7 stylesheet = styleElement.sheet; | 7 stylesheet = styleElement.sheet; |
8 | 8 |
9 function testInvalidFilterRule(description, rule) | 9 function testInvalidFilterRule(description, rule) |
10 { | 10 { |
11 debug(""); | 11 debug(""); |
12 debug(description + " : " + rule); | 12 debug(description + " : " + rule); |
13 | 13 |
14 stylesheet.insertRule("body { -webkit-filter: " + rule + "; }", 0); | 14 stylesheet.insertRule("body { -webkit-filter: " + rule + "; }", 0); |
15 cssRule = stylesheet.cssRules.item(0); | 15 cssRule = stylesheet.cssRules.item(0); |
16 | 16 |
17 shouldBe("cssRule.type", "1"); | 17 shouldBe("cssRule.type", "1"); |
18 | 18 |
19 declaration = cssRule.style; | 19 declaration = cssRule.style; |
20 shouldBe("declaration.length", "0"); | 20 shouldBe("declaration.length", "0"); |
21 shouldBe("declaration.getPropertyValue('-webkit-filter')", "null"); | 21 shouldBeEqualToString("declaration.getPropertyValue('-webkit-filter')", ""); |
22 } | 22 } |
23 | 23 |
24 testInvalidFilterRule("Too many parameters", "url(#a #b)"); | 24 testInvalidFilterRule("Too many parameters", "url(#a #b)"); |
25 | 25 |
26 testInvalidFilterRule("Length instead of number", "grayscale(10px)"); | 26 testInvalidFilterRule("Length instead of number", "grayscale(10px)"); |
27 testInvalidFilterRule("Too many parameters", "grayscale(0.5 0.5)"); | 27 testInvalidFilterRule("Too many parameters", "grayscale(0.5 0.5)"); |
28 testInvalidFilterRule("Too many parameters and commas", "grayscale(0.5, 0.5)"); | 28 testInvalidFilterRule("Too many parameters and commas", "grayscale(0.5, 0.5)"); |
29 testInvalidFilterRule("Trailing comma", "grayscale(0.5,)"); | 29 testInvalidFilterRule("Trailing comma", "grayscale(0.5,)"); |
30 testInvalidFilterRule("Negative parameter", "grayscale(-0.5)"); | 30 testInvalidFilterRule("Negative parameter", "grayscale(-0.5)"); |
31 testInvalidFilterRule("Negative percent", "grayscale(-10%)"); | 31 testInvalidFilterRule("Negative percent", "grayscale(-10%)"); |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 testInvalidFilterRule("Not enough lengths", "drop-shadow(red 1px)"); | 91 testInvalidFilterRule("Not enough lengths", "drop-shadow(red 1px)"); |
92 testInvalidFilterRule("Missing units", "drop-shadow(red 1 2 3)"); | 92 testInvalidFilterRule("Missing units", "drop-shadow(red 1 2 3)"); |
93 testInvalidFilterRule("Inset", "drop-shadow(red 1px 2px 3px inset)"); | 93 testInvalidFilterRule("Inset", "drop-shadow(red 1px 2px 3px inset)"); |
94 testInvalidFilterRule("Too many parameters", "drop-shadow(red 1px 2px 3px 4px)")
; | 94 testInvalidFilterRule("Too many parameters", "drop-shadow(red 1px 2px 3px 4px)")
; |
95 testInvalidFilterRule("Commas", "drop-shadow(red, 1px, 2px, 3px)"); | 95 testInvalidFilterRule("Commas", "drop-shadow(red, 1px, 2px, 3px)"); |
96 testInvalidFilterRule("Negative radius", "drop-shadow(10px 10px -1px red)"); | 96 testInvalidFilterRule("Negative radius", "drop-shadow(10px 10px -1px red)"); |
97 | 97 |
98 testInvalidFilterRule("Unknown function", "fancify(150%)"); | 98 testInvalidFilterRule("Unknown function", "fancify(150%)"); |
99 | 99 |
100 successfullyParsed = true; | 100 successfullyParsed = true; |
OLD | NEW |