<html>
<head>
<script src="../../resources/js-test.js"></script>
<style>
@font-face {
font-family: TestFont;
src: url('../../resources/DownLoadErrorAhem.ttf'), 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;
function runTests() {
document.fonts.addEventListener('loading', onLoading);
document.fonts.addEventListener('loadingdone', onLoadingDone);
document.fonts.addEventListener('loadingerror', onLoadingError);
document.fonts.ready.then(finish);
document.fonts.load('10px TestFont', 'abc').catch(function() {});
}
var event;
var firedEvents = [];
function onLoading(e) {
firedEvents.push(e.type);
}
function onLoadingDone(e) {
firedEvents.push(e.type);
event = e;
shouldBe("event.fontfaces.length", "1");
shouldBeEqualToString("event.fontfaces[0].unicodeRange", "U+0-10FFFF");
shouldBeEqualToString("event.fontfaces[0].status", "loaded");
loadingdoneFired = true;
}
function onLoadingError(e) {
firedEvents.push(e.type);
event = e;
shouldBe("event.fontfaces.length", "1");
shouldBeEqualToString("event.fontfaces[0].unicodeRange", "U+61-7A");
shouldBeEqualToString("event.fontfaces[0].status", "error");
shouldBeFalse("document.fonts.check('10px TestFont', 'abc')");
}
function finish() {
shouldBe("firedEvents", "['loading', 'loadingdone', 'loadingerror']");
finishJSTest();
}
if (document.fonts)
runTests();
else {
testFailed('document.fonts does not exist');
finishJSTest();
}
</script>
</head>
<body>
</body>
</html>