Regression(r188105): Seems to have caused crashes during PLT on some iPads
[WebKit-https.git] / LayoutTests / fast / css / fontloader-events.html
1 <html>
2 <head>
3 <script src="../../resources/js-test-pre.js"></script>
4 <style>
5 @font-face {
6   font-family: 'ahem';
7   src: url(../../resources/Ahem.ttf);
8 }
9 </style>
10 <script>
11 description('Test that the event handlers of FontLoader are called in the correct order.');
12
13 window.jsTestIsAsync = true;
14
15 var event;
16 var numberOfEvents = 0;
17
18 function handleEvent(e) {
19     event = e;
20     shouldBeEqualToString('event.type', ['loading', 'loadstart', 'load', 'loadingdone'][numberOfEvents]);
21     numberOfEvents++;
22 }
23
24 function runTests() {
25     document.fonts.onloading = handleEvent;
26     document.fonts.onloadingdone = handleEvent;
27     document.fonts.onloadstart = handleEvent;
28     document.fonts.onload = handleEvent;
29     document.fonts.onerror = handleEvent;
30
31     document.fonts.notifyWhenFontsReady(function() {
32         shouldBe('numberOfEvents', '4');
33         finishJSTest();
34     });
35 }
36
37 if (document.fonts)
38     runTests();
39 else {
40     testFailed('document.fonts does not exist');
41     finishJSTest();
42 }
43 </script>
44 </head>
45 <body>
46   <div style="font-family: ahem">Hello, world!</div>
47   <script src="../../resources/js-test-post.js"></script>
48 </body>
49 </html>