summaryrefslogtreecommitdiffstats
path: root/layout/xul/test/test_menuitem_ctrl_click.xhtml
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
commit26a029d407be480d791972afb5975cf62c9360a6 (patch)
treef435a8308119effd964b339f76abb83a57c29483 /layout/xul/test/test_menuitem_ctrl_click.xhtml
parentInitial commit. (diff)
downloadfirefox-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 'layout/xul/test/test_menuitem_ctrl_click.xhtml')
-rw-r--r--layout/xul/test/test_menuitem_ctrl_click.xhtml80
1 files changed, 80 insertions, 0 deletions
diff --git a/layout/xul/test/test_menuitem_ctrl_click.xhtml b/layout/xul/test/test_menuitem_ctrl_click.xhtml
new file mode 100644
index 0000000000..99f7cba7c6
--- /dev/null
+++ b/layout/xul/test/test_menuitem_ctrl_click.xhtml
@@ -0,0 +1,80 @@
+<?xml version="1.0"?>
+<?xml-stylesheet type="text/css" href="chrome://global/skin"?>
+<?xml-stylesheet type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"?>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=1630828
+-->
+<window title="Mozilla Bug 1630828"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
+ onload="">
+<script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
+<script src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"/>
+
+<!-- test results are displayed in the html:body -->
+<body xmlns="http://www.w3.org/1999/xhtml">
+<a href="https://bugzilla.mozilla.org/show_bug.cgi?id=1630828"
+ target="_blank">Mozilla Bug 1630828</a>
+</body>
+
+<hbox align="center" pack="center">
+ <menulist id="menu">
+ <menupopup id="popup">
+ <menuitem label="Target" id="target" />
+ </menupopup>
+ </menulist>
+</hbox>
+<!-- test code goes here -->
+<script type="application/javascript">
+<![CDATA[
+
+const { AppConstants } = SpecialPowers.ChromeUtils.importESModule(
+ "resource://gre/modules/AppConstants.sys.mjs"
+);
+
+function waitForEvent(target, event) {
+ info(`Waiting for ${event} event.`);
+ return new Promise(resolve => {
+ target.addEventListener(event, resolve, { once: true });
+ });
+}
+
+function waitForIdle() {
+ return new Promise(resolve => {
+ SpecialPowers.Services.tm.idleDispatchToMainThread(resolve);
+ });
+}
+
+add_setup(async function() {
+ await SimpleTest.promiseFocus();
+});
+
+add_task(async function test_ctrl_click() {
+ const isMac = AppConstants.platform === "macosx";
+
+ let popup = document.getElementById("popup");
+ let promise = waitForEvent(popup, "popupshown");
+ let menu = document.getElementById("menu");
+ synthesizeMouseAtCenter(menu, {});
+ // Wait for popup open.
+ await promise;
+
+ let commandReceived = false;
+ menu.addEventListener("command", function(e) {
+ ok(!isMac, `${AppConstants.platform} receives command event`);
+ commandReceived = true;
+ });
+
+ // Ctrl click in Mac won't dispatch command event and close popup, so we wait
+ // for idle instead.
+ promise = isMac ? waitForIdle() : waitForEvent(popup, "popuphidden");
+ let target = document.getElementById("target");
+ synthesizeMouseAtCenter(target, { ctrlKey: true });
+ await promise;
+
+ is(commandReceived, !isMac, `Check command event for ${AppConstants.platform}`);
+ is(popup.state, isMac ? "open" : "closed", `Check popup state for ${AppConstants.platform}`);
+});
+
+]]>
+</script>
+</window>