Move parseFontFaceDescriptor to CSSPropertyParser.cpp
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / css / fontfaceset-download-error.html
blob5a8724686e1728ed402e43bfea8bd112526bdbfa
1 <html>
2 <head>
3 <script src="../../resources/js-test.js"></script>
4 <style>
5 /* Test 1: Invalid font data */
6 @font-face {
7 font-family: myfont1;
8 src: url('resources/invalidfont.png') format(opentype);
11 /* Test 2: Download error */
12 @font-face {
13 font-family: myfont2;
14 src: url('resources/DownLoadErrorAhem.otf');
17 /* Test 3: Empty data url */
18 @font-face {
19 font-family: myfont3;
20 src: url(data:application/x-truetype-font,) format(truetype);
23 /* Test 4: Download error followed by existing local font */
24 @font-face {
25 font-family: myfont4;
26 src: url('resources/DownLoadErrorAhem.otf'), local('Courier New');
29 /* Test 5: Multiple errors */
30 @font-face {
31 font-family: myfont5;
32 src: url('resources/DownLoadErrorAhem.otf'), url(data:application/x-truetype-font,) format(truetype);
34 </style>
35 <script>
36 description('Test download error cases.');
38 window.jsTestIsAsync = true;
40 function runTests() {
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(){});
47 });
48 document.fonts.ready.then(finish);
51 var event;
52 var firedEvents = [];
54 function onLoading(e) {
55 firedEvents.push(e.type);
58 function onLoadingDone(e) {
59 firedEvents.push(e.type);
60 event = e;
61 shouldBe('event.fontfaces.length', '1');
62 shouldBeEqualToString('event.fontfaces[0].family', 'myfont4');
65 function onLoadingError(e) {
66 firedEvents.push(e.type);
67 event = e;
68 shouldBe('event.fontfaces.length', '4');
69 failedFonts = e.fontfaces.map(function(face){return face.family;}).sort();
70 shouldBe('failedFonts', "['myfont1', 'myfont2', 'myfont3', 'myfont5']");
73 function finish() {
74 shouldBe("firedEvents", "['loading', 'loadingdone', 'loadingerror']");
75 finishJSTest();
78 if (document.fonts)
79 runTests();
80 else {
81 testFailed('document.fonts does not exist');
82 finishJSTest();
84 </script>
85 </head>
86 </html>