mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-12 20:42:21 +00:00
LibWeb: Add a test for Animation.reverse()
This commit is contained in:
parent
83d3defc11
commit
c22055941a
Notes:
sideshowbarker
2024-07-17 01:51:00 +09:00
Author: https://github.com/mattco98
Commit: c22055941a
Pull-request: https://github.com/SerenityOS/serenity/pull/23756
2 changed files with 48 additions and 0 deletions
|
@ -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
|
|
@ -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>
|
Loading…
Add table
Add a link
Reference in a new issue