Move parseFontFaceDescriptor to CSSPropertyParser.cpp
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / css / fontfaceset-multiple-families.html
blobbd4358fef230fa8affea547e665268be75c5e90a
1 <html>
2 <head>
3 <script src="../../resources/js-test.js"></script>
4 <style>
5 @font-face {
6 font-family: TestFont1;
7 src: local('Courier New');
10 @font-face {
11 font-family: TestFont2;
12 src: url(../../resources/Ahem.ttf);
13 unicode-range: u+61-7a; /* 'a'-'z' */
16 @font-face {
17 font-family: TestFont3;
18 src: url(data:application/x-truetype-font,) format(truetype);
21 @font-face {
22 font-family: TestFont4;
23 src: url(data:application/xml,) format(svg);
25 </style>
26 <script>
27 description('Test load events for fonts.loadFont() with multiple font families.');
29 window.jsTestIsAsync = true;
31 function runTests() {
32 document.fonts.addEventListener('loading', onLoading);
33 document.fonts.addEventListener('loadingdone', onLoadingDone);
34 document.fonts.addEventListener('loadingerror', onLoadingError);
35 document.fonts.ready.then(finish);
37 document.fonts.load('10px TestFont1, TestFont2, TestFont3, TestFont4', 'abc').catch(function() {});
40 var event;
41 var firedEvents = [];
43 function onLoading(e) {
44 firedEvents.push(e.type);
47 function onLoadingDone(e) {
48 firedEvents.push(e.type);
49 event = e;
50 shouldBe("event.fontfaces.length", "2");
51 shouldBeEqualToString("event.fontfaces[0].status", "loaded");
52 shouldBeEqualToString("event.fontfaces[1].status", "loaded");
53 loadedFonts = e.fontfaces.map(function(face){return face.family;}).sort();
54 shouldBe('loadedFonts', "['TestFont1', 'TestFont2']");
55 shouldBeTrue("document.fonts.check('10px TestFont1')");
56 shouldBeTrue("document.fonts.check('10px TestFont2')");
57 shouldBeTrue("document.fonts.check('10px TestFont1, TestFont2')");
58 shouldBeTrue("document.fonts.check('10px Times')");
59 shouldBeTrue("document.fonts.check('10px TestFont1, Times')");
62 function onLoadingError(e) {
63 firedEvents.push(e.type);
64 event = e;
65 shouldBe("event.fontfaces.length", "2");
66 shouldBeEqualToString("event.fontfaces[0].status", "error");
67 shouldBeEqualToString("event.fontfaces[1].status", "error");
68 failedFonts = e.fontfaces.map(function(face){return face.family;}).sort();
69 shouldBe('failedFonts', "['TestFont3', 'TestFont4']");
70 shouldBeFalse("document.fonts.check('10px TestFont3')");
71 shouldBeFalse("document.fonts.check('10px TestFont4')");
72 shouldBeFalse("document.fonts.check('10px TestFont4, Times')");
75 function finish() {
76 shouldBe("firedEvents", "['loading', 'loadingdone', 'loadingerror']");
77 finishJSTest();
80 if (document.fonts)
81 runTests();
82 else {
83 testFailed('document.fonts does not exist');
84 finishJSTest();
86 </script>
87 </head>
88 <body>
89 </body>
90 </html>