summaryrefslogtreecommitdiffstats
path: root/gfx/layers/apz/test/mochitest/helper_override_root.html
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
commit36d22d82aa202bb199967e9512281e9a53db42c9 (patch)
tree105e8c98ddea1c1e4784a60a5a6410fa416be2de /gfx/layers/apz/test/mochitest/helper_override_root.html
parentInitial commit. (diff)
downloadfirefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz
firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip
Adding upstream version 115.7.0esr.upstream/115.7.0esr
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'gfx/layers/apz/test/mochitest/helper_override_root.html')
-rw-r--r--gfx/layers/apz/test/mochitest/helper_override_root.html62
1 files changed, 62 insertions, 0 deletions
diff --git a/gfx/layers/apz/test/mochitest/helper_override_root.html b/gfx/layers/apz/test/mochitest/helper_override_root.html
new file mode 100644
index 0000000000..81c1b34938
--- /dev/null
+++ b/gfx/layers/apz/test/mochitest/helper_override_root.html
@@ -0,0 +1,62 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+ <meta charset="utf-8">
+ <meta name="viewport" content="width=device-width; initial-scale=1.0">
+ <title>Simple wheel scroll cancellation</title>
+ <script type="application/javascript" src="apz_test_native_event_utils.js"></script>
+ <script type="application/javascript" src="apz_test_utils.js"></script>
+ <script src="/tests/SimpleTest/paint_listener.js"></script>
+ <script type="application/javascript">
+
+async function test() {
+ let wheelEventPromise = new Promise(resolve => {
+ // Add a non-passive listener on the document, so that we have a document-level
+ // APZ-aware listener, and the entire document is put in the dispatch-to-content
+ // region
+ document.addEventListener("wheel", function(e) {
+ // spin for 2 seconds to give APZ time to scroll, if the event region override
+ // is broken and it decides not to wait for the main thread. Note that it's
+ // possible the APZ controller thread is busy for whatever reason so APZ
+ // may not scroll. That might cause this test to only fail intermittently
+ // instead of consistently if the behaviour being tested regresses.
+ var now = Date.now();
+ while (Date.now() - now < 2000);
+
+ // Cancel the scroll. If this works then we know APZ waited for this listener
+ // to run.
+ e.preventDefault();
+ resolve()
+ }, { passive: false });
+ });
+
+ // Ensure APZ gets a paint with the d-t-c region
+ await promiseApzFlushedRepaints();
+
+ await synthesizeNativeWheel(document.body, 100, 100, 0, -50);
+ dump("Finished native wheel, waiting for listener to run...\n");
+
+ await wheelEventPromise;
+ await promiseOnlyApzControllerFlushed();
+
+ is(window.scrollY, 0, "check that the window didn't scroll");
+}
+
+if (window.top != window) {
+ dump("Running inside an iframe! stealing functions from window.top...\n");
+ window.subtestDone = window.top.subtestDone;
+ window.SimpleTest = window.top.SimpleTest;
+ window.is = window.top.is;
+ window.ok = window.top.ok;
+}
+
+waitUntilApzStable()
+ .then(test)
+ .then(subtestDone);
+
+ </script>
+</head>
+<body style="height: 5000px; background-image: linear-gradient(green,red);">
+ This page should not be wheel-scrollable.
+</body>
+</html>