LibWeb: Add a test for Animation.reverse()

This commit is contained in:
Matthew Olsson 2024-03-28 15:29:55 +00:00 committed by Andreas Kling
commit c22055941a
Notes: sideshowbarker 2024-07-17 01:51:00 +09:00
2 changed files with 48 additions and 0 deletions

View file

@ -0,0 +1,4 @@
reverse() does not update the playback rate synchronously
reverse() updates the playback rate asynchronously
Cannot reverse an animation with an infinite effect end
reverse() does not update the playback rate if calling play() would throw an exception

View file

@ -0,0 +1,44 @@
<!DOCTYPE html>
<div id="foo"></div>
<script src="../../include.js"></script>
<script>
const animationFrame = () => {
const { promise, resolve } = Promise.withResolvers();
requestAnimationFrame(resolve);
return promise;
};
asyncTest(async done => {
const foo = document.getElementById("foo");
// FIXME: passing a null timeline here is broken, needs [ExplicitNull] support for dictionary members
// let anim = foo.animate({}, { timeline: null });
// try {
// anim.reverse();
// } catch {
// println("Cannot call reverse() on an animation with no timeline");
// }
anim = foo.animate({}, {});
anim.reverse();
if (anim.playbackRate === 1.0)
println("reverse() does not update the playback rate synchronously");
await animationFrame();
if (anim.playbackRate === -1.0)
println("reverse() updates the playback rate asynchronously");
anim = foo.animate({}, { duration: Infinity });
anim.cancel();
anim.playbackRate = -1;
try {
// anim.play() would throw here
anim.reverse();
} catch {
println("Cannot reverse an animation with an infinite effect end");
}
if (anim.playbackRate === -1)
println("reverse() does not update the playback rate if calling play() would throw an exception");
done();
});
</script>