Skip to content

Truly independent web browser

1.6 KB
Raw Blame
<!DOCTYPE html>
<script src="../include.js"></script>
<style>
    body {
        margin: 0;
    }

    #sticky {
        position: sticky;
        top: 0;
    }

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

    #spacer {
        width: 500px;
        height: 500px;
    }
</style>
<div id="sticky">
    <div id="scroller"><div id="spacer"></div></div>
</div>
<div style="height: 2000px"></div>
<script>
    function printOutputAndDisplayList(output) {
        const displayList = internals.dumpDisplayList();
        for (const line of output)
            println(line);
        println("display list:");
        println(displayList);
    }

    promiseTest(async () => {
        await animationFrame();
        await animationFrame();
        const state = internals.compositorScrollState();
        const scrollNodeIndices = new Set(state.scrollNodes.map(node => node.scrollNodeIndex));
        const viewportNode = state.scrollNodes.find(node => node.isViewport);
        const childNodes = state.scrollNodes.filter(node => !node.isViewport);
        const danglingParentNodes = state.scrollNodes.filter(node => node.parentScrollNodeIndex !== 0 && !scrollNodeIndices.has(node.parentScrollNodeIndex));

        const output = [
            `scroll nodes: ${state.scrollNodes.length}`,
            `child nodes: ${childNodes.length}`,
            `dangling parent nodes: ${danglingParentNodes.length}`,
        ];
        for (const node of childNodes)
            output.push(`child parent is viewport: ${node.parentScrollNodeIndex === viewportNode.scrollNodeIndex}`);
        printOutputAndDisplayList(output);
    });
</script>