Truly independent web browser
<!DOCTYPE html>
<script src="../include.js"></script>
<style>
@keyframes move-horizontally {
from, 25% { transform: translateX(0); }
26%, to { transform: translateX(30px); }
}
@keyframes turn {
from, 90% { transform: rotate(0deg); }
to { transform: rotate(90deg); }
}
#root {
position: relative;
width: 20px;
height: 20px;
overflow: hidden;
}
#rotated-parent {
position: absolute;
top: -30px;
animation: turn 100s linear forwards;
transform-origin: 0 0;
}
#target {
width: 20px;
height: 20px;
animation: move-horizontally 400ms linear infinite;
}
</style>
<div id="root"><div id="rotated-parent"><div id="target"></div></div></div>
<script>
function printCompositorAnimations(title) {
println(title);
for (const line of internals.dumpCompositorAnimations().split("\n").filter(Boolean))
println(` ${line}`);
}
asyncTest(async done => {
const ancestorAnimation = document.querySelector("#rotated-parent").getAnimations()[0];
ancestorAnimation.currentTime = 0;
const animation = target.getAnimations()[0];
animation.currentTime = 0;
let resolveObservation;
let nextObservation = new Promise(resolve => resolveObservation = resolve);
const observer = new IntersectionObserver(entries => resolveObservation(entries.at(-1)), { root });
observer.observe(target);
println(`target starts outside root: ${!(await nextObservation).isIntersecting}`);
printCompositorAnimations("compositor animations:");
nextObservation = new Promise(resolve => resolveObservation = resolve);
ancestorAnimation.currentTime = 100000;
animation.currentTime = 200;
println(`target enters root: ${(await nextObservation).isIntersecting}`);
observer.disconnect();
ancestorAnimation.cancel();
animation.cancel();
done();
});
</script>