1 description("Test the parsing of the background-blend-mode property.");
3 function jsWrapperClass(node)
7 var string = Object.prototype.toString.apply(node);
8 return string.substr(8, string.length - 9);
11 function shouldBeType(expression, className, prototypeName, constructorName)
14 prototypeName = "Object";
16 constructorName = "Function";
17 shouldBe("jsWrapperClass(" + expression + ")", "'" + className + "'");
18 shouldBe("jsWrapperClass(" + expression + ".__proto__)", "'" + prototypeName + "'");
19 shouldBe("jsWrapperClass(" + expression + ".constructor)", "'" + constructorName + "'");
22 // These have to be global for the test helpers to see them.
23 var stylesheet, cssRule, declaration, blendModeRule, subRule;
24 var styleElement = document.createElement("style");
25 document.head.appendChild(styleElement);
26 stylesheet = styleElement.sheet;
28 function testBlendModeRule(description, rule, expectedLength, expectedValue, expectedTypes, expectedTexts)
31 debug(description + " : " + rule);
33 stylesheet.insertRule("body { background-blend-mode: " + rule + "; }", 0);
34 cssRule = stylesheet.cssRules.item(0);
36 shouldBe("cssRule.type", "1");
38 declaration = cssRule.style;
39 shouldBe("declaration.length", "1");
40 shouldBe("declaration.getPropertyValue('background-blend-mode')", "'" + expectedValue + "'");
42 blendModeRule = declaration.getPropertyCSSValue('background-blend-mode');
43 if(rule.indexOf(',') == -1)
44 shouldBeType("blendModeRule", "CSSPrimitiveValue");
46 shouldBeType("blendModeRule", "CSSValueList");
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", "color", "luminosity"];
52 testBlendModeRule("Basic reference", blendmodes[x], 1, blendmodes[x]);
55 successfullyParsed = true;