mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-21 16:58:58 +00:00
LibWeb: Add a test for Animation.updatePlaybackRate()
This commit is contained in:
parent
7d8cf49b25
commit
83d3defc11
Notes:
sideshowbarker
2024-07-17 00:37:23 +09:00
Author: https://github.com/mattco98
Commit: 83d3defc11
Pull-request: https://github.com/SerenityOS/serenity/pull/23756
2 changed files with 53 additions and 0 deletions
|
@ -0,0 +1,4 @@
|
||||||
|
updatePlaybackRate() updates an idle animation's playback rate immediately
|
||||||
|
updatePlaybackRate() updates a running animation's playback rate after an animation frame
|
||||||
|
updatePlaybackRate() updates a paused animation's playback rate after an animation frame
|
||||||
|
updatePlaybackRate() updates a finished animation's playback rate after an animation frame
|
|
@ -0,0 +1,49 @@
|
||||||
|
<!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");
|
||||||
|
|
||||||
|
let anim = foo.animate({}, { duration: Infinity });
|
||||||
|
anim.pause();
|
||||||
|
anim.updatePlaybackRate(2.0);
|
||||||
|
await animationFrame();
|
||||||
|
if (anim.playbackRate !== 2.0)
|
||||||
|
println("updatePlaybackRate() does nothing if the animation is pending");
|
||||||
|
|
||||||
|
anim = foo.animate({}, {});
|
||||||
|
anim.cancel();
|
||||||
|
anim.updatePlaybackRate(2.0);
|
||||||
|
if (anim.playbackRate === 2.0)
|
||||||
|
println("updatePlaybackRate() updates an idle animation's playback rate immediately");
|
||||||
|
|
||||||
|
anim = foo.animate({}, {});
|
||||||
|
await animationFrame();
|
||||||
|
anim.updatePlaybackRate(2.0);
|
||||||
|
if (anim.playbackRate === 2.0)
|
||||||
|
println("updatePlaybackRate() updates a running animation's playback rate after an animation frame");
|
||||||
|
|
||||||
|
anim = foo.animate({}, {});
|
||||||
|
anim.pause();
|
||||||
|
await animationFrame();
|
||||||
|
anim.updatePlaybackRate(2.0);
|
||||||
|
if (anim.playbackRate === 2.0)
|
||||||
|
println("updatePlaybackRate() updates a paused animation's playback rate after an animation frame");
|
||||||
|
|
||||||
|
anim = foo.animate({}, {});
|
||||||
|
anim.finish();
|
||||||
|
await animationFrame();
|
||||||
|
anim.updatePlaybackRate(2.0);
|
||||||
|
if (anim.playbackRate === 2.0)
|
||||||
|
println("updatePlaybackRate() updates a finished animation's playback rate after an animation frame");
|
||||||
|
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
</script>
|
Loading…
Add table
Add a link
Reference in a new issue