Skip to content

Truly independent web browser

1.4 KB
Raw Blame
<!DOCTYPE html>
<style>
    body { margin: 0; }
    #box { width: 100px; height: 50px; background: rgb(0, 128, 0); }
    #box:hover { width: 150px; background: rgb(255, 0, 0); }
</style>
<div id="box"></div>
<script src="../../include.js"></script>
<script src="../../HTML/frame-in-flight/frame-in-flight.js"></script>
<script>
    asyncTest(async done => {
        const box = document.getElementById("box");
        const read = (label) => {
            const style = getComputedStyle(box);
            println(`${label}: width=${style.width} background=${style.backgroundColor} box.width=${box.getBoundingClientRect().width}`);
        };
        internals.updateStyle();
        internals.beginStyleTrace();
        read("initial");
        // The render clock hovers on a fork of the render state, which goes on with the style engine
        // it forked, without a cold pass of its own.
        const onScreen = await whileLaneHovers(async frameTime => {
            internals.injectHoverPointer(20, 20, frameTime + 16);
            return internals.presentedBorderBox(box)?.width;
        });
        println(`hovered by the render clock: box width on screen=${onScreen}`);
        println(`style restarted from a cold pass: ${internals.takeStyleTrace().includes("style COLD")}`);
        internals.mouseMove(20, 20);
        read("hovered");
        internals.mouseMove(300, 300);
        read("unhovered");
        done();
    });
</script>