1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 20:07:36 +00:00

LibWeb: Add tests for the rest of the Animation properties

This commit is contained in:
Matthew Olsson 2024-03-08 08:47:49 -07:00 committed by Andreas Kling
parent e91f4dcd79
commit dc47210360
10 changed files with 164 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: 1000 });
println(`Animation's startTime is initially null: ${animation.startTime === null}`);
animation.startTime = 100;
println(`Animation's startTime is 100 after setting the value: ${animation.startTime === 100}`);
animation = foo.animate({ opacity: [0, 1] }, { duration: 1000 });
await animation.ready;
println(`Animation's startTime is non-null after ready promise resolved: ${animation.startTime !== null}`);
animation.cancel();
println(`Animation's startTime is null after calling cancel(): ${animation.startTime === null}`);
animation = foo.animate({ opacity: [0, 1] }, { duration: 1000 });
animation.pause();
animation.currentTime = 100;
println(`Animation's startTime is null after calling pause() and setting currentTime: ${animation.startTime === null}`);
animation = foo.animate({ opacity: [0, 1] }, { duration: 1000 });
animation.startTime = 100;
animation.playbackRate = -1;
println(`Animation's startTime updates after reversing playbackRate: ${animation.startTime > -150 && animation.startTime < -50}`);
animation = foo.animate({ opacity: [0, 1] }, { duration: 1000 });
animation.finish();
println(`Animation's startTime updates after calling finish(): ${animation.startTime > -1050 && animation.startTime < -950}`);
done();
});
</script>