1 function testElementStyle(propertyJS, propertyCSS, value)
3 shouldBe("e.style." + propertyJS, "'" + value + "'");
4 shouldBe("e.style.getPropertyValue('" + propertyCSS + "')", "'" + value + "'");
7 function testComputedStyle(propertyJS, propertyCSS, value)
9 computedStyle = window.getComputedStyle(e, null);
10 shouldBe("computedStyle." + propertyJS, "'" + value + "'");
11 shouldBe("computedStyle.getPropertyValue('" + propertyCSS + "')", "'" + value + "'");
14 function valueSettingTest(value, expectedValue, computedValue)
16 debug("Value '" + value + "':");
17 e.style.textIndent = value;
18 testElementStyle("textIndent", "text-indent", expectedValue);
19 testComputedStyle("textIndent", "text-indent", computedValue);
23 function invalidValueSettingTest(value, defaultValue)
25 debug("Invalid value test - '" + value + "':");
26 e.style.textIndent = value;
27 testElementStyle("textIndent", "text-indent", defaultValue);
28 testComputedStyle("textIndent", "text-indent", defaultValue);
32 description("This test checks that text-indent parses properly the properties from CSS3 Text.");
34 e = document.getElementById('test');
36 debug("Test the initial value:");
37 testComputedStyle("textIndent", "text-indent", '0px');
40 valueSettingTest('100px', '100px', '100px');
41 valueSettingTest('20em', '20em', '200px');
42 valueSettingTest('50%', '50%', '50%');
43 valueSettingTest('calc(10px + 20px)', 'calc(30px)', '30px');
44 valueSettingTest('100px each-line', '100px each-line', '100px each-line');
45 valueSettingTest('each-line 100px', 'each-line 100px', '100px each-line');
46 valueSettingTest('20em each-line', '20em each-line', '200px each-line');
47 valueSettingTest('each-line 20em', 'each-line 20em', '200px each-line');
48 valueSettingTest('30% each-line', '30% each-line', '30% each-line');
49 valueSettingTest('each-line 30%', 'each-line 30%', '30% each-line');
50 valueSettingTest('calc(10px + 20px) each-line', 'calc(30px) each-line', '30px each-line');
51 valueSettingTest('each-line calc(10px + 20px)', 'each-line calc(30px)', '30px each-line');
52 valueSettingTest('100px hanging', '100px hanging', '100px hanging');
53 valueSettingTest('hanging 100px', 'hanging 100px', '100px hanging');
54 valueSettingTest('20em hanging', '20em hanging', '200px hanging');
55 valueSettingTest('hanging 20em', 'hanging 20em', '200px hanging');
56 valueSettingTest('30% hanging', '30% hanging', '30% hanging');
57 valueSettingTest('hanging 30%', 'hanging 30%', '30% hanging');
58 valueSettingTest('calc(10px + 20px) hanging', 'calc(30px) hanging', '30px hanging');
59 valueSettingTest('hanging calc(10px + 20px)', 'hanging calc(30px)', '30px hanging');
60 valueSettingTest('100px each-line hanging', '100px each-line hanging', '100px each-line hanging');
61 valueSettingTest('each-line 100px hanging', 'each-line 100px hanging', '100px each-line hanging');
62 valueSettingTest('each-line hanging 100px', 'each-line hanging 100px', '100px each-line hanging');
63 valueSettingTest('100px hanging each-line', '100px hanging each-line', '100px each-line hanging');
64 valueSettingTest('hanging 100px each-line', 'hanging 100px each-line', '100px each-line hanging');
65 valueSettingTest('hanging each-line 100px', 'hanging each-line 100px', '100px each-line hanging');
66 valueSettingTest('30% each-line hanging', '30% each-line hanging', '30% each-line hanging');
67 valueSettingTest('each-line 30% hanging', 'each-line 30% hanging', '30% each-line hanging');
68 valueSettingTest('each-line hanging 30%', 'each-line hanging 30%', '30% each-line hanging');
69 valueSettingTest('30% hanging each-line', '30% hanging each-line', '30% each-line hanging');
70 valueSettingTest('hanging 30% each-line', 'hanging 30% each-line', '30% each-line hanging');
71 valueSettingTest('hanging each-line 30%', 'hanging each-line 30%', '30% each-line hanging');
75 e.style.textIndent = defaultValue;
76 invalidValueSettingTest('10m', defaultValue);
77 invalidValueSettingTest('100px 100px', defaultValue);
78 invalidValueSettingTest('100px line', defaultValue);
79 invalidValueSettingTest('100px hang', defaultValue);
80 invalidValueSettingTest('10m each-line', defaultValue);
81 invalidValueSettingTest('each-line 10m', defaultValue);
82 invalidValueSettingTest('10m hangning', defaultValue);
83 invalidValueSettingTest('hanging 10m', defaultValue);
84 invalidValueSettingTest('10m each-line hanging', defaultValue);
85 invalidValueSettingTest('each-line', defaultValue);
86 invalidValueSettingTest('hanging', defaultValue);
87 invalidValueSettingTest('each-line hanging', defaultValue);
88 invalidValueSettingTest('100px each-line 100px', defaultValue);
89 invalidValueSettingTest('100px hanging 100px', defaultValue);
90 invalidValueSettingTest('each-line 100px each-line', defaultValue);
91 invalidValueSettingTest('hanging 100px hanging', defaultValue);
92 invalidValueSettingTest('100px line hanging', defaultValue);
93 invalidValueSettingTest('100px each-line hang', defaultValue);