Files
ladybird/Tests/LibWeb/Text/input/WebAnimations/animation-methods/persist.html
2024-03-30 19:26:58 +01:00

31 lines
1.4 KiB
HTML

<!DOCTYPE html>
<div id="foo"></div>
<script src="../../include.js"></script>
<script>
promiseTest(async () => {
const foo = document.getElementById("foo");
let anim = foo.animate({}, {});
const prevReplaceState = anim.replaceState;
anim.persist();
if (prevReplaceState === "active" && anim.replaceState === "persisted")
println("persist() sets animation's replaceState to persist");
const timeline = internals.createInternalAnimationTimeline();
let anim1 = foo.animate({ opacity: 0 }, { duration: 1000, fill: "forwards", timeline });
let anim2 = foo.animate({ opacity: 0 }, { duration: 500, fill: "forwards", timeline });
timeline.setTime(1500);
await animationFrame();
if (anim1.replaceState === "removed" && anim2.replaceState === "active")
println("Animations are properly replaced when covered by another animation");
anim1 = foo.animate({ opacity: 0 }, { duration: 1000, fill: "forwards", timeline });
anim2 = foo.animate({ opacity: 0 }, { duration: 500, fill: "forwards", timeline });
anim1.persist();
timeline.setTime(1500);
await animationFrame();
if (anim1.replaceState === "persisted" && anim2.replaceState === "active")
println("persist() keeps an animation from being replaced");
});
</script>