2016-04-01 12:49:00 +00: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 09:05:47 +00: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 12:49:00 +00:00
|
|
|
* - checkbox:
|
|
|
|
* If true, the menuitem is prefixed by a checkbox and runtime code can
|
|
|
|
* toggle it.
|
|
|
|
*/
|
|
|
|
|
2018-04-25 10:01:13 +00:00
|
|
|
const { Cu } = require("chrome");
|
|
|
|
|
2016-04-01 12:49:00 +00:00
|
|
|
loader.lazyRequireGetter(
|
|
|
|
this,
|
|
|
|
"gDevToolsBrowser",
|
|
|
|
"devtools/client/framework/devtools-browser",
|
2016-06-09 11:19:09 +00:00
|
|
|
true
|
|
|
|
);
|
|
|
|
loader.lazyRequireGetter(
|
|
|
|
this,
|
|
|
|
"TargetFactory",
|
|
|
|
"devtools/client/framework/target",
|
2017-09-26 23:39:16 +00:00
|
|
|
true
|
|
|
|
);
|
|
|
|
loader.lazyRequireGetter(
|
|
|
|
this,
|
|
|
|
"ResponsiveUIManager",
|
2019-09-11 18:51:35 +00:00
|
|
|
"devtools/client/responsive/manager"
|
2018-06-12 06:42:19 +00:00
|
|
|
);
|
|
|
|
loader.lazyRequireGetter(
|
|
|
|
this,
|
|
|
|
"openDocLink",
|
|
|
|
"devtools/client/shared/link",
|
2019-07-05 09:24:38 +00:00
|
|
|
true
|
|
|
|
);
|
2016-04-01 12:49:00 +00:00
|
|
|
|
|
|
|
loader.lazyImporter(
|
|
|
|
this,
|
2019-11-27 11:08:11 +00:00
|
|
|
"BrowserToolboxLauncher",
|
|
|
|
"resource://devtools/client/framework/browser-toolbox/Launcher.jsm"
|
2016-04-01 12:49:00 +00:00
|
|
|
);
|
2019-05-31 15:54:18 +00:00
|
|
|
loader.lazyImporter(
|
|
|
|
this,
|
|
|
|
"ProfilerMenuButton",
|
2019-10-08 20:48:04 +00:00
|
|
|
"resource://devtools/client/performance-new/popup/menu-button.jsm.js"
|
2019-05-31 15:54:18 +00:00
|
|
|
);
|
2019-09-12 18:20:39 +00:00
|
|
|
loader.lazyRequireGetter(
|
|
|
|
this,
|
|
|
|
"ResponsiveUIManager",
|
|
|
|
"devtools/client/responsive/manager"
|
|
|
|
);
|
2016-04-01 12:49:00 +00:00
|
|
|
|
|
|
|
exports.menuitems = [
|
|
|
|
{
|
|
|
|
id: "menu_devToolbox",
|
|
|
|
l10nKey: "devToolboxMenuItem",
|
2018-08-29 13:14:38 +00: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 12:49:00 +00:00
|
|
|
},
|
2017-07-18 09:05:47 +00:00
|
|
|
keyId: "toggleToolbox",
|
2018-10-19 12:55:39 +00:00
|
|
|
checkbox: true,
|
2016-04-01 12:49:00 +00:00
|
|
|
},
|
|
|
|
{ id: "menu_devtools_separator", separator: true },
|
2019-07-16 16:24:14 +00:00
|
|
|
{
|
|
|
|
id: "menu_devtools_remotedebugging",
|
|
|
|
l10nKey: "devtoolsRemoteDebugging",
|
|
|
|
oncommand(event) {
|
|
|
|
const window = event.target.ownerDocument.defaultView;
|
|
|
|
gDevToolsBrowser.openAboutDebugging(window.gBrowser);
|
|
|
|
},
|
|
|
|
},
|
2016-04-01 12:49:00 +00:00
|
|
|
{
|
|
|
|
id: "menu_browserToolbox",
|
|
|
|
l10nKey: "browserToolboxMenu",
|
|
|
|
oncommand() {
|
2019-11-27 11:08:11 +00:00
|
|
|
BrowserToolboxLauncher.init();
|
2016-04-01 12:49:00 +00:00
|
|
|
},
|
2017-07-18 09:05:47 +00:00
|
|
|
keyId: "browserToolbox",
|
2016-04-01 12:49:00 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
id: "menu_browserContentToolbox",
|
|
|
|
l10nKey: "browserContentToolboxMenu",
|
2016-09-07 13:48:42 +00:00
|
|
|
oncommand(event) {
|
2018-06-01 10:36:09 +00:00
|
|
|
const window = event.target.ownerDocument.defaultView;
|
2016-09-07 13:48:42 +00:00
|
|
|
gDevToolsBrowser.openContentProcessToolbox(window.gBrowser);
|
2018-10-19 12:55:39 +00:00
|
|
|
},
|
2016-04-01 12:49:00 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
id: "menu_browserConsole",
|
|
|
|
l10nKey: "browserConsoleCmd",
|
|
|
|
oncommand() {
|
2019-08-05 11:40:58 +00:00
|
|
|
const {
|
|
|
|
BrowserConsoleManager,
|
|
|
|
} = require("devtools/client/webconsole/browser-console-manager");
|
|
|
|
BrowserConsoleManager.openBrowserConsoleOrFocus();
|
2016-04-01 12:49:00 +00:00
|
|
|
},
|
2017-07-18 09:05:47 +00:00
|
|
|
keyId: "browserConsole",
|
2016-04-01 12:49:00 +00:00
|
|
|
},
|
2019-05-31 15:54:18 +00:00
|
|
|
{
|
|
|
|
id: "menu_toggleProfilerButtonMenu",
|
|
|
|
l10nKey: "toggleProfilerButtonMenu",
|
|
|
|
checkbox: true,
|
|
|
|
oncommand(event) {
|
|
|
|
ProfilerMenuButton.toggle(event.target.ownerDocument);
|
|
|
|
},
|
|
|
|
},
|
2016-04-01 12:49:00 +00:00
|
|
|
{
|
|
|
|
id: "menu_responsiveUI",
|
|
|
|
l10nKey: "responsiveDesignMode",
|
|
|
|
oncommand(event) {
|
2018-06-01 10:36:09 +00:00
|
|
|
const window = event.target.ownerDocument.defaultView;
|
2018-03-13 19:52:34 +00:00
|
|
|
ResponsiveUIManager.toggle(window, window.gBrowser.selectedTab, {
|
2018-10-19 12:55:39 +00:00
|
|
|
trigger: "menu",
|
2018-03-13 19:52:34 +00:00
|
|
|
});
|
2016-04-01 12:49:00 +00:00
|
|
|
},
|
2017-07-18 09:05:47 +00:00
|
|
|
keyId: "responsiveDesignMode",
|
2018-10-19 12:55:39 +00:00
|
|
|
checkbox: true,
|
2016-04-01 12:49:00 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
id: "menu_eyedropper",
|
|
|
|
l10nKey: "eyedropper",
|
2018-08-17 14:55:01 +00:00
|
|
|
async oncommand(event) {
|
2018-06-01 10:36:09 +00:00
|
|
|
const window = event.target.ownerDocument.defaultView;
|
2018-08-21 15:05:21 +00:00
|
|
|
const target = await TargetFactory.forTab(window.gBrowser.selectedTab);
|
2018-09-18 09:10:24 +00:00
|
|
|
await target.attach();
|
2019-08-07 04:17:31 +00:00
|
|
|
const inspectorFront = await target.getFront("inspector");
|
2019-09-12 18:20:39 +00:00
|
|
|
|
|
|
|
// If RDM is active, disable touch simulation events if they're enabled.
|
|
|
|
// Similarly, enable them when the color picker is done picking.
|
|
|
|
if (
|
2019-12-13 10:38:07 +00:00
|
|
|
ResponsiveUIManager.isActiveForTab(target.localTab) &&
|
2020-01-03 18:28:14 +00:00
|
|
|
target.actorHasMethod("responsive", "setElementPickerState")
|
2019-09-12 18:20:39 +00:00
|
|
|
) {
|
2019-12-13 10:38:07 +00:00
|
|
|
const ui = ResponsiveUIManager.getResponsiveUIForTab(target.localTab);
|
2020-01-03 18:28:14 +00:00
|
|
|
await ui.responsiveFront.setElementPickerState(true);
|
2019-09-12 18:20:39 +00:00
|
|
|
|
|
|
|
inspectorFront.once("color-picked", async () => {
|
2020-01-03 18:28:14 +00:00
|
|
|
await ui.responsiveFront.setElementPickerState(false);
|
2019-09-12 18:20:39 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
inspectorFront.once("color-pick-canceled", async () => {
|
2020-01-03 18:28:14 +00:00
|
|
|
await ui.responsiveFront.setElementPickerState(false);
|
2019-09-12 18:20:39 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2018-08-28 13:04:36 +00:00
|
|
|
inspectorFront.pickColorFromPage({ copyOnSelect: true, fromMenu: true });
|
2016-04-01 12:49:00 +00:00
|
|
|
},
|
2018-10-19 12:55:39 +00:00
|
|
|
checkbox: true,
|
2016-04-01 12:49:00 +00:00
|
|
|
},
|
2018-10-19 12:55:39 +00:00
|
|
|
{ separator: true, id: "devToolsEndSeparator" },
|
2016-04-01 12:49:00 +00:00
|
|
|
{
|
|
|
|
id: "getMoreDevtools",
|
|
|
|
l10nKey: "getMoreDevtoolsCmd",
|
|
|
|
oncommand(event) {
|
2018-06-12 06:42:19 +00:00
|
|
|
openDocLink(
|
|
|
|
"https://addons.mozilla.org/firefox/collections/mozilla/webdeveloper/"
|
|
|
|
);
|
2018-10-19 12:55:39 +00:00
|
|
|
},
|
2016-04-01 12:49:00 +00:00
|
|
|
},
|
|
|
|
];
|