Skip to content

Truly independent web browser

2.0 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 () => {
        await animationFrame();
        await animationFrame();

        await scrollSettled(nested, () => nested.scrollTo(0, 190));

        await internals.wheel(50, 50, 0, 410, true, "ongoing");
        println(`held by the fingers: nested.scrollTop=${nested.scrollTop} stretch=${internals.compositorScrollState(nested).stretch.y}`);
        for (let frame = 0; frame < 5; frame++)
            await animationFrame();
        println(`still held: stretch=${internals.compositorScrollState(nested).stretch.y}`);

        let scrollEventCount = 0;
        nested.addEventListener("scroll", () => scrollEventCount++);
        let stretchGrewDuringRebound = false;
        let scrollTopChangedDuringRebound = false;

        await internals.wheel(50, 50, 0, 0, true, "ended");
        let previousStretch = internals.compositorScrollState(nested).stretch.y;
        while (previousStretch !== 0) {
            await animationFrame();
            const stretch = internals.compositorScrollState(nested).stretch.y;
            if (stretch > previousStretch)
                stretchGrewDuringRebound = true;
            if (nested.scrollTop !== 200)
                scrollTopChangedDuringRebound = true;
            previousStretch = stretch;
        }
        await animationFrame();
        await animationFrame();

        println(`sprung back: nested.scrollTop=${nested.scrollTop} stretch=${internals.compositorScrollState(nested).stretch.y}`);
        println(`stretch grew during the rebound: ${stretchGrewDuringRebound}`);
        println(`scrollTop changed during the rebound: ${scrollTopChangedDuringRebound}`);
        println(`scroll events during the rebound: ${scrollEventCount}`);
    });
</script>