browser_ctrl_click_panel_opening.js (2214B)
1 /* Any copyright is dedicated to the Public Domain. 2 * http://creativecommons.org/publicdomain/zero/1.0/ */ 3 4 "use strict"; 5 6 add_task(async function test_appMenu_mainView() { 7 // On macOS, ctrl-click shouldn't open the panel because this normally opens 8 // the context menu. This happens via the `contextmenu` event which is created 9 // by widget code, so our simulated clicks do not do so, so we can't test 10 // anything on macOS: 11 if (AppConstants.platform == "macosx") { 12 ok(true, "The test is ignored on Mac"); 13 return; 14 } 15 16 let mainViewID = "appMenu-mainView"; 17 const mainView = PanelMultiView.getViewNode(document, mainViewID); 18 19 let shownPromise = BrowserTestUtils.waitForEvent(mainView, "ViewShown"); 20 // Should still open the panel when Ctrl key is pressed. 21 EventUtils.synthesizeMouseAtCenter(PanelUI.menuButton, { ctrlKey: true }); 22 await shownPromise; 23 ok(true, "Main menu shown after button pressed"); 24 25 // Close the main panel. 26 let hiddenPromise = BrowserTestUtils.waitForEvent(document, "popuphidden"); 27 mainView.closest("panel").hidePopup(); 28 await hiddenPromise; 29 }); 30 31 add_task(async function test_appMenu_libraryView() { 32 // On macOS, ctrl-click shouldn't open the panel because this normally opens 33 // the context menu. This happens via the `contextmenu` event which is created 34 // by widget code, so our simulated clicks do not do so, so we can't test 35 // anything on macOS: 36 if (AppConstants.platform == "macosx") { 37 ok(true, "The test is ignored on Mac"); 38 return; 39 } 40 41 CustomizableUI.addWidgetToArea("library-button", "nav-bar"); 42 const button = document.getElementById("library-button"); 43 await waitForElementShown(button); 44 45 // Should still open the panel when Ctrl key is pressed. 46 EventUtils.synthesizeMouseAtCenter(button, { ctrlKey: true }); 47 const libraryView = document.getElementById("appMenu-libraryView"); 48 let shownPromise = BrowserTestUtils.waitForEvent(libraryView, "ViewShown"); 49 await shownPromise; 50 ok(true, "Library menu shown after button pressed"); 51 52 // Close the Library panel. 53 let hiddenPromise = BrowserTestUtils.waitForEvent(document, "popuphidden"); 54 libraryView.closest("panel").hidePopup(); 55 await hiddenPromise; 56 });