Truly independent web browser
<!DOCTYPE html>
<script src="../../include.js"></script>
<script src="frame-in-flight.js"></script>
<style>
@keyframes slide {
from { margin-left: 0px; }
to { margin-left: 100px; }
}
#box {
width: 50px;
height: 50px;
border-radius: 10px;
background: green;
animation: slide 100s linear paused;
}
</style>
<div id="box"></div>
<script>
// A recording in flight reads the animated style its frame was published with. Moving the animation beside it
// replaces that style for the next frame, and the replaced style stays readable until the recording is done.
// Once the recording lands, the replaced style is freed though nothing styles.
asyncTest(async done => {
const animation = box.getAnimations()[0];
await whileRecordingInFlight(() => {
animation.currentTime = 10000;
// Laid out here, so that what the rendering update lets fly is its recording.
box.offsetWidth;
}, () => {
animation.currentTime = 50000;
box.offsetWidth;
});
await twoFrames();
println(`margin-left: ${getComputedStyle(box).marginLeft}`);
println(`hit test finds the box: ${document.elementFromPoint(80, 30) === box}`);
done();
});
</script>