Regression(r188105): Seems to have caused crashes during PLT on some iPads
[WebKit-https.git] / LayoutTests / fast / css / fontloader-multiple-faces.html
1 <html>
2 <head>
3 <script src="../../resources/js-test-pre.js"></script>
4 <style>
5 @font-face {
6     font-family: TestFont;
7     src: local('Courier New');
8 }
9
10 @font-face {
11     font-family: TestFont;
12     src: url(../../resources/Ahem.ttf);
13     unicode-range: u+61-7a; /* 'a'-'z' */
14 }
15 </style>
16 <script>
17 description('Test load events for a font family consists of multiple @font-faces.');
18
19 window.jsTestIsAsync = true;
20
21 var events = {};
22
23 function countEvent(e) {
24     if (!events[e.type])
25         events[e.type] = 0;
26     events[e.type] += 1;
27 }
28
29 function runTests() {
30     document.fonts.addEventListener('loading', countEvent);
31     document.fonts.addEventListener('loadstart', countEvent);
32     document.fonts.addEventListener('load', countEvent);
33     document.fonts.addEventListener('error', countEvent);
34     document.fonts.addEventListener('loadingdone', countEvent);
35
36     document.fonts.loadFont({ font: '10px TestFont', onsuccess: onsuccess, onerror: onerror });
37     document.fonts.notifyWhenFontsReady(verify);
38 }
39
40 function onsuccess() {
41 }
42
43 function onerror() {
44     testFailed("Expected success, but onerror() called");
45     onsuccess();
46 }
47
48 function verify() {
49     shouldBe("events['loading']", "1");
50     shouldBe("events['loadstart']", "2");
51     shouldBe("events['load']", "2");
52     shouldBe("events['error']", "undefined");
53     shouldBe("events['loadingdone']", "1");
54     shouldBe("document.fonts.checkFont('10px TestFont')", "true");
55     finishJSTest();
56 }
57
58 if (document.fonts)
59     runTests();
60 else {
61     testFailed('document.fonts does not exist');
62     finishJSTest();
63 }
64 </script>
65 </head>
66 <body>
67   <script src="../../resources/js-test-post.js"></script>
68 </body>
69 </html>