Truly independent web browser
<!DOCTYPE html>
<script src="../../include.js"></script>
<script src="frame-in-flight.js"></script>
<style>
@keyframes widen {
from { width: 200px; }
to { width: 700px; }
}
#pane {
container-type: inline-size;
width: 200px;
}
#pane.widen {
animation: widen 10s linear;
}
#title {
height: 10px;
}
#aside {
display: none;
}
#aside > div {
height: 1em;
}
@container (min-width: 400px) {
#aside {
display: block;
font-size: 30px;
}
}
</style>
<div id="pane"><div id="title"></div><div id="aside"><div><span>Aside</span></div></div></div>
<script>
// The render clock builds the boxes a container query shows beside a task even where the box it shows holds
// elements with elements of their own, which no style update reached while the box was display:none.
asyncTest(async done => {
const result = await whileLaneAnimates(() => {
pane.classList.add("widen");
return pane.getAnimations()[0];
}, (frameTime, animation) => {
internals.injectClockTick(frameTime + 3000);
internals.injectClockTick(frameTime + 5000);
return {
clock: internals.clockLaneState(document),
presented: internals.presentedBorderBox(pane),
presentedBy: internals.lastFramePresentedBy(document),
localTime: frameTime + 5000 - animation.startTime,
animation,
};
});
result.animation.pause();
result.animation.currentTime = result.localTime;
const laidOut = pane.getBoundingClientRect();
const presented = result.presented;
println(`clock after its frames: ${result.clock}`);
println(`last frame presented by: ${result.presentedBy}`);
println(`the presented size is the main thread's: ${presented !== null && Math.abs(presented.width - laidOut.width) < 0.02 && Math.abs(presented.height - laidOut.height) < 0.02}`);
println(`the aside joined the pane at its font size: ${laidOut.height === 40}`);
done();
});
</script>