summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/uievents/click/contextmenu_event.html
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 09:22:09 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 09:22:09 +0000
commit43a97878ce14b72f0981164f87f2e35e14151312 (patch)
tree620249daf56c0258faa40cbdcf9cfba06de2a846 /testing/web-platform/tests/uievents/click/contextmenu_event.html
parentInitial commit. (diff)
downloadfirefox-43a97878ce14b72f0981164f87f2e35e14151312.tar.xz
firefox-43a97878ce14b72f0981164f87f2e35e14151312.zip
Adding upstream version 110.0.1.upstream/110.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/uievents/click/contextmenu_event.html')
-rw-r--r--testing/web-platform/tests/uievents/click/contextmenu_event.html51
1 files changed, 51 insertions, 0 deletions
diff --git a/testing/web-platform/tests/uievents/click/contextmenu_event.html b/testing/web-platform/tests/uievents/click/contextmenu_event.html
new file mode 100644
index 0000000000..7a33d0aa38
--- /dev/null
+++ b/testing/web-platform/tests/uievents/click/contextmenu_event.html
@@ -0,0 +1,51 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <meta charset="utf-8">
+ <title>Contextmenu event</title>
+ <script src="/resources/testharness.js"></script>
+ <script src="/resources/testharnessreport.js"></script>
+ <script src="/resources/testdriver.js"></script>
+ <script src="/resources/testdriver-actions.js"></script>
+ <script src="/resources/testdriver-vendor.js"></script>
+</head>
+<body>
+ <h1>Test contextmenu event</h1>
+ <p>Tests that right-clicking fires a contextmenu event.</p>
+ <ol id="instructions">
+ <li>Right-click here.
+ </ol>
+ <script>
+ let event_log = [];
+
+ function cancel_and_log_event(ename) {
+ return new Promise(resolve => {
+ document.body.addEventListener(ename, e => {
+ e.preventDefault();
+ event_log.push(e.type);
+ resolve(e);
+ }, {once: true});
+ });
+ }
+
+ promise_test(async () => {
+ const event_promises = ["mousedown", "mouseup", "contextmenu"]
+ .map(ename => cancel_and_log_event(ename));
+
+ let target = document.getElementById("instructions");
+ let actions = new test_driver.Actions();
+ actions.pointerMove(0, 0, {origin: target})
+ .pointerDown({button: actions.ButtonType.RIGHT})
+ .pointerUp({button: actions.ButtonType.RIGHT})
+ .send();
+
+ await Promise.all(event_promises);
+
+ assert_equals(event_log.length, 3, "Three events are received");
+ assert_true(event_log.includes("contextmenu"), "contextmenu event is received");
+ assert_true(event_log.includes("mouseup"), "mouseup event is received");
+ assert_equals(event_log[0], "mousedown", "mousedown event is the first event received");
+ }, "Test contextmenu dispatched after mousedown");
+ </script>
+</body>
+</html>