LibWeb: Add a test for Animation.play()

This commit is contained in:
Matthew Olsson 2024-03-27 19:42:23 -07:00 committed by Andreas Kling
parent 7472536ecb
commit 074f5429a6
Notes: sideshowbarker 2024-07-17 06:54:15 +09:00
2 changed files with 39 additions and 0 deletions

View file

@ -0,0 +1,4 @@
Cannot rewind an animation with an infinite effect end
play() leaves animation's startTime unresolved: true
play() does not recreate the animation's ready promise
play() does not synchronously resolve the ready promise

View file

@ -0,0 +1,35 @@
<!DOCTYPE html>
<div id="foo"></div>
<script src="../../include.js"></script>
<script>
test(() => {
const foo = document.getElementById("foo");
let anim = foo.animate({}, { duration: Infinity });
anim.cancel();
anim.playbackRate = -1;
try {
anim.play();
} catch {
println("Cannot rewind an animation with an infinite effect end")
}
anim = foo.animate({}, {});
anim.play();
println(`play() leaves animation's startTime unresolved: ${anim.startTime === null}`);
anim = foo.animate({}, {});
let oldPromise = anim.ready;
anim.play();
if (Object.is(oldPromise, anim.ready))
println("play() does not recreate the animation's ready promise");
anim = foo.animate({}, {});
anim.play();
anim.ready.catch(() => {
println("play() does not synchronously resolve the ready promise");
});
anim.cancel();
});
</script>