OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE html> |
| 2 <html> |
| 3 <style> |
| 4 * { font-size: 16px; } |
| 5 svg, rect { font-family: 'Ahem'; } |
| 6 div { font-size: 8px; } |
| 7 </style> |
| 8 <html> |
| 9 <svg id="svg" width="0" height="0"></svg> |
| 10 <script src="../../resources/js-test.js"></script> |
| 11 <script> |
| 12 description("Test that 'length' presentation attribute values are parsed with CS
S presentation rules."); |
| 13 |
| 14 function computedStyle(property, value) { |
| 15 var rect = document.createElementNS('http://www.w3.org/2000/svg', 'rect'); |
| 16 document.getElementById('svg').appendChild(rect); |
| 17 rect.setAttribute(property, value); |
| 18 var computedValue = getComputedStyle(rect).getPropertyValue(property); |
| 19 document.getElementById('svg').removeChild(rect); |
| 20 return computedValue; |
| 21 } |
| 22 |
| 23 function testComputed(property, value, expected) { |
| 24 shouldBeEqualToString('computedStyle("' + property + '", "' + value + '")',
expected); |
| 25 } |
| 26 |
| 27 function negativeTest(property, value) { |
| 28 testComputed(property, value, "auto"); |
| 29 } |
| 30 |
| 31 function negativeTestZero(property, value) { |
| 32 testComputed(property, value, "0px"); |
| 33 } |
| 34 |
| 35 // Test 'x'. |
| 36 testComputed("x", " 100", "100px"); |
| 37 testComputed("x", "100 ", "100px"); |
| 38 testComputed("x", "100px", "100px"); |
| 39 testComputed("x", "1em", "16px"); |
| 40 // testComputed("x", "1ex", "12.8000001907349px"); // enable this again once htt
p://crbug.com/441840 is fixed |
| 41 testComputed("x", "20%", "20%"); |
| 42 testComputed("x", "-200px", "-200px"); |
| 43 |
| 44 // Test 'y'. |
| 45 testComputed("y", " 100", "100px"); |
| 46 testComputed("y", "100 ", "100px"); |
| 47 testComputed("y", "100px", "100px"); |
| 48 testComputed("y", "1em", "16px"); |
| 49 // testComputed("y", "1ex", "12.8000001907349px"); // enable this again once htt
p://crbug.com/441840 is fixed |
| 50 testComputed("y", "20%", "20%"); |
| 51 testComputed("y", "-200px", "-200px"); |
| 52 |
| 53 // Negative tests for 'x'. |
| 54 negativeTestZero("x", "auto", "auto"); |
| 55 negativeTestZero("x", "100 px"); |
| 56 negativeTestZero("x", "100px;"); |
| 57 negativeTestZero("x", "100px !important"); |
| 58 negativeTestZero("x", "{ 100px }"); |
| 59 |
| 60 // Negative tests for 'y'. |
| 61 negativeTestZero("y", "auto"); |
| 62 negativeTestZero("y", "100 px"); |
| 63 negativeTestZero("y", "100px;"); |
| 64 negativeTestZero("y", "100px !important"); |
| 65 negativeTestZero("y", "{ 100px }"); |
| 66 </script> |
| 67 </body> |
| 68 </html> |
OLD | NEW |