2016-04-01 15:49:00 +03:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This module defines the sorted list of menuitems inserted into the
|
|
|
|
* "Web Developer" menu.
|
|
|
|
* It also defines the key shortcuts that relates to them.
|
|
|
|
*
|
|
|
|
* Various fields are necessary for historical compatiblity with XUL/addons:
|
|
|
|
* - id:
|
|
|
|
* used as <xul:menuitem> id attribute
|
|
|
|
* - l10nKey:
|
|
|
|
* prefix used to locale localization strings from menus.properties
|
|
|
|
* - oncommand:
|
|
|
|
* function called when the menu item or key shortcut are fired
|
2017-07-18 12:05:47 +03:00
|
|
|
* - keyId:
|
|
|
|
* Identifier used in devtools/client/devtools-startup.js
|
|
|
|
* Helps figuring out the DOM id for the related <xul:key>
|
|
|
|
* in order to have the key text displayed in menus.
|
2016-04-01 15:49:00 +03:00
|
|
|
* - disabled:
|
|
|
|
* If true, the menuitem and key shortcut are going to be hidden and disabled
|
|
|
|
* on startup, until some runtime code eventually enable them.
|
|
|
|
* - checkbox:
|
|
|
|
* If true, the menuitem is prefixed by a checkbox and runtime code can
|
|
|
|
* toggle it.
|
|
|
|
*/
|
|
|
|
|
2018-04-25 13:01:13 +03:00
|
|
|
const { Cu } = require("chrome");
|
|
|
|
|
2016-04-01 15:49:00 +03:00
|
|
|
loader.lazyRequireGetter(this, "gDevToolsBrowser", "devtools/client/framework/devtools-browser", true);
|
2016-06-09 14:19:09 +03:00
|
|
|
loader.lazyRequireGetter(this, "TargetFactory", "devtools/client/framework/target", true);
|
2017-09-27 02:39:16 +03:00
|
|
|
loader.lazyRequireGetter(this, "ResponsiveUIManager", "devtools/client/responsive.html/manager", true);
|
2018-06-12 09:42:19 +03:00
|
|
|
loader.lazyRequireGetter(this, "openDocLink", "devtools/client/shared/link", true);
|
2016-04-01 15:49:00 +03:00
|
|
|
|
|
|
|
loader.lazyImporter(this, "BrowserToolboxProcess", "resource://devtools/client/framework/ToolboxProcess.jsm");
|
|
|
|
loader.lazyImporter(this, "ScratchpadManager", "resource://devtools/client/scratchpad/scratchpad-manager.jsm");
|
|
|
|
|
|
|
|
exports.menuitems = [
|
|
|
|
{ id: "menu_devToolbox",
|
|
|
|
l10nKey: "devToolboxMenuItem",
|
2018-08-29 16:14:38 +03:00
|
|
|
async oncommand(event) {
|
|
|
|
try {
|
|
|
|
const window = event.target.ownerDocument.defaultView;
|
|
|
|
await gDevToolsBrowser.toggleToolboxCommand(window.gBrowser, Cu.now());
|
|
|
|
} catch (e) {
|
|
|
|
console.error(`Exception while opening the toolbox: ${e}\n${e.stack}`);
|
|
|
|
}
|
2016-04-01 15:49:00 +03:00
|
|
|
},
|
2017-07-18 12:05:47 +03:00
|
|
|
keyId: "toggleToolbox",
|
2018-10-19 15:55:39 +03:00
|
|
|
checkbox: true,
|
2016-04-01 15:49:00 +03:00
|
|
|
},
|
|
|
|
{ id: "menu_devtools_separator",
|
|
|
|
separator: true },
|
2019-05-03 14:41:24 +03:00
|
|
|
{ id: "menu_devtools_remotedebugging",
|
|
|
|
l10nKey: "devtoolsRemoteDebugging",
|
|
|
|
disabled: true,
|
|
|
|
oncommand(event) {
|
|
|
|
const window = event.target.ownerDocument.defaultView;
|
|
|
|
gDevToolsBrowser.openAboutDebugging(window.gBrowser);
|
|
|
|
},
|
|
|
|
},
|
2016-04-01 15:49:00 +03:00
|
|
|
{ id: "menu_webide",
|
|
|
|
l10nKey: "webide",
|
|
|
|
disabled: true,
|
|
|
|
oncommand() {
|
|
|
|
gDevToolsBrowser.openWebIDE();
|
|
|
|
},
|
2017-07-18 12:05:47 +03:00
|
|
|
keyId: "webide",
|
2016-04-01 15:49:00 +03:00
|
|
|
},
|
|
|
|
{ id: "menu_browserToolbox",
|
|
|
|
l10nKey: "browserToolboxMenu",
|
|
|
|
disabled: true,
|
|
|
|
oncommand() {
|
|
|
|
BrowserToolboxProcess.init();
|
|
|
|
},
|
2017-07-18 12:05:47 +03:00
|
|
|
keyId: "browserToolbox",
|
2016-04-01 15:49:00 +03:00
|
|
|
},
|
|
|
|
{ id: "menu_browserContentToolbox",
|
|
|
|
l10nKey: "browserContentToolboxMenu",
|
|
|
|
disabled: true,
|
2016-09-07 16:48:42 +03:00
|
|
|
oncommand(event) {
|
2018-06-01 13:36:09 +03:00
|
|
|
const window = event.target.ownerDocument.defaultView;
|
2016-09-07 16:48:42 +03:00
|
|
|
gDevToolsBrowser.openContentProcessToolbox(window.gBrowser);
|
2018-10-19 15:55:39 +03:00
|
|
|
},
|
2016-04-01 15:49:00 +03:00
|
|
|
},
|
|
|
|
{ id: "menu_browserConsole",
|
|
|
|
l10nKey: "browserConsoleCmd",
|
|
|
|
oncommand() {
|
2018-06-01 13:36:09 +03:00
|
|
|
const {HUDService} = require("devtools/client/webconsole/hudservice");
|
2016-04-01 15:49:00 +03:00
|
|
|
HUDService.openBrowserConsoleOrFocus();
|
|
|
|
},
|
2017-07-18 12:05:47 +03:00
|
|
|
keyId: "browserConsole",
|
2016-04-01 15:49:00 +03:00
|
|
|
},
|
|
|
|
{ id: "menu_responsiveUI",
|
|
|
|
l10nKey: "responsiveDesignMode",
|
|
|
|
oncommand(event) {
|
2018-06-01 13:36:09 +03:00
|
|
|
const window = event.target.ownerDocument.defaultView;
|
2018-03-13 22:52:34 +03:00
|
|
|
ResponsiveUIManager.toggle(window, window.gBrowser.selectedTab, {
|
2018-10-19 15:55:39 +03:00
|
|
|
trigger: "menu",
|
2018-03-13 22:52:34 +03:00
|
|
|
});
|
2016-04-01 15:49:00 +03:00
|
|
|
},
|
2017-07-18 12:05:47 +03:00
|
|
|
keyId: "responsiveDesignMode",
|
2018-10-19 15:55:39 +03:00
|
|
|
checkbox: true,
|
2016-04-01 15:49:00 +03:00
|
|
|
},
|
|
|
|
{ id: "menu_eyedropper",
|
|
|
|
l10nKey: "eyedropper",
|
2018-08-17 17:55:01 +03:00
|
|
|
async oncommand(event) {
|
2018-06-01 13:36:09 +03:00
|
|
|
const window = event.target.ownerDocument.defaultView;
|
2018-08-21 18:05:21 +03:00
|
|
|
const target = await TargetFactory.forTab(window.gBrowser.selectedTab);
|
2018-09-18 12:10:24 +03:00
|
|
|
await target.attach();
|
2018-10-05 11:39:47 +03:00
|
|
|
// Temporary fix for bug #1493131 - inspector has a different life cycle
|
|
|
|
// than most other fronts because it is closely related to the toolbox.
|
|
|
|
// TODO: replace with getFront once inspector is separated from the toolbox
|
|
|
|
const inspectorFront = await target.getInspector();
|
2018-08-28 16:04:36 +03:00
|
|
|
inspectorFront.pickColorFromPage({copyOnSelect: true, fromMenu: true});
|
2016-04-01 15:49:00 +03:00
|
|
|
},
|
2018-10-19 15:55:39 +03:00
|
|
|
checkbox: true,
|
2016-04-01 15:49:00 +03:00
|
|
|
},
|
|
|
|
{ id: "menu_scratchpad",
|
|
|
|
l10nKey: "scratchpad",
|
|
|
|
oncommand() {
|
|
|
|
ScratchpadManager.openScratchpad();
|
|
|
|
},
|
2017-07-18 12:05:47 +03:00
|
|
|
keyId: "scratchpad",
|
2016-04-01 15:49:00 +03:00
|
|
|
},
|
|
|
|
{ id: "menu_devtools_connect",
|
|
|
|
l10nKey: "devtoolsConnect",
|
|
|
|
disabled: true,
|
|
|
|
oncommand(event) {
|
2018-06-01 13:36:09 +03:00
|
|
|
const window = event.target.ownerDocument.defaultView;
|
2016-04-01 15:49:00 +03:00
|
|
|
gDevToolsBrowser.openConnectScreen(window.gBrowser);
|
2018-10-19 15:55:39 +03:00
|
|
|
},
|
2016-04-01 15:49:00 +03:00
|
|
|
},
|
|
|
|
{ separator: true,
|
2018-10-19 15:55:39 +03:00
|
|
|
id: "devToolsEndSeparator",
|
2016-04-01 15:49:00 +03:00
|
|
|
},
|
|
|
|
{ id: "getMoreDevtools",
|
|
|
|
l10nKey: "getMoreDevtoolsCmd",
|
|
|
|
oncommand(event) {
|
2018-06-12 09:42:19 +03:00
|
|
|
openDocLink("https://addons.mozilla.org/firefox/collections/mozilla/webdeveloper/");
|
2018-10-19 15:55:39 +03:00
|
|
|
},
|
2016-04-01 15:49:00 +03:00
|
|
|
},
|
|
|
|
];
|