Truly independent web browser
<!DOCTYPE html>
<style>
@keyframes hide {
0%,
100% {
--display: none;
}
}
.hiding {
animation: hide 1s infinite;
display: var(--display, block);
}
</style>
<body>
<script src="../include.js"></script>
<script>
asyncTest(async done => {
// The animation keeps running with the element not displayed, as its display ignoring animations is not none.
const frame = () => new Promise(requestAnimationFrame);
const outer = document.createElement("div");
const inner = document.createElement("div");
const leaf = document.createElement("div");
inner.append(leaf);
outer.append(inner);
document.body.append(outer);
await frame();
outer.classList.add("hiding");
await frame();
const read = element => {
getComputedStyle(element, "::first-line").color;
return getComputedStyle(element).getPropertyValue("color");
};
println(read(leaf));
await frame();
println(read(leaf));
println(`${getComputedStyle(outer).display}, ${outer.getAnimations().length} animation`);
const late = document.createElement("div");
inner.append(late);
println(read(late));
const animation = outer.getAnimations()[0];
animation?.pause();
if (animation)
animation.currentTime = 500;
println(read(leaf));
animation?.cancel();
println(read(leaf));
await frame();
println(read(leaf));
done();
});
</script>