Truly independent web browser
<!DOCTYPE html>
<script src="include.js"></script>
<style>
body {
margin: 0;
height: 3000px;
}
iframe {
position: absolute;
top: 250px;
left: 0;
display: block;
width: 200px;
height: 150px;
border: 0;
}
</style>
<script>
promiseTest(async () => {
const iframe = document.createElement("iframe");
const iframeLoaded = new Promise(resolve => iframe.addEventListener("load", resolve, { once: true }));
iframe.srcdoc = `<style>body { margin: 0; height: 600px; } html { scrollbar-width: none; }</style>`;
document.body.prepend(iframe);
await iframeLoaded;
let wheelEventsInIframe = 0;
iframe.contentWindow.addEventListener("wheel", () => ++wheelEventsInIframe, { passive: false });
// A blocking wheel event listener makes the compositor wait for the page before it scrolls these gestures.
window.addEventListener("wheel", () => {}, { passive: false });
await animationFrame();
await animationFrame();
// The first step scrolls the page far enough for the iframe to slide under the cursor; the gesture stays with
// the page and none of its events reach the iframe.
await internals.wheel(50, 80, 0, 200, true, "ongoing");
await internals.wheel(50, 80, 0, 100, true, "ongoing");
println(`window.scrollY mid-gesture: ${window.scrollY}`);
println(`iframe scrollY mid-gesture: ${iframe.contentWindow.scrollY}`);
println(`wheel events in the iframe mid-gesture: ${wheelEventsInIframe}`);
await internals.wheel(50, 80, 0, 0, true, "ended");
// The next gesture is routed to what is under the cursor now.
await internals.wheel(50, 80, 0, 100, true, "ongoing");
println(`iframe scrollY after a new gesture: ${iframe.contentWindow.scrollY}`);
println(`wheel events in the iframe after a new gesture: ${wheelEventsInIframe}`);
await internals.wheel(50, 80, 0, 0, true, "ended");
});
</script>