LibWeb: Use InternalAnimationTimeline in the playbackRate.html test

This commit is contained in:
Matthew Olsson 2024-03-27 16:49:34 -07:00 committed by Andreas Kling
commit 7dcd7206d3
Notes: sideshowbarker 2024-07-16 23:08:48 +09:00

View file

@ -2,34 +2,30 @@
<div id="foo"></div> <div id="foo"></div>
<script src="../../include.js"></script> <script src="../../include.js"></script>
<script> <script>
asyncTest(async done => { test(() => {
const wait = async (ms) => new Promise(resolve => setTimeout(resolve, ms));
const foo = document.getElementById("foo"); const foo = document.getElementById("foo");
const animation = foo.animate({ opacity: [0, 1] }, { duration: 1000 }); const timeline = internals.createInternalAnimationTimeline();
const animation = foo.animate({ opacity: [0, 1] }, { duration: 1000, timeline });
animation.playbackRate = 2; animation.playbackRate = 2;
// Allow 50ms of error for each test timeline.setTime(100);
await wait(100); if (animation.currentTime === 200)
if (animation.currentTime >= 150 && animation.currentTime <= 250)
println("Animation has expected currentTime value after 100ms"); println("Animation has expected currentTime value after 100ms");
animation.playbackRate = 0.5; animation.playbackRate = 0.5;
await wait(100); timeline.setTime(200);
if (animation.currentTime >= 200 && animation.currentTime <= 300) if (animation.currentTime === 250)
println("Animation has expected currentTime value after 200ms"); println("Animation has expected currentTime value after 200ms");
animation.playbackRate = -1; animation.playbackRate = -1;
await wait(100); timeline.setTime(300);
if (animation.currentTime >= 100 && animation.currentTime <= 200) if (animation.currentTime === 150)
println("Animation has expected currentTime value after 300ms"); println("Animation has expected currentTime value after 300ms");
animation.playbackRate = 0; animation.playbackRate = 0;
const originalTime = animation.currentTime; const originalTime = animation.currentTime;
await wait(100); timeline.setTime(400);
if (animation.currentTime === originalTime) if (animation.currentTime === originalTime)
println("Animation has expected currentTime value after 400ms"); println("Animation has expected currentTime value after 400ms");
done();
}); });
</script> </script>