OLD | NEW |
---|---|
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <html> | 2 <html> |
3 <style> | 3 <style> |
4 * { font-size: 16px; } | 4 * { font-size: 16px; } |
5 svg, rect { font-family: 'Ahem'; } | 5 svg, rect { font-family: 'Ahem'; } |
6 div { font-size: 8px; } | 6 div { font-size: 8px; } |
7 </style> | 7 </style> |
8 <html> | 8 <html> |
9 <svg id="svg" width="0" height="0"></svg> | 9 <svg id="svg" width="0" height="0"></svg> |
10 <script src="../../resources/js-test.js"></script> | 10 <script src="../../resources/js-test.js"></script> |
11 <script> | 11 <script> |
12 description("Test that 'length' presentation attribute values are parsed with CS S presentation rules."); | 12 description("Test that 'length' presentation attribute values are parsed with CS S presentation rules."); |
13 | 13 |
14 function computedStyle(property, value) { | 14 function computedStyle(elementname, property, value) { |
15 var rect = document.createElementNS('http://www.w3.org/2000/svg', 'rect'); | 15 var elm = document.createElementNS('http://www.w3.org/2000/svg', elementname ); |
16 document.getElementById('svg').appendChild(rect); | 16 document.getElementById('svg').appendChild(elm); |
17 rect.setAttribute(property, value); | 17 elm.setAttribute(property, value); |
18 var computedValue = getComputedStyle(rect).getPropertyValue(property); | 18 var computedValue = getComputedStyle(elm).getPropertyValue(property); |
19 document.getElementById('svg').removeChild(rect); | 19 document.getElementById('svg').removeChild(elm); |
20 return computedValue; | 20 return computedValue; |
21 } | 21 } |
22 | 22 |
23 function testComputed(property, value, expected) { | 23 function testComputed(elementname, property, value, expected) { |
24 shouldBeEqualToString('computedStyle("' + property + '", "' + value + '")', expected); | 24 shouldBeEqualToString('computedStyle("' + elementname + '", "' + property + '", "' + value + '")', expected); |
25 } | 25 } |
26 | 26 |
27 function negativeTest(property, value) { | 27 function negativeTest(elementname, property, value) { |
28 testComputed(property, value, "auto"); | 28 testComputed(elementname, property, value, "auto"); |
29 } | 29 } |
30 | 30 |
31 function negativeTestZero(property, value) { | 31 function negativeTestZero(elementname, property, value) { |
32 testComputed(property, value, "0px"); | 32 testComputed(elementname, property, value, "0px"); |
33 } | 33 } |
34 | 34 |
35 // Test 'x'. | 35 var xyelements = [ "mask", "svg", "rect", "image", "foreignObject" ]; |
36 testComputed("x", " 100", "100px"); | 36 for (var i = 0; i < xyelements.length; i++) { |
fs
2015/03/09 12:34:33
for (var elmName of xyElements) {
? (same below)
Erik Dahlström (inactive)
2015/03/09 13:59:02
Done.
| |
37 testComputed("x", "100 ", "100px"); | 37 » var elm = xyelements[i]; |
fs
2015/03/09 12:34:33
Tabs vs. spaces.
Erik Dahlström (inactive)
2015/03/09 13:59:02
Done.
| |
38 testComputed("x", "100px", "100px"); | 38 » // Test 'x'. |
39 testComputed("x", "1em", "16px"); | 39 » testComputed(elm, "x", " 100", "100px"); |
40 // testComputed("x", "1ex", "12.8000001907349px"); // enable this again once htt p://crbug.com/441840 is fixed | 40 » testComputed(elm, "x", "100 ", "100px"); |
41 testComputed("x", "20%", "20%"); | 41 » testComputed(elm, "x", "100px", "100px"); |
42 testComputed("x", "-200px", "-200px"); | 42 » testComputed(elm, "x", "1em", "16px"); |
43 » // testComputed(elm, "x", "1ex", "12.8000001907349px"); // enable this a gain once http://crbug.com/441840 is fixed | |
44 » testComputed(elm, "x", "20%", "20%"); | |
45 » testComputed(elm, "x", "-200px", "-200px"); | |
43 | 46 |
44 // Test 'y'. | 47 » // Test 'y'. |
45 testComputed("y", " 100", "100px"); | 48 » testComputed(elm, "y", " 100", "100px"); |
46 testComputed("y", "100 ", "100px"); | 49 » testComputed(elm, "y", "100 ", "100px"); |
47 testComputed("y", "100px", "100px"); | 50 » testComputed(elm, "y", "100px", "100px"); |
48 testComputed("y", "1em", "16px"); | 51 » testComputed(elm, "y", "1em", "16px"); |
49 // testComputed("y", "1ex", "12.8000001907349px"); // enable this again once htt p://crbug.com/441840 is fixed | 52 » // testComputed(elm, "y", "1ex", "12.8000001907349px"); // enable this a gain once http://crbug.com/441840 is fixed |
50 testComputed("y", "20%", "20%"); | 53 » testComputed(elm, "y", "20%", "20%"); |
51 testComputed("y", "-200px", "-200px"); | 54 » testComputed(elm, "y", "-200px", "-200px"); |
52 | 55 |
53 // Negative tests for 'x'. | 56 » // Negative tests for 'x'. |
54 negativeTestZero("x", "auto", "auto"); | 57 » negativeTestZero(elm, "x", "auto", "auto"); |
55 negativeTestZero("x", "100 px"); | 58 » negativeTestZero(elm, "x", "100 px"); |
56 negativeTestZero("x", "100px;"); | 59 » negativeTestZero(elm, "x", "100px;"); |
57 negativeTestZero("x", "100px !important"); | 60 » negativeTestZero(elm, "x", "100px !important"); |
58 negativeTestZero("x", "{ 100px }"); | 61 » negativeTestZero(elm, "x", "{ 100px }"); |
59 | 62 |
60 // Negative tests for 'y'. | 63 » // Negative tests for 'y'. |
61 negativeTestZero("y", "auto"); | 64 » negativeTestZero(elm, "y", "auto"); |
62 negativeTestZero("y", "100 px"); | 65 » negativeTestZero(elm, "y", "100 px"); |
63 negativeTestZero("y", "100px;"); | 66 » negativeTestZero(elm, "y", "100px;"); |
64 negativeTestZero("y", "100px !important"); | 67 » negativeTestZero(elm, "y", "100px !important"); |
65 negativeTestZero("y", "{ 100px }"); | 68 » negativeTestZero(elm, "y", "{ 100px }"); |
69 } | |
66 | 70 |
67 // Test 'rx'. | 71 var rxryelements = [ "rect", "ellipse" ]; |
68 testComputed("rx", " 100", "100px"); | 72 for (var i = 0; i < rxryelements.length; i++) { |
69 testComputed("rx", "100 ", "100px"); | 73 » var elm = rxryelements[i]; |
70 testComputed("rx", "100px", "100px"); | 74 » // Test 'rx'. |
71 testComputed("rx", "1em", "16px"); | 75 » testComputed(elm, "rx", " 100", "100px"); |
72 // testComputed("rx", "1ex", "12.8000001907349px"); // enable this again once ht tp://crbug.com/441840 is fixed | 76 » testComputed(elm, "rx", "100 ", "100px"); |
73 testComputed("rx", "20%", "20%"); | 77 » testComputed(elm, "rx", "100px", "100px"); |
74 testComputed("rx", "-200px", "-200px"); | 78 » testComputed(elm, "rx", "1em", "16px"); |
79 » // testComputed(elm, "rx", "1ex", "12.8000001907349px"); // enable this again once http://crbug.com/441840 is fixed | |
80 » testComputed(elm, "rx", "20%", "20%"); | |
81 » testComputed(elm, "rx", "-200px", "-200px"); | |
75 | 82 |
76 // Test 'ry'. | 83 » // Test 'ry'. |
77 testComputed("ry", " 100", "100px"); | 84 » testComputed(elm, "ry", " 100", "100px"); |
78 testComputed("ry", "100 ", "100px"); | 85 » testComputed(elm, "ry", "100 ", "100px"); |
79 testComputed("ry", "100px", "100px"); | 86 » testComputed(elm, "ry", "100px", "100px"); |
80 testComputed("ry", "1em", "16px"); | 87 » testComputed(elm, "ry", "1em", "16px"); |
81 // testComputed("ry", "1ex", "12.8000001907349px"); // enable this again once ht tp://crbug.com/441840 is fixed | 88 » // testComputed(elm, "ry", "1ex", "12.8000001907349px"); // enable this again once http://crbug.com/441840 is fixed |
82 testComputed("ry", "20%", "20%"); | 89 » testComputed(elm, "ry", "20%", "20%"); |
83 testComputed("ry", "-200px", "-200px"); | 90 » testComputed(elm, "ry", "-200px", "-200px"); |
84 | 91 |
85 // Negative tests for 'rx'. | 92 » // Negative tests for 'rx'. |
86 negativeTestZero("rx", "auto", "auto"); | 93 » negativeTestZero(elm, "rx", "auto", "auto"); |
87 negativeTestZero("rx", "100 px"); | 94 » negativeTestZero(elm, "rx", "100 px"); |
88 negativeTestZero("rx", "100px;"); | 95 » negativeTestZero(elm, "rx", "100px;"); |
89 negativeTestZero("rx", "100px !important"); | 96 » negativeTestZero(elm, "rx", "100px !important"); |
90 negativeTestZero("rx", "{ 100px }"); | 97 » negativeTestZero(elm, "rx", "{ 100px }"); |
91 | 98 |
92 // Negative tests for 'ry'. | 99 » // Negative tests for 'ry'. |
93 negativeTestZero("ry", "auto"); | 100 » negativeTestZero(elm, "ry", "auto"); |
94 negativeTestZero("ry", "100 px"); | 101 » negativeTestZero(elm, "ry", "100 px"); |
95 negativeTestZero("ry", "100px;"); | 102 » negativeTestZero(elm, "ry", "100px;"); |
96 negativeTestZero("ry", "100px !important"); | 103 » negativeTestZero(elm, "ry", "100px !important"); |
97 negativeTestZero("ry", "{ 100px }"); | 104 » negativeTestZero(elm, "ry", "{ 100px }"); |
105 } | |
106 | |
107 // Test 'r'. | |
108 testComputed("circle", "r", " 100", "100px"); | |
fs
2015/03/09 12:34:33
Since we're pretty much repeating the same set of
Erik Dahlström (inactive)
2015/03/09 13:59:02
Done.
| |
109 testComputed("circle", "r", "100 ", "100px"); | |
110 testComputed("circle", "r", "100px", "100px"); | |
111 testComputed("circle", "r", "1em", "16px"); | |
112 // testComputed("circle", "r", "1ex", "12.8000001907349px"); // enable this agai n once http://crbug.com/441840 is fixed | |
113 testComputed("circle", "r", "20%", "20%"); | |
114 testComputed("circle", "r", "-200px", "-200px"); | |
115 | |
116 // Negative tests for 'r'. | |
117 negativeTestZero("circle", "r", "auto", "auto"); | |
118 negativeTestZero("circle", "r", "100 px"); | |
119 negativeTestZero("circle", "r", "100px;"); | |
120 negativeTestZero("circle", "r", "100px !important"); | |
121 negativeTestZero("circle", "r", "{ 100px }"); | |
98 </script> | 122 </script> |
99 </body> | 123 </body> |
100 </html> | 124 </html> |
OLD | NEW |