1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-06-01 08:28:11 +00:00
serenity/Tests/LibWeb/Text/input/WebAnimations/animation-properties/finished.html
2024-03-09 15:34:27 +01:00

34 lines
1.3 KiB
HTML

<!DOCTYPE html>
<div id="foo"></div>
<script src="../../include.js"></script>
<script>
asyncTest(async done => {
const foo = document.getElementById("foo");
let animation = foo.animate({ opacity: [0, 1] }, { duration: 100 });
let finishedPromise = animation.finished;
// FIXME: Figure out how to consistently test timings
// const currentTime = performance.now();
await finishedPromise;
// const elapsedTime = performance.now() - currentTime;
// if (elapsedTime > 95 && elapsedTime < 105)
// println("Animation time after 100ms is correct")
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
finishedPromise.then(() => {
println("Unexpected finished promise resolution");
}).catch(() => {
println("Expected finished promise cancellation");
});
animation.cancel();
println(`cancel() updates finished promise: ${!Object.is(finishedPromise, animation.finished)}`);
done();
});
</script>