LibWeb: Add a test for Animation.pause()

This commit is contained in:
Matthew Olsson
2024-03-28 14:23:53 +00:00
committed by Andreas Kling
parent 074f5429a6
commit 7d8cf49b25
Notes: sideshowbarker 2024-07-16 23:08:48 +09:00
2 changed files with 59 additions and 0 deletions

View File

@@ -0,0 +1,53 @@
<!DOCTYPE html>
<div id="foo"></div>
<script src="../../include.js"></script>
<script>
asyncTest(done => {
const foo = document.getElementById("foo");
let anim = foo.animate({}, { duration: Infinity });
anim.cancel();
anim.playbackRate = -1;
try {
anim.pause();
} catch {
println("Cannot pause a reversing idle animation with infinite effect end");
}
anim = foo.animate({}, {});
let events = {
remove: false,
finish: false,
cancel: false,
};
anim.onremove = () => { events.remove = true; };
anim.onfinish = () => { events.finish = true; };
anim.oncancel = () => { events.cancel = true; };
let readyResolved = false;
anim.ready.then(() => readyResolved = true);
anim.updatePlaybackRate(2.0);
anim.pause();
if (anim.playbackRate === 1.0)
println("Calling pause() does not synchronously update pending playback rate");
if (!readyResolved)
println("Calling pause() does not synchronously resolve animation's ready promise");
// Ensure we cross both a task boundary and an animation frame boundary
requestAnimationFrame(() => {
setTimeout(() => {
if (!events.remove && !events.finish && !events.cancel)
println("Calling pause() does not send any events");
if (anim.playbackRate === 2.0)
println("Calling pause() does asynchronously update pending playback rate");
if (readyResolved)
println("Calling pause() asynchronously resolves animation's ready promise");
done();
});
});
});
</script>