summaryrefslogtreecommitdiffstats
path: root/gfx/layers/apz/test/mochitest/helper_basic_scrollend.html
diff options
context:
space:
mode:
Diffstat (limited to 'gfx/layers/apz/test/mochitest/helper_basic_scrollend.html')
-rw-r--r--gfx/layers/apz/test/mochitest/helper_basic_scrollend.html92
1 files changed, 92 insertions, 0 deletions
diff --git a/gfx/layers/apz/test/mochitest/helper_basic_scrollend.html b/gfx/layers/apz/test/mochitest/helper_basic_scrollend.html
new file mode 100644
index 0000000000..9d71fe6251
--- /dev/null
+++ b/gfx/layers/apz/test/mochitest/helper_basic_scrollend.html
@@ -0,0 +1,92 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <meta charset="utf-8">
+ <script src="apz_test_utils.js"></script>
+ <script src="apz_test_native_event_utils.js"></script>
+ <script src="/tests/SimpleTest/EventUtils.js"></script>
+ <script src="/tests/SimpleTest/paint_listener.js"></script>
+ <style>
+ html, body { margin: 0; }
+
+ body {
+ height: 10000px;
+ }
+ </style>
+ <script>
+const searchParams = new URLSearchParams(location.search);
+
+async function test() {
+ var scrollendCount = 0;
+
+ function onScrollend(e) {
+ scrollendCount += 1;
+ }
+
+ switch (searchParams.get("chrome-only")) {
+ case "true":
+ // Add chrome-only event listener.
+ SpecialPowers.addChromeEventListener("scrollend", onScrollend, true);
+ break;
+ case "false":
+ // Add document event listener.
+ document.addEventListener("scrollend", onScrollend);
+ break;
+ default:
+ ok(false, "Unsupported chrome-only value: " + searchParams.get("chrome-only"));
+ break;
+ }
+
+ is(scrollendCount, 0, "A scrollend event should not be triggered yet");
+
+ await promiseFrame();
+
+ let wheelScrollTransformEndPromise = promiseTransformEnd();
+
+ await promiseMoveMouseAndScrollWheelOver(document.scrollingElement, 100, 100);
+
+ await wheelScrollTransformEndPromise;
+
+ await promiseFrame();
+
+ is(scrollendCount, 1, "A scrollend event should be triggered after user scroll");
+
+ scrollendCount = 0;
+
+ // Call the scrollTo function without behavior: smooth to trigger an instant
+ // programatic scroll.
+ scrollTo({ top: 500, left: 0 });
+
+ // Ensure the refresh driver has ticked.
+ await promiseFrame();
+
+ // A scrollend event should be posted after the refresh driver has ticked.
+ is(scrollendCount, 1, "A scrollend event should be triggered after instant scroll");
+
+ // If smooth scrolls are enabled, repeat the test with a smooth scroll.
+ if (SpecialPowers.getBoolPref("general.smoothScroll")) {
+
+ scrollendCount = 0;
+
+ let smoothScrollTransformEndPromise = promiseTransformEnd();
+
+ // Call the scrollTo function with behavior: smooth to trigger a programmatic
+ // scroll that should require some form of async transform.
+ scrollTo({ top: 1000, left: 0, behavior: "smooth" });
+
+ // Ensure the smooth scroll transform has finished.
+ await smoothScrollTransformEndPromise;
+
+ await promiseFrame();
+
+ is(scrollendCount, 1, "A scrollend event should be triggered after smooth scroll");
+ }
+}
+waitUntilApzStable()
+.then(test)
+.then(subtestDone, subtestFailed);
+ </script>
+</head>
+<body>
+</body>
+</html>