OLD | NEW |
1 <html> | 1 <html> |
2 <head> | 2 <head> |
3 <script src="../../resources/js-test.js"></script> | 3 <script src="../../resources/js-test.js"></script> |
4 <style> | 4 <style> |
5 @font-face { | 5 @font-face { |
6 font-family: 'ahem'; | 6 font-family: 'ahem'; |
7 src: url(../../resources/Ahem.ttf); | 7 src: url(../../resources/Ahem.ttf); |
8 } | 8 } |
9 </style> | 9 </style> |
10 <script> | 10 <script> |
11 description('Test that the event handlers of FontFaceSet are called in the corre
ct order.'); | 11 description('Test that the event handlers of FontFaceSet are called in the corre
ct order.'); |
12 | 12 |
13 window.jsTestIsAsync = true; | 13 window.jsTestIsAsync = true; |
14 | 14 |
15 var event; | 15 var event; |
16 var numberOfEvents = 0; | 16 var numberOfEvents = 0; |
17 | 17 |
18 function handleEvent(e) { | 18 function handleEvent(e) { |
19 event = e; | 19 event = e; |
20 shouldBeEqualToString('event.type', ['loading', 'loadingdone'][numberOfEvent
s]); | 20 shouldBeEqualToString('event.type', ['loading', 'loadingdone'][numberOfEvent
s]); |
21 numberOfEvents++; | 21 numberOfEvents++; |
22 } | 22 } |
23 | 23 |
24 function runTests() { | 24 function runTests() { |
25 document.fonts.onloading = handleEvent; | 25 document.fonts.onloading = handleEvent; |
26 document.fonts.onloadingdone = handleEvent; | 26 document.fonts.onloadingdone = handleEvent; |
27 document.fonts.onloadingerror = handleEvent; | 27 document.fonts.onloadingerror = handleEvent; |
28 | 28 |
29 document.fonts.ready().then(function() { | 29 document.fonts.ready.then(function() { |
30 shouldBe('numberOfEvents', '2'); | 30 shouldBe('numberOfEvents', '2'); |
31 finishJSTest(); | 31 finishJSTest(); |
32 }); | 32 }); |
33 } | 33 } |
34 | 34 |
35 if (document.fonts) | 35 if (document.fonts) |
36 runTests(); | 36 runTests(); |
37 else { | 37 else { |
38 testFailed('document.fonts does not exist'); | 38 testFailed('document.fonts does not exist'); |
39 finishJSTest(); | 39 finishJSTest(); |
40 } | 40 } |
41 </script> | 41 </script> |
42 </head> | 42 </head> |
43 <body> | 43 <body> |
44 <div style="font-family: ahem">Hello, world!</div> | 44 <div style="font-family: ahem">Hello, world!</div> |
45 </body> | 45 </body> |
46 </html> | 46 </html> |
OLD | NEW |