blob: 61b8ffb73e6a32304d8d1a65583cf5ba80100397 [file] [log] [blame]
<html>
<head>
<script src="../../resources/js-test-pre.js"></script>
<style>
@font-face {
font-family: 'ahem';
src: url(../../resources/Ahem.ttf);
}
</style>
<script>
description('Test that the event handlers of FontLoader are called in the correct order.');
window.jsTestIsAsync = true;
var event;
var numberOfEvents = 0;
function handleEvent(e) {
event = e;
shouldBeEqualToString('event.type', ['loading', 'loadstart', 'load', 'loadingdone'][numberOfEvents]);
numberOfEvents++;
}
function runTests() {
document.fontloader.onloading = handleEvent;
document.fontloader.onloadingdone = handleEvent;
document.fontloader.onloadstart = handleEvent;
document.fontloader.onload = handleEvent;
document.fontloader.onerror = handleEvent;
document.fontloader.notifyWhenFontsReady(function() {
shouldBe('numberOfEvents', '4');
finishJSTest();
});
}
if (document.fontloader)
runTests();
else {
testFailed('document.fontloader does not exist');
finishJSTest();
}
</script>
</head>
<body>
<div style="font-family: ahem">Hello, world!</div>
<script src="../../resources/js-test-post.js"></script>
</body>
</html>