mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-30 11:37:16 +02:00
LibWeb: Add a test for Animation.pause()
This commit is contained in:
committed by
Andreas Kling
parent
074f5429a6
commit
7d8cf49b25
Notes:
sideshowbarker
2024-07-16 23:08:48 +09:00
Author: https://github.com/mattco98 Commit: https://github.com/SerenityOS/serenity/commit/7d8cf49b25 Pull-request: https://github.com/SerenityOS/serenity/pull/23756
@@ -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>
|
||||
Reference in New Issue
Block a user