OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE html> |
| 2 <html> |
| 3 <head> |
| 4 <title>Shape Outside Basic Shape Computed Font Relative Lengths</title> |
| 5 <link rel="author" title="Adobe" href="http://html.adobe.com/"> |
| 6 <link rel="author" title="Bear Travis" href="mailto:betravis@adobe.com"> |
| 7 <link rel="reviewer" title="Alan Stearns" href="mailto:stearns@adobe.com
"> <!-- 2014-03-04 --> |
| 8 <link rel="help" href="http://www.w3.org/TR/css-shapes-1/#shape-outside-
property"> |
| 9 <link rel="help" href="http://www.w3.org/TR/css-cascade-3/#computed"> |
| 10 <meta name="assert" content="The basic shape can contain relative length
formats, which resolve to the computed (absolute) length value"> |
| 11 <meta name="flags" content="dom"> |
| 12 <script src="../../../../../resources/testharness.js"></script> |
| 13 <script src="../../../../../resources/testharnessreport.js"></script> |
| 14 <script src="support/parsing-utils.js"></script> |
| 15 </head> |
| 16 <body> |
| 17 <div id="log"></div> |
| 18 <script type="text/javascript"> |
| 19 // font relative units: em, ex, ch, rem |
| 20 var units = ['em', 'ex', 'ch', 'rem']; |
| 21 var div = document.createElement('div'); |
| 22 document.body.appendChild(div); |
| 23 var resolveds = {}; |
| 24 units.forEach(function(unit) { |
| 25 div.style.width = '10' + unit; |
| 26 var s = getComputedStyle(div); |
| 27 resolveds[unit] = parseFloat(s.width); |
| 28 }); |
| 29 document.body.removeChild(div); |
| 30 |
| 31 function fillArray(string, length) { |
| 32 return Array.apply(null, new Array(length)).map(String.prototype
.valueOf, string); |
| 33 } |
| 34 |
| 35 function testUnit(unit) { |
| 36 var relativeLength = '1' + unit; |
| 37 var usedLength = resolveds[unit] + 'px'; |
| 38 |
| 39 var input = 'polygon(nonzero, ' + fillArray('10' + unit, 2).join
(' ') + ')'; |
| 40 var output = 'polygon(' + fillArray(resolveds[unit] + 'px', 2).j
oin(' ') + ')'; |
| 41 |
| 42 ParsingUtils.testComputedStyle(input, ParsingUtils.roundResultSt
r(output)); |
| 43 } |
| 44 |
| 45 var tests = units.map(function(unit) { |
| 46 return [unit + ' units', unit]; |
| 47 }); |
| 48 |
| 49 generate_tests(testUnit, tests); |
| 50 </script> |
| 51 </body> |
| 52 </html> |
OLD | NEW |