Skip to content

Truly independent web browser

1.9 KB
Raw Blame
<!DOCTYPE html>
<style>
body {
    margin: 0;
}

#scroller {
    width: 150px;
    height: 100px;
    overflow-y: scroll;
    overflow-x: hidden;
}

#content {
    height: 1000px;
}
</style>
<div id="scroller">
    <div id="content"></div>
</div>
<script src="../include.js"></script>
<script>
    promiseTest(async () => {
        let pointerDownCount = 0;
        scroller.addEventListener("pointerdown", () => ++pointerDownCount);
        await animationFrame();
        await animationFrame();

        // The compositor scrolls for a drag of the scrollbar, and the page sees the drag's events without scrolling
        // for them a second time. A move far away from the scrollbar still belongs to the captured drag.
        internals.beginInputTrace();
        await internals.mouseEventThroughUIProcess("mousemove", 147, 5);
        await internals.mouseEventThroughUIProcess("mousedown", 147, 5);
        await internals.mouseEventThroughUIProcess("mousemove", 147, 60, { buttons: 1 });
        await internals.mouseEventThroughUIProcess("mousemove", 20, 90, { buttons: 1 });
        await internals.mouseEventThroughUIProcess("mouseup", 20, 90);
        printInputTrace(internals.takeInputTrace());
        await animationFrame();
        println(`pointerdown reached the scroller: ${pointerDownCount === 1}`);
        println(`scrollTop after the drag: ${scroller.scrollTop}`);

        // The scrollbar takes another drag once the first one has ended.
        scroller.scrollTop = 0;
        await animationFrame();
        await animationFrame();
        await internals.mouseEventThroughUIProcess("mousedown", 147, 5);
        await internals.mouseEventThroughUIProcess("mousemove", 147, 60, { buttons: 1 });
        await internals.mouseEventThroughUIProcess("mouseup", 147, 60);
        await animationFrame();
        println(`scrolled by another drag afterwards: ${scroller.scrollTop > 0}`);
    });
</script>