| OLD | NEW |
| 1 // This file is included by tests using Ahem font to ensure that the font is | 1 // This file is included by tests using Ahem font to ensure that the font is |
| 2 // loaded before window.onload fires and the test finishes. | 2 // loaded before window.onload fires and the test finishes. |
| 3 // Note: this doesn't work if the test doesn't contain any visible element with | 3 // Note: this doesn't work if the test doesn't contain any visible element with |
| 4 // 'font-family: Ahem' style. | 4 // 'font-family: Ahem' style. |
| 5 (function() { | 5 (function() { |
| 6 var scripts = document.getElementsByTagName('script'); | 6 var scripts = document.getElementsByTagName('script'); |
| 7 var scriptSrc = scripts[scripts.length - 1].src; | 7 var scriptSrc = scripts[scripts.length - 1].src; |
| 8 var relativePath = scriptSrc.substr(0, scriptSrc.lastIndexOf('/')); | 8 var relativePath = scriptSrc.substr(0, scriptSrc.lastIndexOf('/')); |
| 9 | 9 |
| 10 window.addEventListener('DOMContentLoaded', function() { | 10 window.addEventListener('DOMContentLoaded', function() { |
| 11 var style = document.createElement('style'); | 11 var style = document.createElement('style'); |
| 12 style.appendChild(document.createTextNode( | 12 style.appendChild(document.createTextNode( |
| 13 '@font-face { font-family: myahem; src: url(' + relativePath + '/Ahem.ttf'
)); | 13 '@font-face { font-family: Ahem; src: url(' + relativePath + '/Ahem.ttf);
}')); |
| 14 document.head.appendChild(style); | 14 document.head.appendChild(style); |
| 15 // Force a layout to start loading the font. | 15 // Force a layout to start loading the font. |
| 16 document.documentElement.offsetTop; | 16 document.documentElement.offsetTop; |
| 17 }, true); | 17 }, true); |
| 18 }()); | 18 }()); |
| OLD | NEW |