1 /* -*- indent-tabs-mode: nil; js-indent-level: 2 -*-
2 * This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 /* eslint-env mozilla/browser-window */
8 document.addEventListener(
11 let mainMenuBar = document.getElementById("main-menubar");
13 mainMenuBar.addEventListener("command", event => {
14 switch (event.target.id) {
16 case "menu_preferences":
17 openPreferences(undefined);
21 case "menu_pageStyleNoStyle":
22 gPageStyleMenu.disableStyle();
24 case "menu_pageStylePersistentOnly":
25 gPageStyleMenu.switchStyleSheet(null);
27 case "repair-text-encoding":
28 BrowserCommands.forceEncodingDetection();
30 case "documentDirection-swap":
31 gBrowser.selectedBrowser.sendMessageToActor(
32 "SwitchDocumentDirection",
34 "SwitchDocumentDirection",
40 case "sync-tabs-menuitem":
41 gSync.openSyncedTabsPanel();
43 case "hiddenTabsMenu":
44 gTabsPanel.showHiddenTabsPanel(event, "hidden-tabs-menuitem");
47 gSync.openPrefs("menubar");
50 gSync.openPrefs("menubar");
52 case "sync-unverifieditem":
53 gSync.openPrefs("menubar");
55 case "sync-syncnowitem":
58 case "sync-reauthitem":
59 gSync.openSignInAgainPage("menubar");
61 case "menu_openFirefoxView":
62 FirefoxViewHandler.openTab();
65 // == menu_HelpPopup ==
66 // (Duplicated in PanelUI._onHelpCommand)
68 openHelpLink("firefox-help");
70 case "menu_layout_debugger":
73 "chrome://layoutdebug/content/layoutdebug.xhtml"
82 case "troubleShooting":
83 openTroubleshootingPage();
85 case "help_reportSiteIssue":
88 case "menu_HelpPopup_reportPhishingtoolmenu":
89 openUILink(gSafeBrowsing.getReportURL("Phish"), event, {
91 Services.scriptSecurityManager.createNullPrincipal({}),
94 case "menu_HelpPopup_reportPhishingErrortoolmenu":
95 ReportFalseDeceptiveSite();
97 case "helpSwitchDevice":
98 openSwitchingDevicesPage();
103 case "helpPolicySupport":
104 openTrustedLinkIn(Services.policies.getSupportMenu().URL.href, "tab");
110 .getElementById("historyMenuPopup")
111 .addEventListener("command", event => {
112 // Handle commands/clicks on the descending menuitems that are
114 let historyMenu = document.getElementById("history-menu");
115 historyMenu._placesView._onCommand(event);
118 mainMenuBar.addEventListener("popupshowing", event => {
119 // On macOS, we don't track whether activation of the native menubar happened
120 // with the keyboard.
121 if (AppConstants.platform != "macosx") {
122 // We only set the "openedwithkey" if a specific menu like "Edit" was opened
123 // instead of the general menu bar. (e.g. Alt+E instead of just Alt)
124 if (event.target.parentNode.parentNode == this) {
127 event.target.parentNode.openedWithKey
132 switch (event.target.id) {
133 case "menu_FilePopup":
134 gFileMenu.onPopupShowing(event);
136 case "menu_newUserContextPopup":
137 createUserContextMenu(event);
139 case "menu_EditPopup":
140 updateEditUIVisibility();
142 case "view-menu-popup":
143 onViewToolbarsPopupShowing(event);
145 case "pageStyleMenuPopup":
146 gPageStyleMenu.fillPopup(event.target);
148 case "historyMenuPopup":
149 if (!event.target.parentNode._placesView) {
150 new HistoryMenu(event);
153 case "historyUndoPopup":
155 .getElementById("history-menu")
156 ._placesView.populateUndoSubmenu();
158 case "historyUndoWindowPopup":
160 .getElementById("history-menu")
161 ._placesView.populateUndoWindowSubmenu();
163 case "bookmarksMenuPopup":
164 BookmarkingUI.onMainMenuPopupShowing(event);
165 if (!event.target.parentNode._placesView) {
168 `place:parent=${PlacesUtils.bookmarks.menuGuid}`
172 case "bookmarksToolbarFolderPopup":
173 if (!event.target.parentNode._placesView) {
176 `place:parent=${PlacesUtils.bookmarks.toolbarGuid}`
180 case "otherBookmarksFolderPopup":
181 if (!event.target.parentNode._placesView) {
184 `place:parent=${PlacesUtils.bookmarks.unfiledGuid}`
188 case "mobileBookmarksFolderPopup":
189 if (!event.target.parentNode._placesView) {
192 `place:parent=${PlacesUtils.bookmarks.mobileGuid}`
196 case "menu_HelpPopup":
203 .getElementById("menu_EditPopup")
204 .addEventListener("popuphidden", () => {
205 updateEditUIVisibility();