OLD | NEW |
1 <html> | 1 <html> |
2 <head> | 2 <head> |
3 <script src="../js/resources/js-test-pre.js"></script> | 3 <script src="../js/resources/js-test-pre.js"></script> |
4 <style> | 4 <style> |
5 @font-face { | 5 @font-face { |
6 font-family: TestFont; | 6 font-family: TestFont; |
7 src: url(../../resources/Ahem.ttf); | 7 src: url(../../resources/Ahem.ttf); |
8 } | 8 } |
9 | 9 |
10 @font-face { | 10 @font-face { |
11 font-family: TestFont; | 11 font-family: TestFont; |
12 src: url('resources/DownLoadErrorAhem.otf'); | 12 src: url('resources/DownLoadErrorAhem.otf'); |
13 unicode-range: u+61-7a; /* 'a'-'z' */ | 13 unicode-range: u+61-7a; /* 'a'-'z' */ |
14 } | 14 } |
15 </style> | 15 </style> |
16 <script> | 16 <script> |
17 description('Test load events for a font family consists of multiple @font-faces
, including download error.'); | 17 description('Test load events for a font family consists of multiple @font-faces
, including download error.'); |
18 | 18 |
19 window.jsTestIsAsync = true; | 19 window.jsTestIsAsync = true; |
20 | 20 |
21 function runTests() { | 21 function runTests() { |
22 document.fonts.addEventListener('loading', onLoading); | 22 document.fonts.addEventListener('loading', onLoading); |
23 document.fonts.addEventListener('loadingdone', onLoadingDone); | 23 document.fonts.addEventListener('loadingdone', onLoadingDone); |
24 document.fonts.addEventListener('loadingerror', onLoadingError); | 24 document.fonts.addEventListener('loadingerror', onLoadingError); |
25 document.fonts.notifyWhenFontsReady(finish); | 25 document.fonts.ready().then(finish); |
26 | 26 |
27 document.fonts.loadFont({font: '10px TestFont'}); | 27 document.fonts.load('10px TestFont'); |
28 } | 28 } |
29 | 29 |
30 var event; | 30 var event; |
31 var firedEvents = []; | 31 var firedEvents = []; |
32 | 32 |
33 function onLoading(e) { | 33 function onLoading(e) { |
34 firedEvents.push(e.type); | 34 firedEvents.push(e.type); |
35 } | 35 } |
36 | 36 |
37 function onLoadingDone(e) { | 37 function onLoadingDone(e) { |
38 firedEvents.push(e.type); | 38 firedEvents.push(e.type); |
39 event = e; | 39 event = e; |
40 shouldBe("event.fontfaces.length", "1"); | 40 shouldBe("event.fontfaces.length", "1"); |
41 shouldBeEqualToString("event.fontfaces[0].unicodeRange", "U+0-10FFFF"); | 41 shouldBeEqualToString("event.fontfaces[0].unicodeRange", "U+0-10FFFF"); |
42 shouldBeEqualToString("event.fontfaces[0].status", "loaded"); | 42 shouldBeEqualToString("event.fontfaces[0].status", "loaded"); |
43 loadingdoneFired = true; | 43 loadingdoneFired = true; |
44 } | 44 } |
45 | 45 |
46 function onLoadingError(e) { | 46 function onLoadingError(e) { |
47 firedEvents.push(e.type); | 47 firedEvents.push(e.type); |
48 event = e; | 48 event = e; |
49 shouldBe("event.fontfaces.length", "1"); | 49 shouldBe("event.fontfaces.length", "1"); |
50 shouldBeEqualToString("event.fontfaces[0].unicodeRange", "U+61-7A"); | 50 shouldBeEqualToString("event.fontfaces[0].unicodeRange", "U+61-7A"); |
51 shouldBeEqualToString("event.fontfaces[0].status", "error"); | 51 shouldBeEqualToString("event.fontfaces[0].status", "error"); |
52 shouldBeFalse("document.fonts.checkFont('10px TestFont')"); | 52 shouldBeFalse("document.fonts.check('10px TestFont')"); |
53 } | 53 } |
54 | 54 |
55 function finish() { | 55 function finish() { |
56 shouldBe("firedEvents", "['loading', 'loadingdone', 'loadingerror']"); | 56 shouldBe("firedEvents", "['loading', 'loadingdone', 'loadingerror']"); |
57 finishJSTest(); | 57 finishJSTest(); |
58 } | 58 } |
59 | 59 |
60 if (document.fonts) | 60 if (document.fonts) |
61 runTests(); | 61 runTests(); |
62 else { | 62 else { |
63 testFailed('document.fonts does not exist'); | 63 testFailed('document.fonts does not exist'); |
64 finishJSTest(); | 64 finishJSTest(); |
65 } | 65 } |
66 </script> | 66 </script> |
67 </head> | 67 </head> |
68 <body> | 68 <body> |
69 <script src="../js/resources/js-test-post.js"></script> | 69 <script src="../js/resources/js-test-post.js"></script> |
70 </body> | 70 </body> |
71 </html> | 71 </html> |
OLD | NEW |