Skip to content

Truly independent web browser

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

    iframe {
        position: absolute;
        left: 40px;
        top: 40px;
        width: 160px;
        height: 120px;
        border: 0;
    }

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

    promiseTest(async () => {
        // The iframe is made here, so that the test waits for its srcdoc document rather than the initial blank one.
        const frame = document.createElement("iframe");
        const frameLoaded = new Promise(resolve => frame.addEventListener("load", resolve, { once: true }));
        frame.srcdoc = "<body style='height: 1000px'></body>";
        document.body.prepend(frame);
        await frameLoaded;
        // The compositor routes the wheel with the first frame that shows where the iframe is, and hands it to the
        // iframe once it holds the iframe's frame too.
        await waitForCondition(() => {
            const state = internals.compositorScrollState();
            return state.document === document && state.nestedContextWheelRegionCount > 0;
        });
        await waitForCondition(() => frame.contentWindow.internals.compositorScrollState().document === frame.contentDocument);

        const state = internals.compositorScrollState();
        const output = [
            `main thread regions: ${state.mainThreadWheelEventRegionCount}`,
            `nested context regions: ${state.nestedContextWheelRegionCount}`,
            `over iframe: ${wheelTargetToString(internals.compositorWheelTargetAt(60, 60, 0, 100))}`,
            `outside iframe: ${wheelTargetToString(internals.compositorWheelTargetAt(250, 60, 0, 100))}`,
        ];
        printOutputAndDisplayList(output);
    });
</script>