mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-26 17:55:07 +02:00
It is not guaranteed that an animation is ready to run a pending task when it is scheduled just because it has a timeline, and even if it is, the current time when scheduling will not necessarily still be correct when the task is run (e.g. if the timeline changes in the interim). We had some tests which relied on the previous behavior which have been updated to await the pending play task Fixes a crash in the /web-animations/interfaces/Animatable/animate-no-browsing-context.html WPT test but it can't be imported since it relies on a python web server to be running
34 lines
1.3 KiB
HTML
34 lines
1.3 KiB
HTML
<!DOCTYPE html>
|
|
<div id="foo"></div>
|
|
<script src="../../include.js"></script>
|
|
<script>
|
|
promiseTest(async () => {
|
|
const foo = document.getElementById("foo");
|
|
const timeline = internals.createInternalAnimationTimeline();
|
|
let animation = foo.animate({ opacity: [0, 1] }, { duration: 100, timeline });
|
|
await animationFrame();
|
|
let finishedPromise = animation.finished;
|
|
|
|
timeline.setTime(100);
|
|
|
|
// This should finish. If not, the test will time out and result in a failure
|
|
await finishedPromise;
|
|
|
|
println(`finished promise remains after finishing: ${Object.is(finishedPromise, animation.finished)}`);
|
|
|
|
animation.play();
|
|
println(`finished promise updates after playing: ${!Object.is(finishedPromise, animation.finished)}`);
|
|
finishedPromise = animation.finished;
|
|
|
|
// Upon cancellation, the finished promise should be rejected
|
|
animation.cancel();
|
|
println(`cancel() updates finished promise: ${!Object.is(finishedPromise, animation.finished)}`);
|
|
try {
|
|
await finishedPromise;
|
|
println("Unexpected finished promise resolution");
|
|
} catch {
|
|
println("Expected finished promise cancellation");
|
|
}
|
|
});
|
|
</script>
|