Truly independent web browser
<!DOCTYPE html>
<script src="../../include.js"></script>
<script src="frame-in-flight.js"></script>
<style>
@keyframes resize {
from { height: 100px; }
to { height: 300px; }
}
@keyframes widen {
from { width: 100px; }
to { width: 300px; }
}
body {
margin: 0;
}
#scroller {
height: 100px;
width: 400px;
overflow: auto;
animation: resize linear both;
animation-timeline: scroll(root);
}
#before {
height: 50px;
}
#subject {
height: 50px;
animation: widen linear both;
animation-timeline: view(10%);
}
#after {
height: 1000px;
}
#spacer {
height: 2000px;
}
</style>
<div id="scroller">
<div id="before"></div>
<div id="subject"></div>
<div id="after"></div>
</div>
<div id="spacer"></div>
<script>
// A tick that resizes the scrollport of a view timeline resolves the timeline's percentage insets against the new
// size, as the host's next rendering update does.
asyncTest(async done => {
const result = await whileLaneAnimates(() => subject.getAnimations()[0], frameTime => {
const position = document.documentElement.scrollHeight - window.innerHeight;
for (let tick = 1; tick <= 8; tick++)
internals.injectClockTick(frameTime + 16 * tick, position);
return {
size: internals.presentedBorderBox(scroller).height,
width: internals.presentedBorderBox(subject).width,
};
});
const coverStart = 50 - (result.size - 0.1 * result.size);
const coverEnd = 50 + 50 - 0.1 * result.size;
const progress = (0 - coverStart) / (coverEnd - coverStart);
println(`the ticks resized the scrollport: ${result.size > 100}`);
println(`the subject shows the progress with its insets in that scrollport: ${Math.abs(result.width - (100 + 200 * progress)) < 0.5}`);
done();
});
</script>