Skip to content

Truly independent web browser

2.2 KB
Raw Blame
<!DOCTYPE html>
<script src="../include.js"></script>
<script src="../work-test.js"></script>
<style>
    #before {
        width: 20px;
        height: 20px;
    }

    #parent {
        width: 200px;
        height: 200px;
    }

    #scroller {
        width: 100px;
        height: 100px;
        overflow: scroll;
    }

    #content {
        width: 500px;
        height: 500px;
    }
</style>
<div id="before"></div>
<div id="parent"><div id="scroller"><div id="content"></div></div></div>
<script>
    const scrollNodeIndex = () => {
        internals.recordDisplayListForTesting();
        return internals.recordedAsyncScrollingState().scrollNodes.find(node => !node.isViewport).scrollNodeIndex;
    };
    let initialIndex;
    visualContextTest({
        setup: async () => {
            internals.forceIncompatibleVisualContextTreeRebuild();
            while (internals.frameSchedulerState() !== "idle")
                await new Promise(resolve => setTimeout(resolve, 0));
            initialIndex = scrollNodeIndex();
        },
        steps: [
            {
                name: "a preceding sibling gains a transform",
                mutate: () => { document.getElementById("before").style.transform = "translateX(0)"; },
                check: equal => equal(scrollNodeIndex(), initialIndex, "scroll node index"),
                expect: `
                    update DIRTY-PATH
                      div#before transform ALLOCATED
                      recording NEEDED
                `,
            },
            {
                name: "the scroller's parent gains a transform",
                mutate: () => { document.getElementById("parent").style.transform = "translateX(5px)"; },
                check: equal => {
                    equal(scrollNodeIndex(), initialIndex, "scroll node index");
                    equal(scroller.getBoundingClientRect().x, 13, "scroller x");
                },
                expect: `
                    update DIRTY-PATH
                      div#parent transform ALLOCATED
                      div#scroller clip REPURPOSED
                      div#scroller scroll REPURPOSED
                      epoch NEW
                      recording NEEDED
                `,
            },
        ],
    });
</script>