| OLD | NEW |
| 1 description("Test the parsing of the background-blend-mode property."); | 1 description("Test the parsing of the background-blend-mode property."); |
| 2 | 2 |
| 3 function jsWrapperClass(node) | 3 function jsWrapperClass(node) |
| 4 { | 4 { |
| 5 if (!node) | 5 if (!node) |
| 6 return "[null]"; | 6 return "[null]"; |
| 7 var string = Object.prototype.toString.apply(node); | 7 var string = Object.prototype.toString.apply(node); |
| 8 return string.substr(8, string.length - 9); | 8 return string.substr(8, string.length - 9); |
| 9 } | 9 } |
| 10 | 10 |
| 11 function shouldBeType(expression, className, prototypeName, constructorName) | 11 function shouldBeType(expression, className, prototypeName, constructorName) |
| 12 { | 12 { |
| 13 if (!prototypeName) | 13 if (!prototypeName) |
| 14 prototypeName = className + "Prototype"; | 14 prototypeName = "Object"; |
| 15 if (!constructorName) | 15 if (!constructorName) |
| 16 constructorName = className + "Constructor"; | 16 constructorName = "Function"; |
| 17 shouldBe("jsWrapperClass(" + expression + ")", "'" + className + "'"); | 17 shouldBe("jsWrapperClass(" + expression + ")", "'" + className + "'"); |
| 18 shouldBe("jsWrapperClass(" + expression + ".__proto__)", "'" + prototypeName
+ "'"); | 18 shouldBe("jsWrapperClass(" + expression + ".__proto__)", "'" + prototypeName
+ "'"); |
| 19 shouldBe("jsWrapperClass(" + expression + ".constructor)", "'" + constructor
Name + "'"); | 19 shouldBe("jsWrapperClass(" + expression + ".constructor)", "'" + constructor
Name + "'"); |
| 20 } | 20 } |
| 21 | 21 |
| 22 // These have to be global for the test helpers to see them. | 22 // These have to be global for the test helpers to see them. |
| 23 var stylesheet, cssRule, declaration, blendModeRule, subRule; | 23 var stylesheet, cssRule, declaration, blendModeRule, subRule; |
| 24 var styleElement = document.createElement("style"); | 24 var styleElement = document.createElement("style"); |
| 25 document.head.appendChild(styleElement); | 25 document.head.appendChild(styleElement); |
| 26 stylesheet = styleElement.sheet; | 26 stylesheet = styleElement.sheet; |
| 27 | 27 |
| 28 function testBlendModeRule(description, rule, expectedLength, expectedValue, exp
ectedTypes, expectedTexts) | 28 function testBlendModeRule(description, rule, expectedLength, expectedValue, exp
ectedTypes, expectedTexts) |
| 29 { | 29 { |
| 30 debug(""); | 30 debug(""); |
| 31 debug(description + " : " + rule); | 31 debug(description + " : " + rule); |
| 32 | 32 |
| 33 stylesheet.insertRule("body { background-blend-mode: " + rule + "; }", 0); | 33 stylesheet.insertRule("body { background-blend-mode: " + rule + "; }", 0); |
| 34 cssRule = stylesheet.cssRules.item(0); | 34 cssRule = stylesheet.cssRules.item(0); |
| 35 | 35 |
| 36 shouldBe("cssRule.type", "1"); | 36 shouldBe("cssRule.type", "1"); |
| 37 | 37 |
| 38 declaration = cssRule.style; | 38 declaration = cssRule.style; |
| 39 shouldBe("declaration.length", "1"); | 39 shouldBe("declaration.length", "1"); |
| 40 shouldBe("declaration.getPropertyValue('background-blend-mode')", "'" + expe
ctedValue + "'"); | 40 shouldBe("declaration.getPropertyValue('background-blend-mode')", "'" + expe
ctedValue + "'"); |
| 41 | 41 |
| 42 blendModeRule = declaration.getPropertyCSSValue('background-blend-mode'); | 42 blendModeRule = declaration.getPropertyCSSValue('background-blend-mode'); |
| 43 » if(rule.indexOf(',') == -1) | 43 if(rule.indexOf(',') == -1) |
| 44 » shouldBeType("blendModeRule", "CSSPrimitiveValue"); | 44 shouldBeType("blendModeRule", "CSSPrimitiveValue"); |
| 45 » else | 45 else |
| 46 » shouldBeType("blendModeRule", "CSSValueList"); | 46 shouldBeType("blendModeRule", "CSSValueList"); |
| 47 } | 47 } |
| 48 | 48 |
| 49 var blendmodes = ["normal", "multiply, screen", "screen, hue", "overlay, normal"
, "darken, lighten, normal, luminosity", "lighten", "color-dodge", "color-burn",
"hard-light", "soft-light", "difference", "exclusion", "hue", "saturation", "co
lor", "luminosity"]; | 49 var blendmodes = ["normal", "multiply, screen", "screen, hue", "overlay, normal"
, "darken, lighten, normal, luminosity", "lighten", "color-dodge", "color-burn",
"hard-light", "soft-light", "difference", "exclusion", "hue", "saturation", "co
lor", "luminosity"]; |
| 50 | 50 |
| 51 for(x in blendmodes) | 51 for(x in blendmodes) |
| 52 testBlendModeRule("Basic reference", blendmodes[x], 1, blendmodes[x]); | 52 testBlendModeRule("Basic reference", blendmodes[x], 1, blendmodes[x]); |
| 53 | 53 |
| 54 | 54 |
| 55 successfullyParsed = true; | 55 successfullyParsed = true; |
| OLD | NEW |