diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
commit | 26a029d407be480d791972afb5975cf62c9360a6 (patch) | |
tree | f435a8308119effd964b339f76abb83a57c29483 /dom/base/test/file_suppressed_events_top.html | |
parent | Initial commit. (diff) | |
download | firefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz firefox-26a029d407be480d791972afb5975cf62c9360a6.zip |
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'dom/base/test/file_suppressed_events_top.html')
-rw-r--r-- | dom/base/test/file_suppressed_events_top.html | 79 |
1 files changed, 79 insertions, 0 deletions
diff --git a/dom/base/test/file_suppressed_events_top.html b/dom/base/test/file_suppressed_events_top.html new file mode 100644 index 0000000000..ca031abb70 --- /dev/null +++ b/dom/base/test/file_suppressed_events_top.html @@ -0,0 +1,79 @@ +<!DOCTYPE HTML> +<html> +<head> +<title>Test event suppression</title> +<script src="/tests/SimpleTest/SimpleTest.js"></script> +<script src="/tests/SimpleTest/EventUtils.js"></script> +<script src="/tests/SimpleTest/paint_listener.js"></script> +<script src="/tests/gfx/layers/apz/test/mochitest/apz_test_utils.js"></script> +<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> +</head> +<body> +<div>Top</div> +<script type="application/javascript"> + +function waitForMessage(aMsg, aCallback) { + window.addEventListener("message", function handler(e) { + if (e.data != aMsg) { + return; + } + + info(`received: ${e.data}`); + window.removeEventListener("message", handler); + if (aCallback) { + aCallback(e); + } + }); +} + +function waitForClickEvent(aElement, aWindow) { + return new Promise((aResolve) => { + aElement.addEventListener("click", aResolve, { once: true }); + synthesizeMouseAtCenter(aElement, { type: "mousedown" }, aWindow); + synthesizeMouseAtCenter(aElement, { type: "mouseup" }, aWindow); + }); +} + +waitForMessage("ready", async function(e) { + await waitUntilApzStable(); + + let innerWin = e.source; + let innerDiv = innerWin.document.querySelector("div"); + + let eventCount = 0; + innerDiv.addEventListener("mousemove", function() { + eventCount++; + }); + + // Test that event handling is suppressed. + let utils = SpecialPowers.getDOMWindowUtils(window); + utils.suppressEventHandling(true); + const TOTAL = 100; + for (let i = 0; i < TOTAL; i++) { + synthesizeMouseAtCenter(innerDiv, { type: "mousemove" }, innerWin); + } + utils.suppressEventHandling(false); + + // Wait for click event to ensure we have received all mousemove events. + await waitForClickEvent(innerDiv, innerWin); + opener.info(`eventCount: ${eventCount}`); + opener.ok(eventCount < TOTAL, "event should be suspressed"); + + // Test that event handling is not suppressed. + eventCount = 0; + for (let i = 0; i < TOTAL; i++) { + synthesizeMouseAtCenter(innerDiv, { type: "mousemove" }, innerWin); + } + + // Wait for click event to ensure we have received all mousemove events. + await waitForClickEvent(innerDiv, innerWin); + opener.info(`eventCount: ${eventCount}`); + opener.is(eventCount, TOTAL, "event should not be suspressed"); + + opener.postMessage("done", "*"); +}); + +</script> +<iframe src="http://example.org/tests/dom/base/test/file_suppressed_events_middle.html"></iframe> +</body> +</html> |