Skip to content

Truly independent web browser

1.6 KB
Raw Blame
<!DOCTYPE html>
<script src="../../include.js"></script>
<script src="frame-in-flight.js"></script>
<div id="box" style="width: 10px; height: 0px; background: green"></div>
<div id="other" style="width: 10px; height: 10px; background: blue"></div>
<script>
    // The rendering update of a nested event loop presents a frame and leaves it no plan. The next rendering update,
    // which presents nothing of its own, seals the plan for that frame: the frame's lane ticks the running animations
    // beside the tasks after it.
    asyncTest(async done => {
        internals.setManualRenderingOpportunities(true);
        await nextTask();
        const animation = box.animate([{ height: "0px" }, { height: "100px" }], { duration: 10000, easing: "linear" });
        let frameTime = performance.now();
        internals.injectRenderingOpportunity(frameTime);
        await nextTask();
        while (animation.pending) {
            frameTime += 16;
            internals.injectRenderingOpportunity(frameTime);
            await nextTask();
        }
        other.style.backgroundColor = "green";
        alert("nested");
        internals.injectRenderingOpportunity(frameTime);
        do await nextTask();
        while (internals.frameSchedulerState() !== "idle");
        println(`lane in the first task after the updates: ${internals.clockLaneState(document)}`);
        internals.injectClockTick(frameTime + 1000);
        println(`last frame presented by: ${internals.lastFramePresentedBy(document)}`);
        internals.setManualRenderingOpportunities(false);
        done();
    });
</script>