3 <script src=
"../../resources/js-test.js"></script>
7 src: url(../../resources/Ahem.ttf?font1);
12 src: url(../../resources/DownLoadErrorAhem.otf);
16 description('Tests load() method of FontFace.');
18 window
.jsTestIsAsync
= true;
20 function getDocumentFontFaces() {
22 document
.fonts
.forEach(function(face
) { faces
.push(face
); });
26 function fail(message
) {
33 function testStep1() {
34 var faces
= getDocumentFontFaces();
38 shouldBeEqualToString('face1.status', 'unloaded');
39 face1
.load().then(testStep2
, fail('face1.load() rejected'));
40 shouldBeEqualToString('face1.status', 'loading');
43 function testStep2() {
44 shouldBeEqualToString('face1.status', 'loaded');
46 shouldBeEqualToString('face2.status', 'unloaded');
47 face2
.load().then(fail('face2.load() fulfilled'), testStep3
);
48 shouldBeEqualToString('face2.status', 'loading');
51 function testStep3() {
52 shouldBeEqualToString('face2.status', 'error');
54 face3
= new FontFace('Font3', 'url(../../resources/Ahem.ttf?font3)', {});
55 shouldBeEqualToString('face3.status', 'unloaded');
57 shouldBeEqualToString('face3.status', 'loading');
58 face3
.loaded
.then(testStep4
, fail('face3.load() rejected'));
61 function testStep4() {
62 shouldBeEqualToString('face3.status', 'loaded');
64 face4
= new FontFace('Font4', 'url(../../resources/DownLoadErrorAhem.otf)', {});
65 shouldBeEqualToString('face4.status', 'unloaded');
67 shouldBeEqualToString('face4.status', 'loading');
68 face4
.loaded
.then(fail('face4.load() fulfilled'), testStep5
);
71 function testStep5() {
72 shouldBeEqualToString('face4.status', 'error');
74 face5
= new FontFace('Font5', 'url(data:font/truetype;base64,), url(../../resources/Ahem.ttf?font5)', {});
75 shouldBeEqualToString('face5.status', 'unloaded');
76 face5
.load().then(testStep6
, fail('face5.load() rejected'));
77 shouldBeEqualToString('face5.status', 'loading');
80 function testStep6() {
81 shouldBeEqualToString('face5.status', 'loaded');
88 testFailed('document.fonts does not exist');