blob: 5960a59aaf02aad82aaf06453b68dba3c6c277c2 [file] [log] [blame]
<html>
<head>
<script src="../../resources/js-test-pre.js"></script>
<style>
@font-face {
font-family: TestFont;
src: url(../../resources/Ahem.ttf);
}
@font-face {
font-family: TestFont;
src: url('resources/DownLoadErrorAhem.otf');
unicode-range: u+61-7a; /* 'a'-'z' */
}
</style>
<script>
description('Test load events for a font family consists of multiple @font-faces, including download error.');
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 TestFont', onsuccess: onsuccess, onerror: onerror });
document.fonts.notifyWhenFontsReady(verify);
}
function onsuccess() {
testFailed("Expected error, but onsuccess() called");
onerror();
}
function onerror() {
}
function verify() {
shouldBe("events['loading']", "1");
shouldBe("events['loadstart']", "2");
shouldBe("events['load']", "1");
shouldBe("events['error']", "1");
shouldBe("events['loadingdone']", "1");
shouldBe("document.fonts.checkFont('10px TestFont')", "false");
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>