1 description('Testing the parsing of the -webkit-shape-outside property.');
3 function testCSSText(declaration, expected)
5 var element = document.createElement("div");
6 element.style.cssText = "-webkit-shape-outside: " + declaration;
7 return element.style.webkitShapeOutside;
10 function testComputedStyle(value, expected) {
11 var element = document.createElement("div");
12 document.body.appendChild(element);
13 element.style.setProperty("-webkit-shape-outside", value);
15 var computedStyle = getComputedStyle(element);
16 var actualValue = computedStyle.getPropertyValue("-webkit-shape-outside");
17 document.body.removeChild(element);
22 function testNotInherited(parentValue, childValue) {
23 var parentElement = document.createElement("div");
24 document.body.appendChild(parentElement);
25 parentElement.style.setProperty("-webkit-shape-outside", parentValue);
27 var childElement = document.createElement("div");
28 parentElement.appendChild(childElement);
29 childElement.style.setProperty("-webkit-shape-outside", childValue);
31 var parentComputedStyle = getComputedStyle(parentElement);
32 var parentActual = parentComputedStyle.getPropertyValue('-webkit-shape-outside')
34 var childComputedStyle = getComputedStyle(childElement);
35 var childActual = childComputedStyle.getPropertyValue('-webkit-shape-outside')
37 parentElement.removeChild(childElement);
38 document.body.removeChild(parentElement);
40 return "parent: " + parentActual + ", child: " + childActual;
43 function test(value, expected) {
44 var unevaledString = '"' + value.replace(/\\/g, "\\\\").replace(/"/g, "\"").replace(/\n/g, "\\n").replace(/\r/g, "\\r") + '"';
45 shouldBeEqualToString('testCSSText(' + unevaledString + ')', expected);
46 shouldBeEqualToString('testComputedStyle(' + unevaledString + ')', expected);
49 function negative_test(value) {
50 var unevaledString = '"' + value.replace(/\\/g, "\\\\").replace(/"/g, "\"").replace(/\n/g, "\\n").replace(/\r/g, "\\r") + '"';
51 shouldBeEqualToString('testCSSText(' + unevaledString + ')', '');
52 shouldBeEqualToString('testComputedStyle(' + unevaledString + ')', 'auto');
58 test("rectangle(10px, 20px, 30px, 40px)", "rectangle(10px, 20px, 30px, 40px)");
59 test("rectangle(10px, 20px, 30px, 40px, 5px)", "rectangle(10px, 20px, 30px, 40px, 5px)");
60 test("rectangle(10px, 20px, 30px, 40px, 5px, 10px)", "rectangle(10px, 20px, 30px, 40px, 5px, 10px)");
62 test("circle(10px, 20px, 30px)", "circle(10px, 20px, 30px)");
64 test("ellipse(10px, 20px, 30px, 40px)", "ellipse(10px, 20px, 30px, 40px)");
66 test("polygon(10px 20px, 30px 40px, 40px 50px)", "polygon(nonzero, 10px 20px, 30px 40px, 40px 50px)");
67 test("polygon(evenodd, 10px 20px, 30px 40px, 40px 50px)", "polygon(evenodd, 10px 20px, 30px 40px, 40px 50px)");
68 test("polygon(nonzero, 10px 20px, 30px 40px, 40px 50px)", "polygon(nonzero, 10px 20px, 30px 40px, 40px 50px)");
70 shouldBeEqualToString('testNotInherited("auto", "rectangle(10px, 20px, 30px, 40px)")', "parent: auto, child: rectangle(10px, 20px, 30px, 40px)");
71 shouldBeEqualToString('testNotInherited("rectangle(10px, 20px, 30px, 40px)", "initial")', "parent: rectangle(10px, 20px, 30px, 40px), child: auto");
72 shouldBeEqualToString('testNotInherited("rectangle(10px, 20px, 30px, 40px)", "")', "parent: rectangle(10px, 20px, 30px, 40px), child: auto");
73 shouldBeEqualToString('testNotInherited("rectangle(10px, 20px, 30px, 40px)", "inherit")', "parent: rectangle(10px, 20px, 30px, 40px), child: rectangle(10px, 20px, 30px, 40px)");
74 shouldBeEqualToString('testNotInherited("", "inherit")', "parent: auto, child: auto");
75 shouldBeEqualToString('testNotInherited("auto", "inherit")', "parent: auto, child: auto");
79 negative_test("calc()");
80 negative_test("none");
82 negative_test("rectangle()");
83 negative_test("rectangle(10px)");
84 negative_test("rectangle(10px, 10px)");
85 negative_test("rectangle(10px, 20px, 30px)");
86 negative_test("rectangle(10px 20px 30px 40px)");
87 negative_test("rectangle(10px, 20px, 30px, 40px, 50px, 60px, 70px)");
89 negative_test("circle()");
90 negative_test("circle(10px)");
91 negative_test("circle(10px, 20px)");
92 negative_test("circle(10px 20px 30px)");
93 negative_test("circle(10px, 20px, 30px, 40px)");
95 negative_test("ellipse()");
96 negative_test("ellipse(10px)");
97 negative_test("ellipse(10px, 20px)");
98 negative_test("ellipse(10px, 20px, 30px)");
99 negative_test("ellipse(10px 20px 30px 40px)");
101 negative_test("polygon()");
102 negative_test("polygon(evenodd 10px 20px, 30px 40px, 40px 50px)");
103 negative_test("polygon(nonzero 10px 20px, 30px 40px, 40px 50px)");
104 negative_test("polygon(nonzero)");
105 negative_test("polygon(evenodd)");
106 negative_test("polygon(10px)");
107 negative_test("polygon(nonzero,10px)");
108 negative_test("polygon(evenodd,12px)");
109 negative_test("polygon(10px, 20px, 30px, 40px, 40px, 50px)");