blob: 7f71ed9d83479d5085d1d5091d5af26a33fcfaa5 [file] [log] [blame]
<!DOCTYPE html>
<html>
<head>
<script src="../../resources/js-test-pre.js"></script>
<style id="teststyle">
@font-face {
font-family: "WebFont";
src: url("../../resources/Ahem.ttf") format("truetype");
}
</style>
</head>
<body>
<div class="test">asdf</div>
<script>
if (window.internals) {
internals.clearMemoryCache();
internals.invalidateFontCache();
}
window.jsTestIsAsync = true;
description("This test makes sure that FontFace.load promises still fire when the src attribute of the @font-face rule changes during a load.");
function completeTest() {
finishJSTest();
}
var counter = 0;
document.fonts.keys().next().value.load().then(function() {
testPassed("Initial then-block should succeed");
++counter;
if (counter == 2)
completeTest();
}, function() {
testFailed("Initial then-block should not fail");
finishJSTest();
});
var testStyle = document.getElementById("teststyle");
testStyle.sheet.rules[0].style.fontFamily = "WebFont2";
testStyle.sheet.rules[0].style.src = "url('../../resources/Ahem.otf') format('opentype')";
var loadedFont;
document.fonts.keys().next().value.load().then(function(f) {
loadedFont = f;
shouldBeEqualToString("loadedFont.family", "WebFont2");
++counter;
if (counter == 2)
completeTest();
}, function() {
testFailed("Secondary then-block should not fail");
finishJSTest();
});
</script>
<script src="../../resources/js-test-post.js"></script>
</body>
</html>