OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE html> |
| 2 <html> |
| 3 <style> |
| 4 * { font-size: 16px; } |
| 5 svg, rect, div { font-family: 'Ahem'; } |
| 6 </style> |
| 7 <html> |
| 8 <svg id="svg" width="0" height="0"></svg> |
| 9 <script src="../resources/js-test.js"></script> |
| 10 <script> |
| 11 description("Test ex unit with Ahem font"); |
| 12 |
| 13 function computedStyleDiv(property, value) { |
| 14 var div = document.createElement("div"); |
| 15 document.body.appendChild(div); |
| 16 div.style[property] = value; |
| 17 var computedValue = getComputedStyle(div).getPropertyValue(property); |
| 18 document.body.removeChild(div); |
| 19 return computedValue; |
| 20 } |
| 21 |
| 22 function computedStyleRect(property, value) { |
| 23 var rect = document.createElementNS('http://www.w3.org/2000/svg', 'rect'); |
| 24 document.getElementById("svg").appendChild(rect); |
| 25 rect.setAttribute(property, value); |
| 26 var computedValue = getComputedStyle(rect).getPropertyValue(property); |
| 27 document.getElementById("svg").removeChild(rect); |
| 28 return computedValue; |
| 29 } |
| 30 |
| 31 |
| 32 function testComputed(property, value, expected) { |
| 33 var tolerance = 0.05; |
| 34 shouldBeCloseTo('parseFloat(computedStyleDiv("' + property + '", "' + value
+ '"))', expected, tolerance); |
| 35 shouldBeCloseTo('parseFloat(computedStyleRect("' + property + '", "' + value
+ '"))', expected, tolerance); |
| 36 } |
| 37 |
| 38 testComputed("word-spacing", "1ex", 12.8); |
| 39 </script> |
| 40 </body> |
| 41 </html> |
OLD | NEW |