Truly independent web browser
<!DOCTYPE html>
<script src="include.js"></script>
<style>
body {
margin: 0;
height: 2000px;
}
#scroller {
width: 100px;
height: 100px;
overflow: scroll;
}
#scroller > div {
height: 200px;
}
</style>
<div id="scroller"><div></div></div>
<script>
promiseTest(async () => {
const cancelable = [];
scroller.addEventListener("wheel", event => {
cancelable.push(event.cancelable);
if (cancelable.length == 1)
event.preventDefault();
}, { passive: false });
await animationFrame();
await animationFrame();
// NB: These steps belong to one gesture for as long as its fingers rest, however long the test takes to reach the
// next one. Wheel ticks with no phase stop belonging to it once enough time has passed between them.
await internals.wheel(50, 50, 0, 100, true, "ongoing");
println(`scroller.scrollTop after the cancelled step: ${scroller.scrollTop}`);
// The cancelled event ended the gesture the scroller was latched for, so the page sees this step first again,
// and it is routed afresh.
await internals.wheel(50, 50, 0, 100, true, "ongoing");
println(`scroller.scrollTop after the step following the cancelled one: ${scroller.scrollTop}`);
// The page let the gesture through, so this step does not wait for it, and the scroller at its extent keeps it.
await internals.wheel(50, 50, 0, 100, true, "ongoing");
println(`window.scrollY after the last step: ${window.scrollY}`);
println(`cancelable: ${cancelable.join(",")}`);
});
</script>