summaryrefslogtreecommitdiffstats
path: root/browser/components/customizableui/test/browser_ctrl_click_panel_opening.js
diff options
context:
space:
mode:
Diffstat (limited to 'browser/components/customizableui/test/browser_ctrl_click_panel_opening.js')
-rw-r--r--browser/components/customizableui/test/browser_ctrl_click_panel_opening.js56
1 files changed, 56 insertions, 0 deletions
diff --git a/browser/components/customizableui/test/browser_ctrl_click_panel_opening.js b/browser/components/customizableui/test/browser_ctrl_click_panel_opening.js
new file mode 100644
index 0000000000..9377c28950
--- /dev/null
+++ b/browser/components/customizableui/test/browser_ctrl_click_panel_opening.js
@@ -0,0 +1,56 @@
+/* Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/publicdomain/zero/1.0/ */
+
+"use strict";
+
+add_task(async function test_appMenu_mainView() {
+ // On macOS, ctrl-click shouldn't open the panel because this normally opens
+ // the context menu. This happens via the `contextmenu` event which is created
+ // by widget code, so our simulated clicks do not do so, so we can't test
+ // anything on macOS:
+ if (AppConstants.platform == "macosx") {
+ ok(true, "The test is ignored on Mac");
+ return;
+ }
+
+ let mainViewID = "appMenu-protonMainView";
+ const mainView = document.getElementById(mainViewID);
+
+ let shownPromise = BrowserTestUtils.waitForEvent(mainView, "ViewShown");
+ // Should still open the panel when Ctrl key is pressed.
+ EventUtils.synthesizeMouseAtCenter(PanelUI.menuButton, { ctrlKey: true });
+ await shownPromise;
+ ok(true, "Main menu shown after button pressed");
+
+ // Close the main panel.
+ let hiddenPromise = BrowserTestUtils.waitForEvent(document, "popuphidden");
+ mainView.closest("panel").hidePopup();
+ await hiddenPromise;
+});
+
+add_task(async function test_appMenu_libraryView() {
+ // On macOS, ctrl-click shouldn't open the panel because this normally opens
+ // the context menu. This happens via the `contextmenu` event which is created
+ // by widget code, so our simulated clicks do not do so, so we can't test
+ // anything on macOS:
+ if (AppConstants.platform == "macosx") {
+ ok(true, "The test is ignored on Mac");
+ return;
+ }
+
+ CustomizableUI.addWidgetToArea("library-button", "nav-bar");
+ const button = document.getElementById("library-button");
+ await waitForElementShown(button);
+
+ // Should still open the panel when Ctrl key is pressed.
+ EventUtils.synthesizeMouseAtCenter(button, { ctrlKey: true });
+ const libraryView = document.getElementById("appMenu-libraryView");
+ let shownPromise = BrowserTestUtils.waitForEvent(libraryView, "ViewShown");
+ await shownPromise;
+ ok(true, "Library menu shown after button pressed");
+
+ // Close the Library panel.
+ let hiddenPromise = BrowserTestUtils.waitForEvent(document, "popuphidden");
+ libraryView.closest("panel").hidePopup();
+ await hiddenPromise;
+});