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_bug1638458_contextmenu.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_bug1638458_contextmenu.html')
-rw-r--r-- | gfx/layers/apz/test/mochitest/helper_bug1638458_contextmenu.html | 82 |
1 files changed, 82 insertions, 0 deletions
diff --git a/gfx/layers/apz/test/mochitest/helper_bug1638458_contextmenu.html b/gfx/layers/apz/test/mochitest/helper_bug1638458_contextmenu.html new file mode 100644 index 0000000000..a5a43f7ca1 --- /dev/null +++ b/gfx/layers/apz/test/mochitest/helper_bug1638458_contextmenu.html @@ -0,0 +1,82 @@ +<!DOCTYPE HTML> +<html> +<!-- +https://bugzilla.mozilla.org/show_bug.cgi?id=1638458 +--> +<head> + <meta charset="utf-8"> + <meta name="viewport" content="width=device-width, initial-scale=1.0"> + <title>Test for Bug 1638458</title> + <script src="/tests/SimpleTest/paint_listener.js"></script> + <script src="/tests/SimpleTest/EventUtils.js"></script> + <script type="application/javascript" src="apz_test_native_event_utils.js"></script> + <script type="application/javascript" src="apz_test_utils.js"></script> + <style> + #target { + margin-top: 1000px; + width: 100px; + height: 100px; + } + </style> +</head> +<body> + <div id="target"> + <script type="application/javascript"> + +async function test() { + let utils = SpecialPowers.getDOMWindowUtils(window); + + // Do a large visual scroll to scroll the visual viewport to the bottom + // of the layout viewport. + let visualScrollPromise = new Promise(resolve => { + window.visualViewport.addEventListener("scroll", resolve, { once: true }); + }); + utils.scrollToVisual(0, 900, utils.UPDATE_TYPE_MAIN_THREAD, + utils.SCROLL_MODE_INSTANT); + await visualScrollPromise; + await promiseApzFlushedRepaints(); + + // Simulate a long-tap on the target. We do this by simply synthesizing + // a touch-start event; eventually, the long-tap timeout will be triggered + // and the "contextmenu" will be fired (on non-Windows platforms). + let target = document.getElementById("target"); + let contextmenuEvent = null; + let contextmenuPromise = new Promise(resolve => { + window.addEventListener("contextmenu", function(e) { + contextmenuEvent = e; + // Don't actually open a context menu; it messes up subsequent + // tests unless we take additional action to close it. + e.preventDefault(); + resolve(); + }); + }); + await synthesizeNativeTouch(target, 10, 10, SpecialPowers.DOMWindowUtils.TOUCH_CONTACT); + await contextmenuPromise; + + // Check that the "contextmenu" event targets the correct element. + is(contextmenuEvent.target, target, "contextmenu event targeted the correct element"); + + // Clean up by firing a touch-end to clear the APZ gesture state. + await new Promise(resolve => { + synthesizeNativeTouch(target, 10, 10, SpecialPowers.DOMWindowUtils.TOUCH_REMOVE, + resolve); + }); +} + +if (getPlatform() == "windows") { + // On Windows, contextmenu events work differently (e.g. they are fired + // after the touch-end) which makes them more involved to synthesize. + // We don't gain much value in terms of extra test coverage from running + // this subtest on windows, so just skip it. + ok(true, "Skipping this subtest on windows"); + subtestDone(); +} else { + SpecialPowers.getDOMWindowUtils(window).setResolutionAndScaleTo(2.0); + waitUntilApzStable() + .then(test) + .then(subtestDone, subtestFailed); +} + + </script> +</body> +</html> |