Skip to content

Truly independent web browser

1.7 KB
Raw Blame
<!DOCTYPE html>
<script src="include.js"></script>
<style>
    body {
        margin: 0;
    }
    iframe {
        width: 200px;
        height: 200px;
        border: 0;
    }
    #spacer {
        height: 2000px;
    }
</style>
<iframe id="frame" srcdoc="<style>html{scroll-snap-type:y mandatory}body{margin:0}div{height:200px;scroll-snap-align:start}</style><div></div><div></div>"></iframe>
<div id="spacer"></div>
<script>
    promiseTest(async () => {
        await new Promise(resolve => frame.addEventListener("load", resolve, { once: true }));
        await animationFrame();
        await animationFrame();

        // The first step takes the nested navigable to its last snap position, which is also its scroll extent.
        await internals.wheel(100, 100, 0, 200);
        await scrollOffsetStopsChanging(() => frame.contentWindow.scrollY);
        println(`nested navigable scroll offset after the first step: ${frame.contentWindow.scrollY}`);
        println(`page scroll offset after the first step: ${window.scrollY}`);

        // A step of the same gesture would stay with the nested navigable at its extent, so the second step is a
        // gesture of its own, which the nested navigable leaves to the page.
        await timeout(600);
        const pageScrollend = new Promise(resolve => document.addEventListener("scrollend", resolve, { once: true }));
        await internals.wheel(100, 100, 0, 200);
        await scrollOffsetStopsChanging(() => frame.contentWindow.scrollY);
        println(`nested navigable scroll offset after the second step: ${frame.contentWindow.scrollY}`);
        await pageScrollend;
        println(`page scroll offset after the second step: ${window.scrollY}`);
    });
</script>