LibWeb: Add some async/animation test utilities

This commit is contained in:
Matthew Olsson 2024-03-29 16:54:12 +00:00 committed by Andreas Kling
commit e298e8af5a
Notes: sideshowbarker 2024-07-16 23:55:09 +09:00
13 changed files with 65 additions and 91 deletions

View file

@ -2,7 +2,7 @@
<div id="foo"></div>
<script src="../../include.js"></script>
<script>
test(() => {
promiseTest(async () => {
const foo = document.getElementById("foo");
let anim = foo.animate({}, {});
@ -45,19 +45,17 @@
let finishCount = 0;
anim.onfinish = () => { finishCount++; }
anim.finish();
requestAnimationFrame(() => {
if (finishCount === 1)
println("finish() sends an onfinish event");
})
await animationFrame();
if (finishCount === 1)
println("finish() sends an onfinish event");
anim = foo.animate({}, { duration: 1000 });
let finished = false;
anim.finished.then(() => finished = true);
anim.finish();
requestAnimationFrame(() => {
if (finished)
println("finish() recreated the animation's finished promise");
});
await animationFrame();
if (finished)
println("finish() recreated the animation's finished promise");
});
</script>