blob: ac9aaf9b03b43fdb826dcfe5bdae748471396177 [file] [log] [blame]
<!DOCTYPE html>
<html>
<head>
<script src="../../resources/js-test-pre.js"></script>
<script>
if (window.testRunner)
testRunner.dumpAsText();
if (window.internals) {
internals.clearMemoryCache();
internals.invalidateFontCache();
}
</script>
<style>
@font-face {
font-family: WebFont;
src: url("../../resources/Ahem.ttf") format("truetype");
unicode-range: U+42;
}
@font-face {
font-family: WebFont;
src: url("../../resources/Ahem.otf") format("opentype");
unicode-range: U+41;
}
@font-face {
font-family: WebFont2;
src: url("../../resources/Ahem.otf") format("opentype");
unicode-range: U+41-42;
}
@font-face {
font-family: WebFont3;
src: url("notafont.ttf") format("truetype");
unicode-range: U+42;
}
@font-face {
font-family: WebFont3;
src: url("../../resources/Ahem.woff") format("woff");
unicode-range: U+41;
}
</style>
</head>
<body>
<script>
self.jsTestIsAsync = true;
description("This test makes sure that the second argument to FontFaceSet.load() and FontFaceSet.check() is honored.");
function failure() {
testFailed("Promise should not fail.");
finishJSTest();
}
var faces;
document.fonts.load("14px WebFont", "A").then(function(facesArgument) {
faces = facesArgument;
shouldBe("faces.length", "1");
shouldBeEqualToString("faces[0].unicodeRange", "U+41");
shouldBeTrue("document.fonts.check('14px WebFont', 'A')");
return document.fonts.load("14px WebFont, WebFont2", "A");
}, failure).then(function(facesArgument) {
faces = facesArgument;
shouldBe("faces.length", "1");
shouldBeEqualToString("faces[0].family", "WebFont");
shouldBeEqualToString("faces[0].unicodeRange", "U+41");
shouldBeFalse("document.fonts.check('14px WebFont3', 'A')");
for (let f of document.fonts) {
if (f.family == "WebFont3" && f.unicodeRange == "U+41")
return f.load();
}
testFailed("Should find font.");
finishJSTest();
}, failure).then(function(face) {
shouldBeTrue("document.fonts.check('14px WebFont3', 'A')");
finishJSTest();
}, failure);
</script>
<script src="../../resources/js-test-post.js"></script>
</body>
</html>