Skip to content

Truly independent web browser

1.4 KB
Raw Blame
<!DOCTYPE html>
<script src="../include.js"></script>
<script src="../work-test.js"></script>
<div id="scroller" style="overflow: scroll; width: 100px; height: 100px;">
    <div id="child" style="width: 50px; height: 50px;"></div>
</div>
<script>
    // An animated transform flows through the animation update context rather than the regular
    // style update path, and must schedule scrollable overflow recalculation the same way.
    test(() => {
        const scroller = document.getElementById("scroller");
        const child = document.getElementById("child");
        const initialHeight = scroller.scrollHeight;
        let heightAtAnimationEnd;
        let heightAtAnimationStart;
        const work = layoutWork(() => {
            const animation = child.animate(
                [{ transform: "translateY(0px)" }, { transform: "translateY(500px)" }],
                { duration: 1000, fill: "forwards" });
            animation.pause();
            animation.currentTime = 1000;
            heightAtAnimationEnd = scroller.scrollHeight;
            animation.currentTime = 0;
            heightAtAnimationStart = scroller.scrollHeight;
        });
        println(`initial scrollHeight: ${initialHeight}`);
        println(`scrollHeight at animation end: ${heightAtAnimationEnd}`);
        println(`scrollHeight at animation start: ${heightAtAnimationStart}`);
        println(`layout passes: ${work.passes().join(" | ") || "(no layout)"}`);
    });
</script>