diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
commit | 36d22d82aa202bb199967e9512281e9a53db42c9 (patch) | |
tree | 105e8c98ddea1c1e4784a60a5a6410fa416be2de /gfx/layers/apz/test/mochitest/helper_scrollend_bubbles.html | |
parent | Initial commit. (diff) | |
download | firefox-esr-upstream.tar.xz firefox-esr-upstream.zip |
Adding upstream version 115.7.0esr.upstream/115.7.0esrupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'gfx/layers/apz/test/mochitest/helper_scrollend_bubbles.html')
-rw-r--r-- | gfx/layers/apz/test/mochitest/helper_scrollend_bubbles.html | 99 |
1 files changed, 99 insertions, 0 deletions
diff --git a/gfx/layers/apz/test/mochitest/helper_scrollend_bubbles.html b/gfx/layers/apz/test/mochitest/helper_scrollend_bubbles.html new file mode 100644 index 0000000000..d0d763b474 --- /dev/null +++ b/gfx/layers/apz/test/mochitest/helper_scrollend_bubbles.html @@ -0,0 +1,99 @@ +<!DOCTYPE html> +<html> +<head> + <meta charset="utf-8"> + <script src="apz_test_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; + } + + #container { + height: 500px; + width: 500px; + overflow: scroll; + } + + .spacer { + height: 5000px; + width: 100%; + } + </style> + <script> +const searchParams = new URLSearchParams(location.search); + +async function test() { + let scrollendCount = 0; + + // When scrollend is fired at the document, the document and + // window event listeners should be fired. + let expectedScrollendCount = 2; + let scrollTarget = document.scrollingElement; + + // The scrollend event should not bubble if the target is not Document. + function onElementScrollend(e) { + scrollendCount += 1; + is(e.bubbles, false, "Event bubbles should be false for Element"); + } + + // The scrollend event should bubble if the target is Document. + function onDocumentScrollend(e) { + scrollendCount += 1; + is(e.bubbles, true, "Event bubbles should be true for Document"); + } + + function failOnScrollend(e) { + ok(false, e.target + ": should not receive a scrollend event"); + } + + switch (searchParams.get("scroll-target")) { + case "document": + // The window and the document event listeners should be triggered. + document.addEventListener("scrollend", onDocumentScrollend); + window.addEventListener("scrollend", onDocumentScrollend); + + // Fail if the element receives a scrollend event. + container.addEventListener("scrollend", failOnScrollend); + break; + case "element": + scrollTarget = document.getElementById("container"); + expectedScrollendCount = 1; + + // Only the the element event listener should be triggered. + container.addEventListener("scrollend", onElementScrollend); + + // Fail if the document or window receive a scrollend event. + document.addEventListener("scrollend", failOnScrollend); + window.addEventListener("scrollend", failOnScrollend); + break; + default: + ok(false, "Unsupported scroll-target: " + searchParams.get("scroll-target")); + break; + } + + // Call the scrollTo function on the target to trigger the scrollend. + scrollTarget.scrollBy({ 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, expectedScrollendCount, + "Trigger the expected number of scrollend events"); +} +waitUntilApzStable() +.then(test) +.then(subtestDone, subtestFailed); + </script> +</head> +<body> + <div id="container"> + <div class="spacer"> + </div> + </div> +</body> +</html> |