Move parseFontFaceDescriptor to CSSPropertyParser.cpp
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / css / fontface-methods.html
blob0c0fdcde7a18f7d6f40a9cdb62a0cf02c1135529
1 <html>
2 <head>
3 <script src="../../resources/js-test.js"></script>
4 <style>
5 @font-face {
6 font-family: Font1;
7 src: url(../../resources/Ahem.ttf?font1);
10 @font-face {
11 font-family: Font2;
12 src: url(../../resources/DownLoadErrorAhem.otf);
14 </style>
15 <script>
16 description('Tests load() method of FontFace.');
18 window.jsTestIsAsync = true;
20 function getDocumentFontFaces() {
21 var faces = [];
22 document.fonts.forEach(function(face) { faces.push(face); });
23 return faces;
26 function fail(message) {
27 return function() {
28 testFailed(message);
29 finishJSTest();
33 function testStep1() {
34 var faces = getDocumentFontFaces();
35 face1 = faces[0];
36 face2 = faces[1];
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');
56 face3.load();
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');
66 face4.load();
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');
82 finishJSTest();
85 if (document.fonts)
86 testStep1();
87 else
88 testFailed('document.fonts does not exist');
90 </script>
91 </head>
92 <body>
93 </body>
94 </html>