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 <script> | 4 <script> |
5 description('Tests that FontFaceSet is correctly updated when added or removed a
FontFace while loading.'); | 5 description('Tests that FontFaceSet is correctly updated when added or removed a
FontFace while loading.'); |
6 | 6 |
7 window.jsTestIsAsync = true; | 7 window.jsTestIsAsync = true; |
8 | 8 |
9 function testStep1() { | 9 function testStep1() { |
10 face1 = new FontFace('face1', 'url(../../resources/Ahem.ttf)', {}); | 10 face1 = new FontFace('face1', 'url(../../resources/Ahem.ttf)', {}); |
11 shouldBeEqualToString('face1.status', 'unloaded'); | 11 shouldBeEqualToString('face1.status', 'unloaded'); |
12 | 12 |
13 face1.load(); | 13 face1.load(); |
14 shouldBeEqualToString('face1.status', 'loading'); | 14 shouldBeEqualToString('face1.status', 'loading'); |
15 shouldBeEqualToString('document.fonts.status', 'loaded'); | 15 shouldBeEqualToString('document.fonts.status', 'loaded'); |
16 | 16 |
17 document.fonts.add(face1); | 17 document.fonts.add(face1); |
18 shouldBeEqualToString('document.fonts.status', 'loading'); | 18 shouldBeEqualToString('document.fonts.status', 'loading'); |
19 document.fonts.ready().then(testStep2); | 19 document.fonts.ready().then(testStep2); |
20 } | 20 } |
21 | 21 |
22 function testStep2() { | 22 function testStep2() { |
23 shouldBeEqualToString('face1.status', 'loaded'); | 23 shouldBeEqualToString('face1.status', 'loaded'); |
24 shouldBeEqualToString('document.fonts.status', 'loaded'); | 24 shouldBeEqualToString('document.fonts.status', 'loaded'); |
25 | 25 |
26 face2 = new FontFace('face2', 'url(../../resources/Ahem.ttf)', {}); | 26 face2 = new FontFace('face2', 'url(../../resources/Ahem.ttf)', {}); |
27 shouldBeEqualToString('face2.status', 'unloaded'); | 27 shouldBeEqualToString('face2.status', 'unloaded'); |
28 | 28 |
29 document.fonts.add(face2); | 29 document.fonts.add(face2); |
30 face2.load(); | 30 face2.load().then(testStep3); |
31 shouldBeEqualToString('document.fonts.status', 'loading'); | 31 shouldBeEqualToString('document.fonts.status', 'loading'); |
32 | 32 |
33 document.fonts.delete(face2); | 33 document.fonts.delete(face2); |
34 shouldBeEqualToString('document.fonts.status', 'loaded'); | 34 shouldBeEqualToString('document.fonts.status', 'loaded'); |
35 shouldBeEqualToString('face2.status', 'loading'); | 35 shouldBeEqualToString('face2.status', 'loading'); |
36 | |
37 face2.ready().then(testStep3); | |
38 } | 36 } |
39 | 37 |
40 function testStep3() { | 38 function testStep3() { |
41 shouldBeEqualToString('face2.status', 'loaded'); | 39 shouldBeEqualToString('face2.status', 'loaded'); |
42 shouldBeEqualToString('document.fonts.status', 'loaded'); | 40 shouldBeEqualToString('document.fonts.status', 'loaded'); |
43 | 41 |
44 face3 = new FontFace('face3', 'url(../../resources/Ahem.ttf)', {}); | 42 face3 = new FontFace('face3', 'url(../../resources/Ahem.ttf)', {}); |
45 shouldBeEqualToString('face3.status', 'unloaded'); | 43 shouldBeEqualToString('face3.status', 'unloaded'); |
46 | 44 |
47 document.fonts.add(face3); | 45 document.fonts.add(face3); |
(...skipping 10 matching lines...) Expand all Loading... |
58 if (document.fonts) | 56 if (document.fonts) |
59 testStep1(); | 57 testStep1(); |
60 else | 58 else |
61 testFailed('document.fonts does not exist'); | 59 testFailed('document.fonts does not exist'); |
62 | 60 |
63 </script> | 61 </script> |
64 </head> | 62 </head> |
65 <body> | 63 <body> |
66 </body> | 64 </body> |
67 </html> | 65 </html> |
OLD | NEW |