mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-29 12:49:05 +00:00
LibWeb: Add a test for Animation.pause()
This commit is contained in:
parent
074f5429a6
commit
7d8cf49b25
Notes:
sideshowbarker
2024-07-16 23:08:48 +09:00
Author: https://github.com/mattco98
Commit: 7d8cf49b25
Pull-request: https://github.com/SerenityOS/serenity/pull/23756
2 changed files with 59 additions and 0 deletions
|
@ -0,0 +1,6 @@
|
|||
Cannot pause a reversing idle animation with infinite effect end
|
||||
Calling pause() does not synchronously update pending playback rate
|
||||
Calling pause() does not synchronously resolve animation's ready promise
|
||||
Calling pause() does not send any events
|
||||
Calling pause() does asynchronously update pending playback rate
|
||||
Calling pause() asynchronously resolves animation's ready promise
|
|
@ -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>
|
Loading…
Add table
Add a link
Reference in a new issue