Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(234)

Side by Side Diff: LayoutTests/fast/css/fontface-methods.html

Issue 184633005: [CSS Font Loading] Remove FontFace#ready, fold its functionality into FontFace#load (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: rebase Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 <style> 4 <style>
5 @font-face { 5 @font-face {
6 font-family: Font1; 6 font-family: Font1;
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: Font2; 11 font-family: Font2;
12 src: url(../../resources/DownLoadErrorAhem.otf); 12 src: url(../../resources/DownLoadErrorAhem.otf);
13 } 13 }
14 </style> 14 </style>
15 <script> 15 <script>
16 description('Tests load() and ready() methods of FontFace.'); 16 description('Tests load() method of FontFace.');
17 17
18 window.jsTestIsAsync = true; 18 window.jsTestIsAsync = true;
19 19
20 function getDocumentFontFaces() { 20 function getDocumentFontFaces() {
21 var faces = []; 21 var faces = [];
22 document.fonts.forEach(function(face) { faces.push(face); }); 22 document.fonts.forEach(function(face) { faces.push(face); });
23 return faces; 23 return faces;
24 } 24 }
25 25
26 function fail(message) { 26 function fail(message) {
27 return function() { 27 return function() {
28 testFailed(message); 28 testFailed(message);
29 finishJSTest(); 29 finishJSTest();
30 }; 30 };
31 } 31 }
32 32
33 function testStep1() { 33 function testStep1() {
34 var faces = getDocumentFontFaces(); 34 var faces = getDocumentFontFaces();
35 face1 = faces[0]; 35 face1 = faces[0];
36 face2 = faces[1]; 36 face2 = faces[1];
37 37
38 face1.ready().then(testStep2, fail('face1.ready() rejected'));
39 shouldBeEqualToString('face1.status', 'unloaded'); 38 shouldBeEqualToString('face1.status', 'unloaded');
40 face1.load(); 39 face1.load().then(testStep2, fail('face1.load() rejected'));
41 shouldBeEqualToString('face1.status', 'loading'); 40 shouldBeEqualToString('face1.status', 'loading');
42 } 41 }
43 42
44 function testStep2() { 43 function testStep2() {
45 shouldBeEqualToString('face1.status', 'loaded'); 44 shouldBeEqualToString('face1.status', 'loaded');
46 45
47 face2.ready().then(fail('face2.ready() fulfilled'), testStep3);
48 shouldBeEqualToString('face2.status', 'unloaded'); 46 shouldBeEqualToString('face2.status', 'unloaded');
49 face2.load(); 47 face2.load().then(fail('face2.load() fulfilled'), testStep3);
50 shouldBeEqualToString('face2.status', 'loading'); 48 shouldBeEqualToString('face2.status', 'loading');
51 } 49 }
52 50
53 function testStep3() { 51 function testStep3() {
54 shouldBeEqualToString('face2.status', 'error'); 52 shouldBeEqualToString('face2.status', 'error');
55 53
56 face3 = new FontFace('Font3', 'url(../../resources/Ahem.ttf)', {}); 54 face3 = new FontFace('Font3', 'url(../../resources/Ahem.ttf)', {});
57 face3.ready().then(testStep4, fail('face3.ready() rejected'));
58 shouldBeEqualToString('face3.status', 'unloaded'); 55 shouldBeEqualToString('face3.status', 'unloaded');
59 face3.load(); 56 face3.load().then(testStep4, fail('face3.load() rejected'));
60 shouldBeEqualToString('face3.status', 'loading'); 57 shouldBeEqualToString('face3.status', 'loading');
61 } 58 }
62 59
63 function testStep4() { 60 function testStep4() {
64 shouldBeEqualToString('face3.status', 'loaded'); 61 shouldBeEqualToString('face3.status', 'loaded');
65 62
66 face4 = new FontFace('Font4', 'url(../../resources/DownLoadErrorAhem.otf)', {}); 63 face4 = new FontFace('Font4', 'url(../../resources/DownLoadErrorAhem.otf)', {});
67 face4.ready().then(fail('face4.ready() fulfilled'), testStep5);
68 shouldBeEqualToString('face4.status', 'unloaded'); 64 shouldBeEqualToString('face4.status', 'unloaded');
69 face4.load(); 65 face4.load().then(fail('face4.load() fulfilled'), testStep5);
70 shouldBeEqualToString('face4.status', 'loading'); 66 shouldBeEqualToString('face4.status', 'loading');
71 } 67 }
72 68
73 function testStep5() { 69 function testStep5() {
74 shouldBeEqualToString('face4.status', 'error'); 70 shouldBeEqualToString('face4.status', 'error');
75 finishJSTest(); 71 finishJSTest();
76 } 72 }
77 73
78 if (document.fonts) 74 if (document.fonts)
79 testStep1(); 75 testStep1();
80 else 76 else
81 testFailed('document.fonts does not exist'); 77 testFailed('document.fonts does not exist');
82 78
83 </script> 79 </script>
84 </head> 80 </head>
85 <body> 81 <body>
86 </body> 82 </body>
87 </html> 83 </html>
OLDNEW
« no previous file with comments | « LayoutTests/fast/css/fontface-arraybuffer.html ('k') | LayoutTests/fast/css/fontface-methods-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698