Truly independent web browser
<!DOCTYPE html>
<script src="include.js"></script>
<style>
#scroller {
width: 200px;
height: 200px;
overflow: scroll;
scroll-snap-type: y mandatory;
}
.item {
height: 200px;
scroll-snap-align: start;
}
</style>
<div id="scroller">
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
</div>
<script>
promiseTest(async () => {
const scroller = document.getElementById("scroller");
await animationFrame();
await animationFrame();
let scrollendCount = 0;
scroller.addEventListener("scrollend", () => ++scrollendCount);
// Nothing keeps this gesture on the main thread, so the compositor process runs the scroll to the snap position
// selected once the gesture settles.
while (true) {
await internals.wheel(50, 50, 0, 120, true);
while (scroller.scrollTop === 120)
await animationFrame();
// The input of a new gesture takes the scroll over, so its scrollend event is not delivered mid-gesture.
await internals.wheel(50, 50, 0, 20, true);
if (scroller.scrollTop < 220)
break;
while (scroller.scrollTop % 200 !== 0)
await scrollendEvent(scroller);
await scrollSettled(scroller, () => scroller.scrollTop = 0);
scrollendCount = 0;
}
await animationFrame();
println(`scrollend events while the gesture was in progress: ${scrollendCount}`);
await scrollendEvent(scroller);
println(`scroll offset after the gesture settled: ${scroller.scrollLeft},${scroller.scrollTop}`);
println(`scrollend events in total: ${scrollendCount}`);
});
</script>