Skip to content

Truly independent web browser

1.9 KB
Raw Blame
<!DOCTYPE html>
<script src="../../include.js"></script>
<script src="frame-in-flight.js"></script>
<style>
    #target { width: 20px; height: 20px; transform: translateX(0); transition: transform 100s linear 100s; }
    #target.changed { transform: translateX(100px); }
    #probe { width: 50px; height: 10px; }
</style>
<div id="target"></div>
<div id="probe"></div>
<script>
    // The compositor animation wake-up of a delayed transition comes from a timer, not a task, so it may come while a
    // frame flies. Republishing the transition's visual animations at its active start reads the render state, which
    // lands the frame in flight in a read of its own.
    asyncTest(async done => {
        await twoFrames();
        target.classList.add("changed");
        await twoFrames();
        const transition = target.getAnimations()[0];
        await transition.ready;
        await twoFrames();
        const activeStartTime = transition.startTime + 100001;

        const result = await whileRecordingInFlight(() => {
            internals.beginRenderingTrace();
            probe.style.width = "60px";
        }, state => {
            internals.fireCompositorAnimationWakeupForTesting(activeStartTime);
            const trace = internals.takeRenderingTrace().split("\n");
            return {
                state,
                republished: trace.filter(line => line.startsWith("compositor animations updated")),
                requested: trace.filter(line => line.startsWith("animation frame pump request")),
            };
        });
        println(`state in the next task: ${result.state}`);
        println(`wake-up republishes beside the frame: [${result.republished.join(", ")}]`);
        println(`wake-up requests a frame: [${result.requested.join(", ")}]`);
        await twoFrames();
        println(`probe box width: ${probe.offsetWidth}`);
        transition.cancel();
        done();
    });
</script>