1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 11:07:45 +00:00

LibWeb: Add a few Animation property tests

This commit is contained in:
Matthew Olsson 2024-03-07 09:48:26 -07:00 committed by Alexander Kalenik
parent d76c2d45c4
commit d7ad134ae5
8 changed files with 110 additions and 0 deletions

View file

@ -0,0 +1,34 @@
<!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>