gecko-dev/layout/style/test/test_animations_pausing.html

88 lines
2.8 KiB
HTML

<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=1070745
-->
<head>
<title>Test for play() and pause() on animations (Bug 1070745)</title>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript"
src="/tests/SimpleTest/paint_listener.js"></script>
<script type="application/javascript" src="animation_utils.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
<style type="text/css">
@keyframes anim {
0% { transform: translate(0px) }
100% { transform: translate(100px) }
}
.target {
/* The animation target needs geometry in order to qualify for OMTA */
width: 100px;
height: 100px;
background-color: white;
}
</style>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1070745">Mozilla Bug 1070745</a>
<div id="display"></div>
<pre id="test">
<script type="application/javascript">
"use strict";
SimpleTest.waitForExplicitFinish();
runOMTATest(function() {
runAllAsyncAnimTests().then(function() {
SimpleTest.finish();
});
}, SimpleTest.finish);
addAsyncAnimTest(function *() {
var [ div, cs ] = new_div("animation: anim 10s 2 linear alternate");
// Animation is initially running on compositor
yield waitForPaintsFlushed();
advance_clock(1000);
omta_is(div, "transform", { tx: 10 }, RunningOn.Compositor,
"Animation is initally animating on compositor");
// pause() means it is no longer on the compositor
var player = div.getAnimationPlayers()[0];
player.pause();
// pause() should set up the changes to animations for the next layer
// transaction but it won't schedule a paint immediately so we need to tick
// the refresh driver before we can wait on the next paint.
advance_clock(0);
yield waitForPaints();
omta_is(div, "transform", { tx: 10 }, RunningOn.MainThread,
"After pausing, animation is removed from compositor");
// Animation remains paused
advance_clock(1000);
omta_is(div, "transform", { tx: 10 }, RunningOn.MainThread,
"Animation remains paused");
// play() puts the animation back on the compositor
player.play();
// As with pause(), play() will set up pending animations for the next layer
// transaction but won't schedule a paint so we need to tick the refresh
// driver before waiting on the next paint.
advance_clock(0);
yield waitForPaints();
omta_is(div, "transform", { tx: 10 }, RunningOn.Compositor,
"After playing, animation is sent to compositor");
// Where it continues to run
advance_clock(1000);
omta_is(div, "transform", { tx: 20 }, RunningOn.Compositor,
"Animation continues playing on compositor");
done_div();
});
</script>
</pre>
</body>
</html>