1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
8 * This module defines the sorted list of menuitems inserted into the
9 * "Browser Tools" menu.
10 * It also defines the key shortcuts that relates to them.
12 * Various fields are necessary for historical compatiblity with XUL/addons:
14 * used as <xul:menuitem> id attribute
16 * prefix used to locale localization strings from menus.properties
18 * function called when the menu item or key shortcut are fired
20 * Identifier used in devtools/client/devtools-startup.js
21 * Helps figuring out the DOM id for the related <xul:key>
22 * in order to have the key text displayed in menus.
24 * If true, the menuitem is prefixed by a checkbox and runtime code can
29 ChromeUtils.defineESModuleGetters(lazy, {
30 BrowserToolboxLauncher:
31 "resource://devtools/client/framework/browser-toolbox/Launcher.sys.mjs",
34 loader.lazyRequireGetter(this, "flags", "resource://devtools/shared/flags.js");
36 loader.lazyRequireGetter(
39 "resource://devtools/client/framework/devtools-browser.js",
42 loader.lazyRequireGetter(
44 "ResponsiveUIManager",
45 "resource://devtools/client/responsive/manager.js"
47 loader.lazyRequireGetter(
50 "resource://devtools/client/shared/link.js",
53 loader.lazyRequireGetter(
56 "resource://devtools/shared/commands/commands-factory.js",
60 loader.lazyRequireGetter(
63 "resource://devtools/shared/picker-constants.js"
68 id: "menu_devToolbox",
69 l10nKey: "webDeveloperToolsMenu",
72 const window = event.target.ownerDocument.defaultView;
73 gDevToolsBrowser.toggleToolboxCommand(window.gBrowser, Cu.now());
75 console.error(`Exception while opening the toolbox: ${e}\n${e.stack}`);
78 keyId: "toggleToolbox",
82 id: "menu_devtools_remotedebugging",
83 l10nKey: "devtoolsRemoteDebugging",
85 const window = event.target.ownerDocument.defaultView;
86 gDevToolsBrowser.openAboutDebugging(window.gBrowser);
90 id: "menu_browserToolbox",
91 l10nKey: "browserToolboxMenu",
93 lazy.BrowserToolboxLauncher.init();
95 keyId: "browserToolbox",
98 id: "menu_browserConsole",
99 l10nKey: "browserConsoleCmd",
102 BrowserConsoleManager,
103 } = require("resource://devtools/client/webconsole/browser-console-manager.js");
104 BrowserConsoleManager.openBrowserConsoleOrFocus();
106 keyId: "browserConsole",
109 id: "menu_responsiveUI",
110 l10nKey: "responsiveDesignMode",
112 const window = event.target.ownerDocument.defaultView;
113 ResponsiveUIManager.toggle(window, window.gBrowser.selectedTab, {
117 keyId: "responsiveDesignMode",
121 id: "menu_eyedropper",
122 l10nKey: "eyedropper",
123 async oncommand(event) {
124 const window = event.target.ownerDocument.defaultView;
126 // The eyedropper might be used without a toolbox, so it should use a
127 // dedicated commands instance.
129 const commands = await CommandsFactory.forTab(
130 window.gBrowser.selectedTab
132 await commands.targetCommand.startListening();
134 const target = commands.targetCommand.targetFront;
135 const inspectorFront = await target.getFront("inspector");
137 // If RDM is active, disable touch simulation events if they're enabled.
138 // Similarly, enable them when the color picker is done picking.
139 if (ResponsiveUIManager.isActiveForTab(target.localTab)) {
140 const ui = ResponsiveUIManager.getResponsiveUIForTab(target.localTab);
141 await ui.responsiveFront.setElementPickerState(
143 PICKER_TYPES.EYEDROPPER
146 inspectorFront.once("color-picked", async () => {
147 await ui.responsiveFront.setElementPickerState(
149 PICKER_TYPES.EYEDROPPER
153 inspectorFront.once("color-pick-canceled", async () => {
154 await ui.responsiveFront.setElementPickerState(
156 PICKER_TYPES.EYEDROPPER
161 // Destroy the dedicated commands instance when the color picking is
163 inspectorFront.once("color-picked", () => commands.destroy());
164 inspectorFront.once("color-pick-canceled", () => commands.destroy());
166 inspectorFront.pickColorFromPage({ copyOnSelect: true, fromMenu: true });
169 // Used in devtools/client/inspector/test/browser_inspector_eyedropper_ruleview.js
170 Services.obs.notifyObservers(
171 { wrappedJSObject: target },
172 "color-picker-command-handled"
179 id: "extensionsForDevelopers",
180 l10nKey: "extensionsForDevelopersCmd",
181 appMenuL10nId: "appmenu-developer-tools-extensions",
184 "https://addons.mozilla.org/firefox/collections/mozilla/webdeveloper/"