Skip to content

Truly independent web browser

1.3 KB
Raw Blame
<!DOCTYPE html>
<script src="include.js"></script>
<style>
    body {
        margin: 0;
        height: 2000px;
    }
    #a, #b {
        position: absolute;
        left: 0;
        width: 200px;
    }
    #a {
        top: 0;
        height: 100px;
    }
    #b {
        top: 100px;
        height: 300px;
    }
</style>
<div id="a"></div>
<div id="b"></div>
<script>
    promiseTest(async () => {
        const targets = [];
        // Blocking wheel event listeners make the compositor wait for the page before it scrolls these gestures.
        for (const element of [a, b])
            element.addEventListener("wheel", event => targets.push(event.currentTarget.id), { passive: false });
        await animationFrame();
        await animationFrame();

        // The first step scrolls #b under the cursor, but the gesture's events keep going to #a. Its end, a step that
        // moves along no axis, goes to the page as no wheel event.
        await internals.wheel(50, 50, 0, 100, true, "ongoing");
        await internals.wheel(50, 50, 0, 100, true, "ongoing");
        await internals.wheel(50, 50, 0, 0, true, "ended");
        await internals.wheel(50, 50, 0, 100, true, "ongoing");

        println(`wheel event targets: ${targets.join(",")}`);
        println(`window.scrollY: ${window.scrollY}`);
    });
</script>