Skip to content

Truly independent web browser

1013 B
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>
<script>
    // A tick handed an earlier time than a tick before it does not sample the animation back in time.
    asyncTest(async done => {
        const result = await whileLaneAnimates(() => {
            return box.animate([{ height: "0px" }, { height: "100px" }], { duration: 10000, easing: "linear" });
        }, (frameTime, animation) => {
            internals.injectClockTick(frameTime + 2000);
            internals.injectClockTick(frameTime + 1000);
            const expectedHeight = (frameTime + 2000 - animation.startTime) / 100;
            const presented = internals.presentedBorderBox(box);
            return presented !== null && Math.abs(presented.height - expectedHeight) < 0.02;
        });
        println(`the presented height is the animation's at the latest tick: ${result}`);
        done();
    });
</script>