1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 19:37:36 +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,29 @@
<!DOCTYPE html>
<div id="foo"></div>
<script src="../../include.js"></script>
<script>
asyncTest(done => {
const foo = document.getElementById("foo");
let animation = new Animation(null, null);
println(`Animation with no timeline has null currentTime: ${animation.currentTime === null}`);
animation = new Animation(new KeyframeEffect(foo, []));
println(`Animation that hasn't been played has null currentTime: ${animation.currentTime === null}`);
animation = foo.animate({ color: "red" }, { duration: 1000 });
println(`Played animation has a currentTime of 0: ${animation.currentTime === 0}`);
setTimeout(() => {
// FIXME: Figure out how to consistently test timings
// if (animation.currentTime > 95 && animation.currentTime < 105)
// println("Animation time after 100ms is correct");
animation = foo.animate({ opacity: [0, 1] }, { duration: 1000 });
println(`New animation has not started animating: ${getComputedStyle(foo).opacity === "0"}`);
animation.currentTime = 1000;
println(`Animation with currentTime set to end is finished: ${getComputedStyle(foo).opacity === "1"}`);
done();
}, 100);
});
</script>