<!DOCTYPE html>
<html>
<head>
<script src="../../resources/js-test-pre.js"></script>
<style>
@font-face {
	font-family: "WebFont";
	src: url("../../resources/Ahem.ttf") format("truetype");
}
</style>
<style id="teststyle">
.test {
	font: 300px "WebFont";
}
</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 FontFaceSet.load promises still fire when the CSSFontSelector has been rebuilt during a load.");

document.fonts.load("300px 'WebFont'").then(function() {
	testPassed("Font loaded.");
	finishJSTest();
}, function() {
	testFailed("Font should load");
	finishJSTest();
});

var testStyle = document.getElementById("teststyle");
testStyle.media = "print";
</script>
<script src="../../resources/js-test-post.js"></script>
</body>
</html>