OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <script src="/js-test-resources/js-test.js"></script> | 2 <script src="/js-test-resources/js-test.js"></script> |
3 | 3 |
4 <div id="target">Hello webfont</div> | 4 <div id="target">Hello webfont</div> |
5 | 5 |
6 <script> | 6 <script> |
7 if (window.testRunner) | 7 jsTestIsAsync = true; |
8 testRunner.waitUntilDone(); | |
9 | 8 |
10 var waitMillisBeforeFetching = 300; | 9 var waitMillisBeforeFetching = 300; |
11 var entry; | 10 var entry; |
12 var fontFace = new FontFace('ahem', "url('../../../../misc/resources/acid3/font.
ttf')"); | 11 var fontFace = new FontFace('ahem', "url('../../../../misc/resources/acid3/font.
ttf')"); |
13 document.fonts.add(fontFace); | 12 document.fonts.add(fontFace); |
14 | 13 |
15 new Promise(function(resolve) { | 14 new Promise(function(resolve) { |
16 setTimeout(resolve, waitMillisBeforeFetching); | 15 setTimeout(resolve, waitMillisBeforeFetching); |
17 }).then(function() { | 16 }).then(function() { |
18 var target = document.getElementById('target'); | 17 var target = document.getElementById('target'); |
19 target.style['font-family'] = 'ahem'; | 18 target.style['font-family'] = 'ahem'; |
20 return fontFace.loaded; | 19 return fontFace.loaded; |
21 }).then(function() { | 20 }).then(function() { |
22 var name = document.location.origin + '/misc/resources/acid3/font.ttf'; | 21 var name = document.location.origin + '/misc/resources/acid3/font.ttf'; |
23 entry = window.performance.getEntriesByName(name)[0]; | 22 entry = window.performance.getEntriesByName(name)[0]; |
24 shouldBeTrue('entry.startTime >= waitMillisBeforeFetching'); | 23 shouldBeTrue('entry.startTime >= waitMillisBeforeFetching'); |
25 if (window.testRunner) | 24 finishJSTest(); |
26 testRunner.notifyDone(); | |
27 }); | 25 }); |
28 </script> | 26 </script> |
OLD | NEW |