Skip to content

Truly independent web browser

1.5 KB
Raw Blame
<!DOCTYPE html>
<script src="include.js"></script>
<style>
    body {
        margin: 0;
        height: 2000px;
    }
    #nested {
        width: 100px;
        height: 100px;
        overflow: scroll;
    }
    #nested > div {
        height: 300px;
    }
</style>
<div id="nested"><div></div></div>
<script>
    promiseTest(async () => {
        // A blocking wheel event listener makes the compositor wait for the page before it scrolls these gestures.
        nested.addEventListener("wheel", () => {}, { passive: false });
        await animationFrame();
        await animationFrame();

        // Mouse wheel ticks carry no gesture phase; ticks in quick succession at one spot are one gesture, which the
        // nested scroller absorbs once it reaches its extent.
        await Promise.all([
            internals.wheel(50, 50, 0, 150),
            internals.wheel(50, 50, 0, 150),
            internals.wheel(50, 50, 0, 100),
        ]);
        println(`nested.scrollTop after three ticks: ${nested.scrollTop}`);
        println(`window.scrollY after three ticks: ${window.scrollY}`);

        // A tick 20 CSS pixels from where the gesture started is a gesture of its own, though still over the nested
        // scroller, which at its extent leaves it to the page.
        await internals.wheel(50, 70, 0, 100);
        println(`window.scrollY after a tick elsewhere: ${window.scrollY}`);
        println(`nested.scrollTop after a tick elsewhere: ${nested.scrollTop}`);
    });
</script>