Truly independent web browser
Tests/LibWeb: Test a pinch away from blocking wheel listeners
Andreas Kling6cbc24cfb28f
diff --git a/Tests/LibWeb/Text/expected/SiteIsolation/iframe/pinch-away-from-isolated-iframe-with-blocking-wheel-listener.txt b/Tests/LibWeb/Text/expected/SiteIsolation/iframe/pinch-away-from-isolated-iframe-with-blocking-wheel-listener.txtnew file mode 100644index 00000000000..9e81d140bc7--- /dev/null+++ b/Tests/LibWeb/Text/expected/SiteIsolation/iframe/pinch-away-from-isolated-iframe-with-blocking-wheel-listener.txt@@ -0,0 +1 @@+compositor scale beside the task: 1diff --git a/Tests/LibWeb/Text/expected/async-scrolling/pinch-away-from-a-blocking-wheel-listener.txt b/Tests/LibWeb/Text/expected/async-scrolling/pinch-away-from-a-blocking-wheel-listener.txtnew file mode 100644index 00000000000..b2b3be08f53--- /dev/null+++ b/Tests/LibWeb/Text/expected/async-scrolling/pinch-away-from-a-blocking-wheel-listener.txt@@ -0,0 +1,2 @@+over the listener: cancelable=true compositor scale=1+away from the listener, beside the task: compositor scale=1diff --git a/Tests/LibWeb/Text/input/SiteIsolation/iframe/pinch-away-from-isolated-iframe-with-blocking-wheel-listener.html b/Tests/LibWeb/Text/input/SiteIsolation/iframe/pinch-away-from-isolated-iframe-with-blocking-wheel-listener.htmlnew file mode 100644index 00000000000..563c33d2d6c--- /dev/null+++ b/Tests/LibWeb/Text/input/SiteIsolation/iframe/pinch-away-from-isolated-iframe-with-blocking-wheel-listener.html@@ -0,0 +1,54 @@+<!doctype html>+<script src="../../include.js"></script>+<style>+ body {+ margin: 0;+ }+ iframe {+ display: block;+ width: 300px;+ height: 200px;+ border: 0;+ }+</style>+<script>+ // An iframe's listeners only see the wheel event of a pinch over the iframe, so a pinch elsewhere on the page does+ // not wait for it. The compositor zooms without waiting for the task that keeps the main thread busy.+ promiseTest(async () => {+ const remoteUrl = new URL(+ await httpTestServer().createEcho("GET", "/oop-iframe-pinch-away", {+ status: 200,+ headers: { "Content-Type": "text/html" },+ body: `<!DOCTYPE html><script>+ addEventListener("wheel", () => {}, { passive: false });+ requestAnimationFrame(() => requestAnimationFrame(() => {+ // The parent synchronizes only its own process. Publish this frame's listener state and+ // parent-context link on our compositor connection before inviting input.+ internals.synchronizeCompositor();+ parent.postMessage("ready", "*");+ }));+ <\/script>`,+ })+ );+ remoteUrl.hostname = uniqueLocalhostHostname("oop-iframe-pinch-away");++ const ready = new Promise(resolve => window.addEventListener("message", resolve, { once: true }));+ const iframe = document.createElement("iframe");+ iframe.src = remoteUrl;+ document.body.appendChild(iframe);+ await ready;+ await animationFrame();+ await animationFrame();++ const compositorScale = () => internals.compositorScrollState().visualViewportScale;+ internals.pinchThroughUIProcess(500, 400, 0.5);++ // NB: This only gives up on a zoom that never comes, so the time limit can't fail a slow machine's run of a fixed+ // engine.+ const giveUpAt = performance.now() + 5000;+ while (compositorScale() !== 1.5 && performance.now() < giveUpAt) {+ // Stay in this task.+ }+ println(`compositor scale beside the task: ${compositorScale()}`);+ });+</script>diff --git a/Tests/LibWeb/Text/input/async-scrolling/pinch-away-from-a-blocking-wheel-listener.html b/Tests/LibWeb/Text/input/async-scrolling/pinch-away-from-a-blocking-wheel-listener.htmlnew file mode 100644index 00000000000..daa66613c5d--- /dev/null+++ b/Tests/LibWeb/Text/input/async-scrolling/pinch-away-from-a-blocking-wheel-listener.html@@ -0,0 +1,52 @@+<!DOCTYPE html>+<script src="../include.js"></script>+<style>+ body {+ margin: 0;+ height: 3000px;+ }+ #listener {+ position: absolute;+ left: 0;+ top: 0;+ width: 100px;+ height: 100px;+ }+</style>+<div id="listener"></div>+<script>+ // A listener only sees the wheel event of a pinch over its own element, so it only holds back that pinch. The+ // compositor zooms for one elsewhere on the page without waiting for the task that keeps the main thread busy.+ promiseTest(async () => {+ const compositorScale = () => internals.compositorScrollState().visualViewportScale;+ const wheelEvent = new Promise(resolve => {+ listener.addEventListener(+ "wheel",+ event => {+ event.preventDefault();+ resolve(event);+ },+ { passive: false }+ );+ });+ await animationFrame();+ await animationFrame();++ internals.pinchThroughUIProcess(50, 50, 0.5);+ const event = await wheelEvent;+ println(`over the listener: cancelable=${event.cancelable} compositor scale=${compositorScale()}`);++ // NB: Leave the task handling the pinch above, which holds back the next one until it finishes.+ await animationFrame();++ internals.pinchThroughUIProcess(400, 300, 0.5);++ // NB: This only gives up on a zoom that never comes, so the time limit can't fail a slow machine's run of a fixed+ // engine.+ const giveUpAt = performance.now() + 5000;+ while (compositorScale() !== 1.5 && performance.now() < giveUpAt) {+ // Stay in this task.+ }+ println(`away from the listener, beside the task: compositor scale=${compositorScale()}`);+ });+</script>