gecko-dev/layout/style/test/test_animations_async_tests.html
L. David Baron 7cff21024e Bug 1086937 patch 3 - Add test for animations continuing across a user font set update. r=birtles
I confirmed that without patch 2, the third and fourth tests fail
(reporting -1000px), whereas with the patches all 4 tests pass.
2014-11-12 23:28:52 -08:00

71 lines
2.1 KiB
HTML

<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>Test for Bug 1086937</title>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript" src="animation_utils.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
<style>
/* must use implicit value at one end */
@keyframes slide-left { from { margin-left: -1000px } }
</style>
<script type="application/javascript">
SimpleTest.waitForExplicitFinish();
var gDisplay;
function run() {
gDisplay = document.getElementById("display");
setTimeout(test1, 0);
}
/*
* Bug 1086937 - Animations continue correctly across load of
* downloadable font.
*/
function test1() {
var animdiv = document.createElement("div");
animdiv.style.animation = "slide-left 100s linear"; // 10px per second
gDisplay.appendChild(animdiv);
var cs = getComputedStyle(animdiv, "");
advance_clock(0);
is(cs.marginLeft, "-1000px", "initial value of animation (force flush)");
advance_clock(1000);
is(cs.marginLeft, "-990px", "value of animation before font load");
var font = new FontFace("DownloadedAhem", "url(Ahem.ttf)");
document.fonts.add(font);
var fontdiv = document.createElement("div");
fontdiv.appendChild(document.createTextNode("A"));
fontdiv.style.fontFamily = "DownloadedAhem";
gDisplay.appendChild(fontdiv);
font.load().then(function(loadedFace) {
is(cs.marginLeft, "-990px", "value of animation after font load " +
"(clock only advances when we say so)");
advance_clock(1000);
is(cs.marginLeft, "-980px",
"animation should still be advancing after font load");
SpecialPowers.DOMWindowUtils.restoreNormalRefresh();
document.fonts.delete(font);
animdiv.remove();
fontdiv.remove();
SimpleTest.finish();
});
}
</script>
</head>
<body onload="run()">
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1086937">Mozilla Bug 1086937</a>
<div id="display"></div>
<pre id="test">
</pre>
</body>
</html>