3 <script src=
"../../resources/js-test.js"></script>
5 /* Test
1: Invalid font data */
8 src: url('resources/invalidfont.png') format(opentype);
11 /* Test
2: Download error */
14 src: url('resources/DownLoadErrorAhem.otf');
17 /* Test
3: Empty data url */
20 src: url(data:application/x-truetype-font,) format(truetype);
23 /* Test
4: Download error followed by existing local font */
26 src: url('resources/DownLoadErrorAhem.otf'), local('Courier New');
29 /* Test
5: Multiple errors */
32 src: url('resources/DownLoadErrorAhem.otf'), url(data:application/x-truetype-font,) format(truetype);
36 description('Test download error cases.');
38 window
.jsTestIsAsync
= true;
41 document
.fonts
.addEventListener('loading', onLoading
);
42 document
.fonts
.addEventListener('loadingdone', onLoadingDone
);
43 document
.fonts
.addEventListener('loadingerror', onLoadingError
);
45 document
.fonts
.load('10px myfont1').catch(function() {
46 document
.fonts
.load('10px myfont2, myfont3, myfont4, myfont5').catch(function(){});
48 document
.fonts
.ready
.then(finish
);
54 function onLoading(e
) {
55 firedEvents
.push(e
.type
);
58 function onLoadingDone(e
) {
59 firedEvents
.push(e
.type
);
61 shouldBe('event.fontfaces.length', '1');
62 shouldBeEqualToString('event.fontfaces[0].family', 'myfont4');
65 function onLoadingError(e
) {
66 firedEvents
.push(e
.type
);
68 shouldBe('event.fontfaces.length', '4');
69 failedFonts
= e
.fontfaces
.map(function(face
){return face
.family
;}).sort();
70 shouldBe('failedFonts', "['myfont1', 'myfont2', 'myfont3', 'myfont5']");
74 shouldBe("firedEvents", "['loading', 'loadingdone', 'loadingerror']");
81 testFailed('document.fonts does not exist');