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; transform: translate(1px, 1px);"></div>
</div>
<script>
    // A transform value change must refresh the scroll container's scrollable overflow without
    // performing layout.
    // NOTE: All geometry reads happen before any println(), because printing mutates the DOM and
    //       forces a relayout that would mask missing invalidation.
    test(() => {
        const scroller = document.getElementById("scroller");
        const child = document.getElementById("child");
        const initialWidth = scroller.scrollWidth;
        const initialHeight = scroller.scrollHeight;
        let widthAfterChange;
        let heightAfterChange;
        const work = layoutWork(() => {
            child.style.transform = "translate(200px, 500px)";
            widthAfterChange = scroller.scrollWidth;
            heightAfterChange = scroller.scrollHeight;
        });
        println(`initial scrollWidth: ${initialWidth}`);
        println(`initial scrollHeight: ${initialHeight}`);
        println(`scrollWidth after transform change: ${widthAfterChange}`);
        println(`scrollHeight after transform change: ${heightAfterChange}`);
        println(`layout passes: ${work.passes().join(" | ") || "(no layout)"}`);
    });
</script>