Truly independent web browser
<!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 of the render clock beside a task samples the running animation at its own time, but a read in the task
// answers as of the animation's timeline, which only a rendering update moves. The lane goes on ticking beside the
// read.
asyncTest(async done => {
const heightBefore = { value: 0 };
const result = await whileLaneAnimates(() => {
return box.animate([{ height: "0px" }, { height: "100px" }], { duration: 10000, easing: "linear" });
}, (frameTime, animation) => {
const before = internals.clockLaneState(document);
internals.injectClockTick(frameTime + 1000);
const afterTick = internals.clockLaneState(document);
const currentTime = animation.currentTime;
const height = box.offsetHeight;
return { before, afterTick, readMatchesTimeline: Math.abs(height - currentTime / 100) <= 1, after: internals.clockLaneState(document) };
});
println(`lane as the task begins: ${result.before}`);
println(`lane after a tick: ${result.afterTick}`);
println(`the read answers as of the animation's timeline: ${result.readMatchesTimeline}`);
println(`lane after the read: ${result.after}`);
done();
});
</script>