blob: 20e97ea13186da4e04c5baf15e49e0450cc07bef [file] [log] [blame]
<html>
<head>
<script src="../../resources/js-test-pre.js"></script>
<style>
@font-face {
font-family: TestFont1;
src: local('Courier New');
}
@font-face {
font-family: TestFont2;
src: url(../../resources/Ahem.ttf);
unicode-range: u+61-7a; /* 'a'-'z' */
}
</style>
<script>
description('Test load events for fontloader.loadFont() with multiple font families.');
window.jsTestIsAsync = true;
var events = {};
function countEvent(e) {
if (!events[e.type])
events[e.type] = 0;
events[e.type] += 1;
}
function runTests() {
document.fonts.addEventListener('loading', countEvent);
document.fonts.addEventListener('loadstart', countEvent);
document.fonts.addEventListener('load', countEvent);
document.fonts.addEventListener('error', countEvent);
document.fonts.addEventListener('loadingdone', countEvent);
document.fonts.loadFont({ font: '10px TestFont1, TestFont2', onsuccess: onsuccess, onerror: onerror });
document.fonts.notifyWhenFontsReady(verify);
}
function onsuccess() {
}
function onerror() {
testFailed("Expected success, but onerror() called");
}
function verify() {
shouldBe("events['loading']", "1");
shouldBe("events['loadstart']", "2");
shouldBe("events['load']", "2");
shouldBe("events['error']", "undefined");
shouldBe("events['loadingdone']", "1");
shouldBe("document.fonts.checkFont('10px TestFont1, TestFont2')", "true");
finishJSTest();
}
if (document.fonts)
runTests();
else {
testFailed('document.fonts does not exist');
finishJSTest();
}
</script>
</head>
<body>
<script src="../../resources/js-test-post.js"></script>
</body>
</html>