Truly independent web browser
<!DOCTYPE html>
<script src="../include.js"></script>
<style>
body {
margin: 0;
height: 3000px;
}
</style>
<script>
promiseTest(async () => {
await animationFrame();
await animationFrame();
const vv = window.visualViewport;
internals.pinchThroughUIProcess(0, 0, 1.0);
while (vv.scale === 1)
await animationFrame();
await animationFrame();
await animationFrame();
const busyWait = milliseconds => {
const end = performance.now() + milliseconds;
while (performance.now() < end) {}
};
// The compositor pans the zoomed visual viewport by 50 while the main thread is busy, so the main thread has not
// heard of it when the page scrolls itself by 30. The visual viewport takes that from where the pan left it.
await internals.wheelThroughUIProcess(50, 50, 0, 0, true, "ongoing");
await animationFrame();
await animationFrame();
const panned = internals.wheelThroughUIProcess(50, 50, 0, 100, true, "ongoing");
busyWait(200);
window.scrollBy(0, 30);
// Once the UI process has handed the wheel to the compositor, and a rendering update has committed the frame
// that carries the page's scroll, synchronizing with the compositor and waiting for a frame brings the pan to
// this thread.
await panned;
await animationFrame();
await animationFrame();
internals.synchronizeCompositor();
await animationFrame();
println(`visual viewport offset: ${vv.offsetTop}`);
println(`layout viewport offset: ${window.scrollY}`);
await internals.wheelThroughUIProcess(50, 50, 0, 0, true, "ended");
});
</script>