[CSS Blending] Refactor -webkit-blend-mode to -webkit-mix-blend-mode
[WebKit-https.git] / LayoutTests / css3 / compositing / script-tests / blend-mode-property-parsing.js
1 description("Test the parsing of the -webkit-mix-blend-mode property.");
2
3 function jsWrapperClass(node)
4 {
5     if (!node)
6         return "[null]";
7     var string = Object.prototype.toString.apply(node);
8     return string.substr(8, string.length - 9);
9 }
10
11 function shouldBeType(expression, className, prototypeName, constructorName)
12 {
13     if (!prototypeName)
14         prototypeName = className + "Prototype";
15     if (!constructorName)
16         constructorName = className + "Constructor";
17     shouldBe("jsWrapperClass(" + expression + ")", "'" + className + "'");
18     shouldBe("jsWrapperClass(" + expression + ".__proto__)", "'" + prototypeName + "'");
19     shouldBe("jsWrapperClass(" + expression + ".constructor)", "'" + constructorName + "'");
20 }
21
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;
27
28 function testBlendModeRule(description, rule, expectedLength, expectedValue, expectedTypes, expectedTexts)
29 {
30     debug("");
31     debug(description + " : " + rule);
32
33     stylesheet.insertRule("body { -webkit-mix-blend-mode: " + rule + "; }", 0);
34     cssRule = stylesheet.cssRules.item(0);
35   
36     shouldBe("cssRule.type", "1");
37
38     declaration = cssRule.style;
39     shouldBe("declaration.length", "1");
40     shouldBe("declaration.getPropertyValue('-webkit-mix-blend-mode')", "'" + expectedValue + "'");
41
42     blendModeRule = declaration.getPropertyCSSValue('-webkit-mix-blend-mode');
43     shouldBeType("blendModeRule", "CSSPrimitiveValue");
44 }
45
46 var blendmodes = ["normal", "multiply", "screen", "overlay", "darken", "lighten", "color-dodge", "color-burn", "hard-light", "soft-light", "difference", "exclusion", "hue", "saturation", "color", "luminosity"];
47
48 for(x in blendmodes)
49    testBlendModeRule("Basic reference", blendmodes[x], 1, blendmodes[x]);
50
51
52 successfullyParsed = true;