2015-04-23 12:24:49 +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";
|
|
|
|
|
2016-02-27 15:51:10 +03:00
|
|
|
const Services = require("Services");
|
2016-07-14 21:48:47 +03:00
|
|
|
const osString = Services.appinfo.OS;
|
2015-04-23 12:24:49 +03:00
|
|
|
|
|
|
|
// Panels
|
2015-09-21 20:04:18 +03:00
|
|
|
loader.lazyGetter(
|
|
|
|
this,
|
|
|
|
"OptionsPanel",
|
|
|
|
() => require("devtools/client/framework/toolbox-options").OptionsPanel
|
|
|
|
);
|
2016-09-29 20:02:28 +03:00
|
|
|
loader.lazyGetter(
|
|
|
|
this,
|
|
|
|
"InspectorPanel",
|
|
|
|
() => require("devtools/client/inspector/panel").InspectorPanel
|
|
|
|
);
|
2015-09-21 20:04:18 +03:00
|
|
|
loader.lazyGetter(
|
|
|
|
this,
|
|
|
|
"WebConsolePanel",
|
|
|
|
() => require("devtools/client/webconsole/panel").WebConsolePanel
|
|
|
|
);
|
2019-04-26 15:24:57 +03:00
|
|
|
loader.lazyGetter(
|
|
|
|
this,
|
|
|
|
"DebuggerPanel",
|
|
|
|
() => require("devtools/client/debugger/panel").DebuggerPanel
|
|
|
|
);
|
2018-06-25 22:47:52 +03:00
|
|
|
loader.lazyGetter(
|
|
|
|
this,
|
|
|
|
"StyleEditorPanel",
|
|
|
|
() => require("devtools/client/styleeditor/panel").StyleEditorPanel
|
|
|
|
);
|
2015-09-21 20:04:18 +03:00
|
|
|
loader.lazyGetter(
|
|
|
|
this,
|
|
|
|
"MemoryPanel",
|
|
|
|
() => require("devtools/client/memory/panel").MemoryPanel
|
|
|
|
);
|
|
|
|
loader.lazyGetter(
|
|
|
|
this,
|
|
|
|
"PerformancePanel",
|
|
|
|
() => require("devtools/client/performance/panel").PerformancePanel
|
|
|
|
);
|
2017-11-08 19:36:43 +03:00
|
|
|
loader.lazyGetter(
|
|
|
|
this,
|
|
|
|
"NewPerformancePanel",
|
|
|
|
() => require("devtools/client/performance-new/panel").PerformancePanel
|
|
|
|
);
|
2015-09-21 20:04:18 +03:00
|
|
|
loader.lazyGetter(
|
|
|
|
this,
|
|
|
|
"NetMonitorPanel",
|
|
|
|
() => require("devtools/client/netmonitor/panel").NetMonitorPanel
|
|
|
|
);
|
|
|
|
loader.lazyGetter(
|
|
|
|
this,
|
|
|
|
"StoragePanel",
|
|
|
|
() => require("devtools/client/storage/panel").StoragePanel
|
|
|
|
);
|
2018-06-25 22:47:52 +03:00
|
|
|
loader.lazyGetter(
|
|
|
|
this,
|
|
|
|
"DomPanel",
|
|
|
|
() => require("devtools/client/dom/panel").DomPanel
|
|
|
|
);
|
|
|
|
loader.lazyGetter(
|
|
|
|
this,
|
|
|
|
"AccessibilityPanel",
|
|
|
|
() => require("devtools/client/accessibility/panel").AccessibilityPanel
|
|
|
|
);
|
2018-03-14 23:21:02 +03:00
|
|
|
loader.lazyGetter(
|
|
|
|
this,
|
|
|
|
"ApplicationPanel",
|
|
|
|
() => require("devtools/client/application/panel").ApplicationPanel
|
|
|
|
);
|
2015-04-23 12:24:49 +03:00
|
|
|
|
2017-01-05 21:27:31 +03:00
|
|
|
// Other dependencies
|
2017-09-27 02:39:16 +03:00
|
|
|
loader.lazyRequireGetter(
|
|
|
|
this,
|
|
|
|
"ResponsiveUIManager",
|
2019-09-11 21:51:35 +03:00
|
|
|
"devtools/client/responsive/manager"
|
2017-01-05 21:27:31 +03:00
|
|
|
);
|
|
|
|
|
2019-10-10 16:00:03 +03:00
|
|
|
loader.lazyRequireGetter(
|
|
|
|
this,
|
|
|
|
"AppConstants",
|
|
|
|
"resource://gre/modules/AppConstants.jsm",
|
|
|
|
true
|
|
|
|
);
|
|
|
|
loader.lazyRequireGetter(
|
|
|
|
this,
|
|
|
|
"DevToolsFissionPrefs",
|
|
|
|
"devtools/client/devtools-fission-prefs"
|
|
|
|
);
|
|
|
|
|
2017-07-18 12:05:47 +03:00
|
|
|
const { MultiLocalizationHelper } = require("devtools/shared/l10n");
|
|
|
|
const L10N = new MultiLocalizationHelper(
|
|
|
|
"devtools/client/locales/startup.properties",
|
2018-03-12 16:41:48 +03:00
|
|
|
"devtools/startup/locales/key-shortcuts.properties"
|
2017-07-18 12:05:47 +03:00
|
|
|
);
|
2015-04-23 12:24:49 +03:00
|
|
|
|
2015-09-15 21:19:45 +03:00
|
|
|
var Tools = {};
|
2015-04-23 12:24:49 +03:00
|
|
|
exports.Tools = Tools;
|
|
|
|
|
|
|
|
// Definitions
|
|
|
|
Tools.options = {
|
|
|
|
id: "options",
|
|
|
|
ordinal: 0,
|
2020-01-09 13:02:22 +03:00
|
|
|
url: "chrome://devtools/content/framework/toolbox-options.html",
|
2019-01-05 13:53:38 +03:00
|
|
|
icon: "chrome://devtools/skin/images/settings.svg",
|
2015-04-23 12:24:49 +03:00
|
|
|
bgTheme: "theme-body",
|
2016-09-02 18:45:22 +03:00
|
|
|
label: l10n("options.label"),
|
2015-04-23 12:24:49 +03:00
|
|
|
iconOnly: true,
|
2016-09-02 18:45:22 +03:00
|
|
|
panelLabel: l10n("options.panelLabel"),
|
|
|
|
tooltip: l10n("optionsButton.tooltip"),
|
2015-04-23 12:24:49 +03:00
|
|
|
inMenu: false,
|
|
|
|
|
2018-03-12 21:24:38 +03:00
|
|
|
isTargetSupported: function() {
|
2015-04-23 12:24:49 +03:00
|
|
|
return true;
|
|
|
|
},
|
|
|
|
|
2018-03-12 21:24:38 +03:00
|
|
|
build: function(iframeWindow, toolbox) {
|
2015-04-23 12:24:49 +03:00
|
|
|
return new OptionsPanel(iframeWindow, toolbox);
|
|
|
|
},
|
2016-01-26 12:53:45 +03:00
|
|
|
};
|
2015-04-23 12:24:49 +03:00
|
|
|
|
|
|
|
Tools.inspector = {
|
|
|
|
id: "inspector",
|
2016-09-02 18:45:22 +03:00
|
|
|
accesskey: l10n("inspector.accesskey"),
|
2015-04-23 12:24:49 +03:00
|
|
|
ordinal: 1,
|
2015-10-30 21:59:30 +03:00
|
|
|
icon: "chrome://devtools/skin/images/tool-inspector.svg",
|
2018-06-21 21:08:25 +03:00
|
|
|
url: "chrome://devtools/content/inspector/index.xhtml",
|
2016-09-02 18:45:22 +03:00
|
|
|
label: l10n("inspector.label"),
|
|
|
|
panelLabel: l10n("inspector.panelLabel"),
|
2015-06-09 21:07:01 +03:00
|
|
|
get tooltip() {
|
2018-05-23 09:06:14 +03:00
|
|
|
if (osString == "Darwin") {
|
2018-06-01 13:36:09 +03:00
|
|
|
const cmdShiftC = "Cmd+Shift+" + l10n("inspector.commandkey");
|
|
|
|
const cmdOptC = "Cmd+Opt+" + l10n("inspector.commandkey");
|
2018-05-23 09:06:14 +03:00
|
|
|
return l10n("inspector.mac.tooltip", cmdShiftC, cmdOptC);
|
|
|
|
}
|
|
|
|
|
2019-02-18 18:58:59 +03:00
|
|
|
const ctrlShiftC = "Ctrl+Shift+" + l10n("inspector.commandkey");
|
|
|
|
return l10n("inspector.tooltip2", ctrlShiftC);
|
2015-06-09 21:07:01 +03:00
|
|
|
},
|
2015-04-23 12:24:49 +03:00
|
|
|
inMenu: true,
|
|
|
|
|
|
|
|
preventClosingOnKey: true,
|
2019-08-07 05:07:08 +03:00
|
|
|
// preventRaisingOnKey is used to keep the focus on the content window for shortcuts
|
|
|
|
// that trigger the element picker.
|
|
|
|
preventRaisingOnKey: true,
|
2019-08-16 07:48:27 +03:00
|
|
|
onkey: function(panel, toolbox) {
|
|
|
|
toolbox.nodePicker.togglePicker();
|
2016-02-18 19:52:33 +03:00
|
|
|
},
|
2015-04-23 12:24:49 +03:00
|
|
|
|
2018-03-12 21:24:38 +03:00
|
|
|
isTargetSupported: function(target) {
|
2015-04-23 12:24:49 +03:00
|
|
|
return target.hasActor("inspector");
|
|
|
|
},
|
|
|
|
|
2018-03-12 21:24:38 +03:00
|
|
|
build: function(iframeWindow, toolbox) {
|
2015-04-23 12:24:49 +03:00
|
|
|
return new InspectorPanel(iframeWindow, toolbox);
|
|
|
|
},
|
|
|
|
};
|
|
|
|
Tools.webConsole = {
|
|
|
|
id: "webconsole",
|
2016-09-02 18:45:22 +03:00
|
|
|
accesskey: l10n("webConsoleCmd.accesskey"),
|
2015-04-23 12:24:49 +03:00
|
|
|
ordinal: 2,
|
2018-06-21 21:08:25 +03:00
|
|
|
url: "chrome://devtools/content/webconsole/index.html",
|
2015-10-30 21:59:30 +03:00
|
|
|
icon: "chrome://devtools/skin/images/tool-webconsole.svg",
|
2016-09-02 18:45:22 +03:00
|
|
|
label: l10n("ToolboxTabWebconsole.label"),
|
|
|
|
menuLabel: l10n("MenuWebconsole.label"),
|
|
|
|
panelLabel: l10n("ToolboxWebConsole.panelLabel"),
|
2015-06-09 21:07:01 +03:00
|
|
|
get tooltip() {
|
2016-09-02 18:45:22 +03:00
|
|
|
return l10n(
|
|
|
|
"ToolboxWebconsole.tooltip2",
|
2017-07-18 12:05:47 +03:00
|
|
|
(osString == "Darwin" ? "Cmd+Opt+" : "Ctrl+Shift+") +
|
|
|
|
l10n("webconsole.commandkey")
|
|
|
|
);
|
2015-06-09 21:07:01 +03:00
|
|
|
},
|
2015-04-23 12:24:49 +03:00
|
|
|
inMenu: true,
|
|
|
|
|
|
|
|
preventClosingOnKey: true,
|
2018-03-12 21:24:38 +03:00
|
|
|
onkey: function(panel, toolbox) {
|
2016-01-26 12:53:45 +03:00
|
|
|
if (toolbox.splitConsole) {
|
2015-04-23 12:24:49 +03:00
|
|
|
return toolbox.focusConsoleInput();
|
2016-01-26 12:53:45 +03:00
|
|
|
}
|
2015-04-23 12:24:49 +03:00
|
|
|
|
|
|
|
panel.focusInput();
|
2016-04-05 21:31:19 +03:00
|
|
|
return undefined;
|
2015-04-23 12:24:49 +03:00
|
|
|
},
|
|
|
|
|
2018-03-12 21:24:38 +03:00
|
|
|
isTargetSupported: function() {
|
2015-04-23 12:24:49 +03:00
|
|
|
return true;
|
|
|
|
},
|
2018-03-12 21:24:38 +03:00
|
|
|
build: function(iframeWindow, toolbox) {
|
2015-04-23 12:24:49 +03:00
|
|
|
return new WebConsolePanel(iframeWindow, toolbox);
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
Tools.jsdebugger = {
|
|
|
|
id: "jsdebugger",
|
2016-09-02 18:45:22 +03:00
|
|
|
accesskey: l10n("debuggerMenu.accesskey"),
|
2015-04-23 12:24:49 +03:00
|
|
|
ordinal: 3,
|
2015-10-30 21:59:30 +03:00
|
|
|
icon: "chrome://devtools/skin/images/tool-debugger.svg",
|
2019-04-08 17:20:01 +03:00
|
|
|
url: "chrome://devtools/content/debugger/index.html",
|
2016-09-02 18:45:22 +03:00
|
|
|
label: l10n("ToolboxDebugger.label"),
|
|
|
|
panelLabel: l10n("ToolboxDebugger.panelLabel"),
|
2015-06-09 21:07:01 +03:00
|
|
|
get tooltip() {
|
2019-09-09 20:54:53 +03:00
|
|
|
return l10n(
|
|
|
|
"ToolboxDebugger.tooltip4",
|
|
|
|
(osString == "Darwin" ? "Cmd+Opt+" : "Ctrl+Shift+") +
|
2019-10-17 10:29:45 +03:00
|
|
|
l10n("jsdebugger.commandkey2")
|
2019-09-09 20:54:53 +03:00
|
|
|
);
|
2015-06-09 21:07:01 +03:00
|
|
|
},
|
2015-04-23 12:24:49 +03:00
|
|
|
inMenu: true,
|
2018-03-12 21:24:38 +03:00
|
|
|
isTargetSupported: function() {
|
2015-04-23 12:24:49 +03:00
|
|
|
return true;
|
|
|
|
},
|
2018-03-12 21:24:38 +03:00
|
|
|
build: function(iframeWindow, toolbox) {
|
2019-04-26 15:24:57 +03:00
|
|
|
return new DebuggerPanel(iframeWindow, toolbox);
|
2015-04-23 12:24:49 +03:00
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
Tools.styleEditor = {
|
|
|
|
id: "styleeditor",
|
2019-06-26 17:10:38 +03:00
|
|
|
ordinal: 5,
|
2016-06-21 16:13:51 +03:00
|
|
|
visibilityswitch: "devtools.styleeditor.enabled",
|
2016-09-02 18:45:22 +03:00
|
|
|
accesskey: l10n("open.accesskey"),
|
2015-10-30 21:59:30 +03:00
|
|
|
icon: "chrome://devtools/skin/images/tool-styleeditor.svg",
|
2019-11-14 02:44:19 +03:00
|
|
|
url: "chrome://devtools/content/styleeditor/index.xhtml",
|
2016-09-02 18:45:22 +03:00
|
|
|
label: l10n("ToolboxStyleEditor.label"),
|
|
|
|
panelLabel: l10n("ToolboxStyleEditor.panelLabel"),
|
2015-06-09 21:07:01 +03:00
|
|
|
get tooltip() {
|
2016-09-02 18:45:22 +03:00
|
|
|
return l10n(
|
|
|
|
"ToolboxStyleEditor.tooltip3",
|
2017-07-18 12:05:47 +03:00
|
|
|
"Shift+" + functionkey(l10n("styleeditor.commandkey"))
|
|
|
|
);
|
2015-06-09 21:07:01 +03:00
|
|
|
},
|
2015-04-23 12:24:49 +03:00
|
|
|
inMenu: true,
|
2018-03-12 21:24:38 +03:00
|
|
|
isTargetSupported: function(target) {
|
2017-09-12 19:01:14 +03:00
|
|
|
return target.hasActor("styleSheets");
|
2015-04-23 12:24:49 +03:00
|
|
|
},
|
|
|
|
|
2018-03-12 21:24:38 +03:00
|
|
|
build: function(iframeWindow, toolbox) {
|
2015-04-23 12:24:49 +03:00
|
|
|
return new StyleEditorPanel(iframeWindow, toolbox);
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2017-11-28 22:47:41 +03:00
|
|
|
Tools.performance = {
|
2017-11-08 19:36:43 +03:00
|
|
|
id: "performance",
|
2019-06-26 17:10:38 +03:00
|
|
|
ordinal: 6,
|
2017-11-08 19:36:43 +03:00
|
|
|
icon: "chrome://devtools/skin/images/tool-profiler.svg",
|
|
|
|
visibilityswitch: "devtools.performance.enabled",
|
|
|
|
label: l10n("performance.label"),
|
|
|
|
panelLabel: l10n("performance.panelLabel"),
|
|
|
|
get tooltip() {
|
|
|
|
return l10n(
|
|
|
|
"performance.tooltip",
|
|
|
|
"Shift+" + functionkey(l10n("performance.commandkey"))
|
|
|
|
);
|
|
|
|
},
|
|
|
|
accesskey: l10n("performance.accesskey"),
|
|
|
|
inMenu: true,
|
|
|
|
};
|
2017-11-28 22:47:41 +03:00
|
|
|
|
2017-11-08 19:36:43 +03:00
|
|
|
function switchPerformancePanel() {
|
|
|
|
if (
|
|
|
|
Services.prefs.getBoolPref("devtools.performance.new-panel-enabled", false)
|
|
|
|
) {
|
2018-06-21 21:08:25 +03:00
|
|
|
Tools.performance.url =
|
|
|
|
"chrome://devtools/content/performance-new/index.xhtml";
|
2018-03-12 21:24:38 +03:00
|
|
|
Tools.performance.build = function(frame, target) {
|
2017-11-08 19:36:43 +03:00
|
|
|
return new NewPerformancePanel(frame, target);
|
|
|
|
};
|
2018-03-12 21:24:38 +03:00
|
|
|
Tools.performance.isTargetSupported = function(target) {
|
2018-09-28 15:48:05 +03:00
|
|
|
// Root actors are lazily initialized, so we can't check if the target has
|
|
|
|
// the perf actor yet. Also this function is not async, so we can't initialize
|
|
|
|
// the actor yet.
|
|
|
|
// We don't display the new performance panel for remote context in the
|
2019-09-25 20:24:58 +03:00
|
|
|
// toolbox, because this has an overhead. Instead we should use
|
|
|
|
// about:debugging.
|
2018-09-28 15:48:05 +03:00
|
|
|
return target.isLocalTab;
|
2017-11-08 19:36:43 +03:00
|
|
|
};
|
|
|
|
} else {
|
2019-11-14 02:44:19 +03:00
|
|
|
Tools.performance.url = "chrome://devtools/content/performance/index.xhtml";
|
2018-03-12 21:24:38 +03:00
|
|
|
Tools.performance.build = function(frame, target) {
|
2017-11-08 19:36:43 +03:00
|
|
|
return new PerformancePanel(frame, target);
|
|
|
|
};
|
2018-03-12 21:24:38 +03:00
|
|
|
Tools.performance.isTargetSupported = function(target) {
|
2017-11-08 19:36:43 +03:00
|
|
|
return target.hasActor("performance");
|
|
|
|
};
|
2017-11-28 22:47:41 +03:00
|
|
|
}
|
2017-11-08 19:36:43 +03:00
|
|
|
}
|
|
|
|
switchPerformancePanel();
|
|
|
|
|
2020-03-16 15:48:56 +03:00
|
|
|
const prefObserver = { observe: switchPerformancePanel };
|
|
|
|
Services.prefs.addObserver(
|
|
|
|
"devtools.performance.new-panel-enabled",
|
|
|
|
prefObserver
|
|
|
|
);
|
|
|
|
const unloadObserver = function(subject) {
|
|
|
|
if (subject.wrappedJSObject == require("@loader/unload")) {
|
|
|
|
Services.prefs.removeObserver(
|
|
|
|
"devtools.performance.new-panel-enabled",
|
|
|
|
prefObserver
|
|
|
|
);
|
|
|
|
Services.obs.removeObserver(unloadObserver, "devtools:loader:destroy");
|
|
|
|
}
|
|
|
|
};
|
|
|
|
Services.obs.addObserver(unloadObserver, "devtools:loader:destroy");
|
2015-04-23 12:24:49 +03:00
|
|
|
|
2015-08-30 01:49:22 +03:00
|
|
|
Tools.memory = {
|
|
|
|
id: "memory",
|
2019-06-26 17:10:38 +03:00
|
|
|
ordinal: 7,
|
2015-10-30 21:59:30 +03:00
|
|
|
icon: "chrome://devtools/skin/images/tool-memory.svg",
|
2018-06-21 21:08:25 +03:00
|
|
|
url: "chrome://devtools/content/memory/index.xhtml",
|
2015-08-30 01:49:22 +03:00
|
|
|
visibilityswitch: "devtools.memory.enabled",
|
2016-09-02 18:45:22 +03:00
|
|
|
label: l10n("memory.label"),
|
|
|
|
panelLabel: l10n("memory.panelLabel"),
|
|
|
|
tooltip: l10n("memory.tooltip"),
|
2015-08-30 01:49:22 +03:00
|
|
|
|
2018-03-12 21:24:38 +03:00
|
|
|
isTargetSupported: function(target) {
|
2018-11-15 13:23:48 +03:00
|
|
|
return (
|
|
|
|
target.getTrait("heapSnapshots") &&
|
|
|
|
!target.isAddon &&
|
|
|
|
!target.isWorkerTarget
|
|
|
|
);
|
2015-08-30 01:49:22 +03:00
|
|
|
},
|
|
|
|
|
2018-03-12 21:24:38 +03:00
|
|
|
build: function(frame, target) {
|
2015-08-30 01:49:22 +03:00
|
|
|
return new MemoryPanel(frame, target);
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2015-04-23 12:24:49 +03:00
|
|
|
Tools.netMonitor = {
|
|
|
|
id: "netmonitor",
|
2016-09-02 18:45:22 +03:00
|
|
|
accesskey: l10n("netmonitor.accesskey"),
|
2019-06-26 17:10:38 +03:00
|
|
|
ordinal: 4,
|
2015-04-23 12:24:49 +03:00
|
|
|
visibilityswitch: "devtools.netmonitor.enabled",
|
2015-10-30 21:59:30 +03:00
|
|
|
icon: "chrome://devtools/skin/images/tool-network.svg",
|
2017-03-26 16:37:16 +03:00
|
|
|
url: "chrome://devtools/content/netmonitor/index.html",
|
2016-09-02 18:45:22 +03:00
|
|
|
label: l10n("netmonitor.label"),
|
|
|
|
panelLabel: l10n("netmonitor.panelLabel"),
|
2015-06-09 21:07:01 +03:00
|
|
|
get tooltip() {
|
2016-09-02 18:45:22 +03:00
|
|
|
return l10n(
|
|
|
|
"netmonitor.tooltip2",
|
2017-07-18 12:05:47 +03:00
|
|
|
(osString == "Darwin" ? "Cmd+Opt+" : "Ctrl+Shift+") +
|
|
|
|
l10n("netmonitor.commandkey")
|
|
|
|
);
|
2015-06-09 21:07:01 +03:00
|
|
|
},
|
2015-04-23 12:24:49 +03:00
|
|
|
inMenu: true,
|
|
|
|
|
2018-03-12 21:24:38 +03:00
|
|
|
isTargetSupported: function(target) {
|
2018-11-15 13:23:48 +03:00
|
|
|
return target.getTrait("networkMonitor") && !target.isWorkerTarget;
|
2015-04-23 12:24:49 +03:00
|
|
|
},
|
|
|
|
|
2018-03-12 21:24:38 +03:00
|
|
|
build: function(iframeWindow, toolbox) {
|
2015-04-23 12:24:49 +03:00
|
|
|
return new NetMonitorPanel(iframeWindow, toolbox);
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
Tools.storage = {
|
|
|
|
id: "storage",
|
2019-06-26 17:10:38 +03:00
|
|
|
ordinal: 8,
|
2016-09-02 18:45:22 +03:00
|
|
|
accesskey: l10n("storage.accesskey"),
|
2015-04-23 12:24:49 +03:00
|
|
|
visibilityswitch: "devtools.storage.enabled",
|
2015-10-30 21:59:30 +03:00
|
|
|
icon: "chrome://devtools/skin/images/tool-storage.svg",
|
2019-11-14 02:44:19 +03:00
|
|
|
url: "chrome://devtools/content/storage/index.xhtml",
|
2016-09-02 18:45:22 +03:00
|
|
|
label: l10n("storage.label"),
|
|
|
|
menuLabel: l10n("storage.menuLabel"),
|
|
|
|
panelLabel: l10n("storage.panelLabel"),
|
2015-06-09 21:07:01 +03:00
|
|
|
get tooltip() {
|
2017-07-18 12:05:47 +03:00
|
|
|
return l10n(
|
|
|
|
"storage.tooltip3",
|
|
|
|
"Shift+" + functionkey(l10n("storage.commandkey"))
|
|
|
|
);
|
2015-06-09 21:07:01 +03:00
|
|
|
},
|
2015-04-23 12:24:49 +03:00
|
|
|
inMenu: true,
|
|
|
|
|
2018-03-12 21:24:38 +03:00
|
|
|
isTargetSupported: function(target) {
|
2015-04-23 12:24:49 +03:00
|
|
|
return (
|
|
|
|
target.isLocalTab ||
|
2016-01-26 12:53:45 +03:00
|
|
|
(target.hasActor("storage") && target.getTrait("storageInspector"))
|
|
|
|
);
|
2015-04-23 12:24:49 +03:00
|
|
|
},
|
|
|
|
|
2018-03-12 21:24:38 +03:00
|
|
|
build: function(iframeWindow, toolbox) {
|
2015-04-23 12:24:49 +03:00
|
|
|
return new StoragePanel(iframeWindow, toolbox);
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2016-02-10 01:23:29 +03:00
|
|
|
Tools.dom = {
|
|
|
|
id: "dom",
|
2016-09-02 18:45:22 +03:00
|
|
|
accesskey: l10n("dom.accesskey"),
|
2019-06-26 17:10:38 +03:00
|
|
|
ordinal: 11,
|
2016-02-10 01:23:29 +03:00
|
|
|
visibilityswitch: "devtools.dom.enabled",
|
|
|
|
icon: "chrome://devtools/skin/images/tool-dom.svg",
|
2018-06-21 21:08:25 +03:00
|
|
|
url: "chrome://devtools/content/dom/index.html",
|
2016-09-02 18:45:22 +03:00
|
|
|
label: l10n("dom.label"),
|
|
|
|
panelLabel: l10n("dom.panelLabel"),
|
2016-02-10 01:23:29 +03:00
|
|
|
get tooltip() {
|
2016-09-02 18:45:22 +03:00
|
|
|
return l10n(
|
|
|
|
"dom.tooltip",
|
2017-07-18 12:05:47 +03:00
|
|
|
(osString == "Darwin" ? "Cmd+Opt+" : "Ctrl+Shift+") +
|
|
|
|
l10n("dom.commandkey")
|
|
|
|
);
|
2016-02-10 01:23:29 +03:00
|
|
|
},
|
|
|
|
inMenu: true,
|
|
|
|
|
2018-03-12 21:24:38 +03:00
|
|
|
isTargetSupported: function(target) {
|
2020-04-24 17:23:42 +03:00
|
|
|
return true;
|
2016-02-10 01:23:29 +03:00
|
|
|
},
|
|
|
|
|
2018-03-12 21:24:38 +03:00
|
|
|
build: function(iframeWindow, toolbox) {
|
2016-02-10 01:23:29 +03:00
|
|
|
return new DomPanel(iframeWindow, toolbox);
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2018-03-28 18:40:49 +03:00
|
|
|
Tools.accessibility = {
|
|
|
|
id: "accessibility",
|
|
|
|
accesskey: l10n("accessibility.accesskey"),
|
2019-06-26 17:10:38 +03:00
|
|
|
ordinal: 9,
|
2018-03-28 18:40:49 +03:00
|
|
|
modifiers: osString == "Darwin" ? "accel,alt" : "accel,shift",
|
|
|
|
visibilityswitch: "devtools.accessibility.enabled",
|
|
|
|
icon: "chrome://devtools/skin/images/tool-accessibility.svg",
|
2018-06-21 21:08:25 +03:00
|
|
|
url: "chrome://devtools/content/accessibility/index.html",
|
2018-03-28 18:40:49 +03:00
|
|
|
label: l10n("accessibility.label"),
|
|
|
|
panelLabel: l10n("accessibility.panelLabel"),
|
|
|
|
get tooltip() {
|
2018-12-10 23:43:49 +03:00
|
|
|
return l10n(
|
|
|
|
"accessibility.tooltip3",
|
2018-12-12 21:25:41 +03:00
|
|
|
"Shift+" + functionkey(l10n("accessibilityF12.commandkey"))
|
|
|
|
);
|
2018-03-28 18:40:49 +03:00
|
|
|
},
|
|
|
|
inMenu: true,
|
|
|
|
|
|
|
|
isTargetSupported(target) {
|
|
|
|
return target.hasActor("accessibility");
|
|
|
|
},
|
|
|
|
|
|
|
|
build(iframeWindow, toolbox) {
|
2020-07-04 02:52:10 +03:00
|
|
|
return new AccessibilityPanel(iframeWindow, toolbox);
|
2018-03-28 18:40:49 +03:00
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2018-03-14 23:21:02 +03:00
|
|
|
Tools.application = {
|
|
|
|
id: "application",
|
2019-06-26 17:10:38 +03:00
|
|
|
ordinal: 10,
|
2018-03-14 23:21:02 +03:00
|
|
|
visibilityswitch: "devtools.application.enabled",
|
2018-03-21 13:40:56 +03:00
|
|
|
icon: "chrome://devtools/skin/images/tool-application.svg",
|
2018-03-14 23:21:02 +03:00
|
|
|
url: "chrome://devtools/content/application/index.html",
|
2018-06-05 13:48:14 +03:00
|
|
|
label: l10n("application.label"),
|
|
|
|
panelLabel: l10n("application.panellabel"),
|
|
|
|
tooltip: l10n("application.tooltip"),
|
2020-05-26 20:41:23 +03:00
|
|
|
inMenu: true,
|
2018-03-14 23:21:02 +03:00
|
|
|
|
|
|
|
isTargetSupported: function(target) {
|
2019-11-21 01:51:06 +03:00
|
|
|
return target.hasActor("manifest");
|
2018-03-14 23:21:02 +03:00
|
|
|
},
|
|
|
|
|
|
|
|
build: function(iframeWindow, toolbox) {
|
|
|
|
return new ApplicationPanel(iframeWindow, toolbox);
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2015-09-15 21:19:45 +03:00
|
|
|
var defaultTools = [
|
2015-04-23 12:24:49 +03:00
|
|
|
Tools.options,
|
|
|
|
Tools.webConsole,
|
|
|
|
Tools.inspector,
|
|
|
|
Tools.jsdebugger,
|
|
|
|
Tools.styleEditor,
|
|
|
|
Tools.performance,
|
|
|
|
Tools.netMonitor,
|
|
|
|
Tools.storage,
|
2015-08-30 01:49:22 +03:00
|
|
|
Tools.memory,
|
2016-02-10 01:23:29 +03:00
|
|
|
Tools.dom,
|
2018-03-28 18:40:49 +03:00
|
|
|
Tools.accessibility,
|
2018-03-14 23:21:02 +03:00
|
|
|
Tools.application,
|
2015-04-23 12:24:49 +03:00
|
|
|
];
|
|
|
|
|
|
|
|
exports.defaultTools = defaultTools;
|
|
|
|
|
|
|
|
Tools.darkTheme = {
|
|
|
|
id: "dark",
|
2016-09-02 18:45:22 +03:00
|
|
|
label: l10n("options.darkTheme.label2"),
|
2015-04-23 12:24:49 +03:00
|
|
|
ordinal: 1,
|
2015-10-30 21:59:30 +03:00
|
|
|
stylesheets: ["chrome://devtools/skin/dark-theme.css"],
|
2015-04-23 12:24:49 +03:00
|
|
|
classList: ["theme-dark"],
|
|
|
|
};
|
|
|
|
|
|
|
|
Tools.lightTheme = {
|
|
|
|
id: "light",
|
2016-09-02 18:45:22 +03:00
|
|
|
label: l10n("options.lightTheme.label2"),
|
2015-04-23 12:24:49 +03:00
|
|
|
ordinal: 2,
|
2015-10-30 21:59:30 +03:00
|
|
|
stylesheets: ["chrome://devtools/skin/light-theme.css"],
|
2015-04-23 12:24:49 +03:00
|
|
|
classList: ["theme-light"],
|
|
|
|
};
|
|
|
|
|
|
|
|
exports.defaultThemes = [Tools.darkTheme, Tools.lightTheme];
|
|
|
|
|
2020-07-07 20:10:13 +03:00
|
|
|
// List buttons that can be toggled to prevent adding prefs for
|
2016-10-13 00:22:57 +03:00
|
|
|
// addons that have manually inserted toolbarbuttons into DOM.
|
|
|
|
// (By default, supported target is only local tab)
|
|
|
|
exports.ToolboxButtons = [
|
2017-01-05 21:27:31 +03:00
|
|
|
{
|
|
|
|
id: "command-button-paintflashing",
|
|
|
|
description: l10n("toolbox.buttons.paintflashing"),
|
|
|
|
isTargetSupported: target => target.isLocalTab,
|
|
|
|
onClick(event, toolbox) {
|
2018-09-03 17:54:04 +03:00
|
|
|
toolbox.togglePaintFlashing();
|
2017-01-05 21:27:31 +03:00
|
|
|
},
|
2017-03-20 16:54:03 +03:00
|
|
|
isChecked(toolbox) {
|
2018-09-03 17:54:04 +03:00
|
|
|
return toolbox.isPaintFlashing;
|
2017-03-20 16:54:03 +03:00
|
|
|
},
|
2017-01-05 21:27:31 +03:00
|
|
|
},
|
2019-10-10 16:00:03 +03:00
|
|
|
{
|
|
|
|
id: "command-button-fission-prefs",
|
|
|
|
description: "DevTools Fission preferences",
|
|
|
|
isTargetSupported: target => !AppConstants.MOZILLA_OFFICIAL,
|
|
|
|
onClick: (event, toolbox) => DevToolsFissionPrefs.showTooltip(toolbox),
|
|
|
|
isChecked: () => DevToolsFissionPrefs.isAnyPreferenceEnabled(),
|
|
|
|
},
|
2017-01-05 21:27:31 +03:00
|
|
|
{
|
|
|
|
id: "command-button-responsive",
|
|
|
|
description: l10n(
|
|
|
|
"toolbox.buttons.responsive",
|
|
|
|
osString == "Darwin" ? "Cmd+Opt+M" : "Ctrl+Shift+M"
|
|
|
|
),
|
|
|
|
isTargetSupported: target => target.isLocalTab,
|
|
|
|
onClick(event, toolbox) {
|
2019-12-13 13:38:07 +03:00
|
|
|
const tab = toolbox.target.localTab;
|
2018-06-01 13:36:09 +03:00
|
|
|
const browserWindow = tab.ownerDocument.defaultView;
|
2018-09-06 14:42:57 +03:00
|
|
|
ResponsiveUIManager.toggle(browserWindow, tab, { trigger: "toolbox" });
|
2017-01-05 21:27:31 +03:00
|
|
|
},
|
|
|
|
isChecked(toolbox) {
|
2019-12-13 13:38:07 +03:00
|
|
|
if (!toolbox.target.localTab) {
|
2017-01-05 21:27:31 +03:00
|
|
|
return false;
|
|
|
|
}
|
2019-12-13 13:38:07 +03:00
|
|
|
return ResponsiveUIManager.isActiveForTab(toolbox.target.localTab);
|
2017-01-05 21:27:31 +03:00
|
|
|
},
|
|
|
|
setup(toolbox, onChange) {
|
|
|
|
ResponsiveUIManager.on("on", onChange);
|
|
|
|
ResponsiveUIManager.on("off", onChange);
|
|
|
|
},
|
|
|
|
teardown(toolbox, onChange) {
|
|
|
|
ResponsiveUIManager.off("on", onChange);
|
|
|
|
ResponsiveUIManager.off("off", onChange);
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: "command-button-screenshot",
|
|
|
|
description: l10n("toolbox.buttons.screenshot"),
|
2018-08-27 18:14:10 +03:00
|
|
|
isTargetSupported: target =>
|
|
|
|
!target.chrome && target.hasActor("screenshot"),
|
|
|
|
async onClick(event, toolbox) {
|
2017-01-05 21:27:31 +03:00
|
|
|
// Special case for screenshot button to check for clipboard preference
|
|
|
|
const clipboardEnabled = Services.prefs.getBoolPref(
|
|
|
|
"devtools.screenshot.clipboard.enabled"
|
|
|
|
);
|
2018-08-27 18:14:10 +03:00
|
|
|
const args = { fullpage: true, file: true };
|
2017-01-05 21:27:31 +03:00
|
|
|
if (clipboardEnabled) {
|
2018-08-27 18:14:10 +03:00
|
|
|
args.clipboard = true;
|
2017-01-05 21:27:31 +03:00
|
|
|
}
|
2018-11-14 18:11:59 +03:00
|
|
|
const screenshotFront = await toolbox.target.getFront("screenshot");
|
2018-08-27 18:14:10 +03:00
|
|
|
await screenshotFront.captureAndSave(toolbox.win, args);
|
2017-01-05 21:27:31 +03:00
|
|
|
},
|
|
|
|
},
|
2018-09-03 17:54:04 +03:00
|
|
|
createHighlightButton("RulersHighlighter", "rulers"),
|
|
|
|
createHighlightButton("MeasuringToolHighlighter", "measure"),
|
|
|
|
];
|
|
|
|
|
|
|
|
function createHighlightButton(highlighterName, id) {
|
|
|
|
return {
|
|
|
|
id: `command-button-${id}`,
|
|
|
|
description: l10n(`toolbox.buttons.${id}`),
|
|
|
|
isTargetSupported: target => !target.chrome,
|
|
|
|
async onClick(event, toolbox) {
|
2019-08-07 20:46:07 +03:00
|
|
|
const inspectorFront = await toolbox.target.getFront("inspector");
|
|
|
|
const highlighter = await inspectorFront.getOrCreateHighlighterByType(
|
2018-12-18 11:45:30 +03:00
|
|
|
highlighterName
|
|
|
|
);
|
2018-09-03 17:54:04 +03:00
|
|
|
if (highlighter.isShown()) {
|
|
|
|
return highlighter.hide();
|
|
|
|
}
|
|
|
|
// Starting with FF63, higlighter's spec accept a null first argument.
|
|
|
|
// Still pass an empty object to fake a domnode front in order to support old
|
|
|
|
// servers.
|
|
|
|
return highlighter.show({});
|
2017-01-05 21:27:31 +03:00
|
|
|
},
|
2017-03-20 16:54:03 +03:00
|
|
|
isChecked(toolbox) {
|
2018-12-18 11:32:33 +03:00
|
|
|
// if the inspector doesn't exist, then the highlighter has not yet been connected
|
|
|
|
// to the front end.
|
2019-08-07 07:17:31 +03:00
|
|
|
const inspectorFront = toolbox.target.getCachedFront("inspector");
|
2018-12-18 11:32:33 +03:00
|
|
|
if (!inspectorFront) {
|
|
|
|
// initialize the inspector front asyncronously. There is a potential for buggy
|
|
|
|
// behavior here, but we need to change how the buttons get data (have them
|
|
|
|
// consume data from reducers rather than writing our own version) in order to
|
|
|
|
// fix this properly.
|
2018-12-18 11:45:28 +03:00
|
|
|
return false;
|
|
|
|
}
|
2018-12-18 11:32:33 +03:00
|
|
|
const highlighter = inspectorFront.getKnownHighlighter(highlighterName);
|
2018-09-03 17:54:04 +03:00
|
|
|
return highlighter && highlighter.isShown();
|
2017-03-20 16:54:03 +03:00
|
|
|
},
|
2018-09-03 17:54:04 +03:00
|
|
|
};
|
|
|
|
}
|
2016-10-13 00:22:57 +03:00
|
|
|
|
2015-04-23 12:24:49 +03:00
|
|
|
/**
|
|
|
|
* Lookup l10n string from a string bundle.
|
|
|
|
*
|
|
|
|
* @param {string} name
|
|
|
|
* The key to lookup.
|
2018-05-23 09:06:14 +03:00
|
|
|
* @param {...string} args
|
2016-09-02 18:45:22 +03:00
|
|
|
* Optional format argument.
|
2015-04-23 12:24:49 +03:00
|
|
|
* @returns A localized version of the given key.
|
|
|
|
*/
|
2018-05-23 09:06:14 +03:00
|
|
|
function l10n(name, ...args) {
|
2015-04-23 12:24:49 +03:00
|
|
|
try {
|
2018-05-23 09:06:14 +03:00
|
|
|
return args ? L10N.getFormatStr(name, ...args) : L10N.getStr(name);
|
2015-04-23 12:24:49 +03:00
|
|
|
} catch (ex) {
|
2016-04-19 23:05:35 +03:00
|
|
|
console.log("Error reading '" + name + "'");
|
2015-04-23 12:24:49 +03:00
|
|
|
throw new Error("l10n error with " + name);
|
|
|
|
}
|
|
|
|
}
|
2015-06-09 21:07:01 +03:00
|
|
|
|
2016-01-26 12:53:45 +03:00
|
|
|
function functionkey(shortkey) {
|
2015-06-09 21:07:01 +03:00
|
|
|
return shortkey.split("_")[1];
|
|
|
|
}
|