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);
|
|
|
|
loader.lazyGetter(this, "DebuggerPanel", () => require("devtools/client/debugger/panel").DebuggerPanel);
|
2016-12-19 20:00:12 +03:00
|
|
|
loader.lazyGetter(this, "NewDebuggerPanel", () => require("devtools/client/debugger/new/panel").DebuggerPanel);
|
2015-09-21 20:04:18 +03:00
|
|
|
loader.lazyGetter(this, "StyleEditorPanel", () => require("devtools/client/styleeditor/styleeditor-panel").StyleEditorPanel);
|
|
|
|
loader.lazyGetter(this, "ShaderEditorPanel", () => require("devtools/client/shadereditor/panel").ShaderEditorPanel);
|
|
|
|
loader.lazyGetter(this, "CanvasDebuggerPanel", () => require("devtools/client/canvasdebugger/panel").CanvasDebuggerPanel);
|
|
|
|
loader.lazyGetter(this, "WebAudioEditorPanel", () => require("devtools/client/webaudioeditor/panel").WebAudioEditorPanel);
|
|
|
|
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);
|
|
|
|
loader.lazyGetter(this, "ScratchpadPanel", () => require("devtools/client/scratchpad/scratchpad-panel").ScratchpadPanel);
|
2016-02-10 01:23:29 +03:00
|
|
|
loader.lazyGetter(this, "DomPanel", () => require("devtools/client/dom/dom-panel").DomPanel);
|
2018-03-28 18:40:49 +03:00
|
|
|
loader.lazyGetter(this, "AccessibilityPanel", () => require("devtools/client/accessibility/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
|
|
|
|
loader.lazyRequireGetter(this, "CommandUtils", "devtools/client/shared/developer-toolbar", true);
|
2017-03-20 16:54:03 +03:00
|
|
|
loader.lazyRequireGetter(this, "CommandState", "devtools/shared/gcli/command-state", true);
|
2017-09-27 02:39:16 +03:00
|
|
|
loader.lazyRequireGetter(this, "ResponsiveUIManager", "devtools/client/responsive.html/manager", true);
|
2017-01-05 21:27:31 +03:00
|
|
|
loader.lazyImporter(this, "ScratchpadManager", "resource://devtools/client/scratchpad/scratchpad-manager.jsm");
|
|
|
|
|
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,
|
2016-02-27 01:40:14 +03:00
|
|
|
url: "chrome://devtools/content/framework/toolbox-options.xhtml",
|
2015-10-30 21:59:30 +03:00
|
|
|
icon: "chrome://devtools/skin/images/tool-options.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",
|
2016-10-14 17:47:10 +03:00
|
|
|
url: "chrome://devtools/content/inspector/inspector.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);
|
|
|
|
}
|
|
|
|
|
|
|
|
return l10n("inspector.tooltip2", "Ctrl+Shift+") + l10n("inspector.commandkey");
|
2015-06-09 21:07:01 +03:00
|
|
|
},
|
2015-04-23 12:24:49 +03:00
|
|
|
inMenu: true,
|
|
|
|
commands: [
|
2017-09-27 02:47:12 +03:00
|
|
|
"devtools/client/responsive.html/commands",
|
2016-07-20 17:06:42 +03:00
|
|
|
"devtools/client/inspector/inspector-commands"
|
2015-04-23 12:24:49 +03:00
|
|
|
],
|
|
|
|
|
|
|
|
preventClosingOnKey: true,
|
2018-03-12 21:24:38 +03:00
|
|
|
onkey: function(panel, toolbox) {
|
2016-02-18 19:52:33 +03:00
|
|
|
toolbox.highlighterUtils.togglePicker();
|
|
|
|
},
|
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-04-13 18:08:03 +03:00
|
|
|
url: "chrome://devtools/content/webconsole/webconsole.html",
|
2018-04-26 20:35:14 +03:00
|
|
|
get browserConsoleUsesHTML() {
|
|
|
|
return Services.prefs.getBoolPref("devtools.browserconsole.html");
|
|
|
|
},
|
|
|
|
get browserConsoleURL() {
|
|
|
|
return this.browserConsoleUsesHTML ?
|
|
|
|
"chrome://devtools/content/webconsole/webconsole.html" :
|
|
|
|
"chrome://devtools/content/webconsole/browserconsole.xul";
|
|
|
|
},
|
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,
|
2015-09-21 20:04:18 +03:00
|
|
|
commands: "devtools/client/webconsole/console-commands",
|
2015-04-23 12:24:49 +03:00
|
|
|
|
|
|
|
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",
|
2015-09-21 20:02:37 +03:00
|
|
|
url: "chrome://devtools/content/debugger/debugger.xul",
|
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() {
|
2016-09-02 18:45:22 +03:00
|
|
|
return l10n("ToolboxDebugger.tooltip2",
|
2017-07-18 12:05:47 +03:00
|
|
|
(osString == "Darwin" ? "Cmd+Opt+" : "Ctrl+Shift+") +
|
|
|
|
l10n("debugger.commandkey"));
|
2015-06-09 21:07:01 +03:00
|
|
|
},
|
2015-04-23 12:24:49 +03:00
|
|
|
inMenu: true,
|
2015-09-21 20:04:18 +03:00
|
|
|
commands: "devtools/client/debugger/debugger-commands",
|
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 DebuggerPanel(iframeWindow, toolbox);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2016-09-01 00:21:24 +03:00
|
|
|
function switchDebugger() {
|
|
|
|
if (Services.prefs.getBoolPref("devtools.debugger.new-debugger-frontend")) {
|
|
|
|
Tools.jsdebugger.url = "chrome://devtools/content/debugger/new/index.html";
|
2018-03-12 21:24:38 +03:00
|
|
|
Tools.jsdebugger.build = function(iframeWindow, toolbox) {
|
2016-09-01 00:21:24 +03:00
|
|
|
return new NewDebuggerPanel(iframeWindow, toolbox);
|
|
|
|
};
|
|
|
|
} else {
|
|
|
|
Tools.jsdebugger.url = "chrome://devtools/content/debugger/debugger.xul";
|
2018-03-12 21:24:38 +03:00
|
|
|
Tools.jsdebugger.build = function(iframeWindow, toolbox) {
|
2016-09-01 00:21:24 +03:00
|
|
|
return new DebuggerPanel(iframeWindow, toolbox);
|
|
|
|
};
|
|
|
|
}
|
2016-08-05 16:27:41 +03:00
|
|
|
}
|
2016-09-01 00:21:24 +03:00
|
|
|
switchDebugger();
|
|
|
|
|
|
|
|
Services.prefs.addObserver(
|
|
|
|
"devtools.debugger.new-debugger-frontend",
|
2017-04-14 22:51:38 +03:00
|
|
|
{ observe: switchDebugger }
|
2016-09-01 00:21:24 +03:00
|
|
|
);
|
2016-08-05 16:27:41 +03:00
|
|
|
|
2015-04-23 12:24:49 +03:00
|
|
|
Tools.styleEditor = {
|
|
|
|
id: "styleeditor",
|
|
|
|
ordinal: 4,
|
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",
|
2015-09-21 20:02:37 +03:00
|
|
|
url: "chrome://devtools/content/styleeditor/styleeditor.xul",
|
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,
|
2015-09-21 20:04:18 +03:00
|
|
|
commands: "devtools/client/styleeditor/styleeditor-commands",
|
2015-04-23 12:24:49 +03:00
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
Tools.shaderEditor = {
|
|
|
|
id: "shadereditor",
|
|
|
|
ordinal: 5,
|
|
|
|
visibilityswitch: "devtools.shadereditor.enabled",
|
2015-10-30 21:59:30 +03:00
|
|
|
icon: "chrome://devtools/skin/images/tool-shadereditor.svg",
|
2015-09-21 20:02:37 +03:00
|
|
|
url: "chrome://devtools/content/shadereditor/shadereditor.xul",
|
2016-09-02 18:45:22 +03:00
|
|
|
label: l10n("ToolboxShaderEditor.label"),
|
|
|
|
panelLabel: l10n("ToolboxShaderEditor.panelLabel"),
|
|
|
|
tooltip: l10n("ToolboxShaderEditor.tooltip"),
|
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("webgl") && !target.chrome;
|
|
|
|
},
|
|
|
|
|
2018-03-12 21:24:38 +03:00
|
|
|
build: function(iframeWindow, toolbox) {
|
2015-04-23 12:24:49 +03:00
|
|
|
return new ShaderEditorPanel(iframeWindow, toolbox);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
Tools.canvasDebugger = {
|
|
|
|
id: "canvasdebugger",
|
|
|
|
ordinal: 6,
|
|
|
|
visibilityswitch: "devtools.canvasdebugger.enabled",
|
2015-10-30 21:59:30 +03:00
|
|
|
icon: "chrome://devtools/skin/images/tool-canvas.svg",
|
2015-09-21 20:02:37 +03:00
|
|
|
url: "chrome://devtools/content/canvasdebugger/canvasdebugger.xul",
|
2016-09-02 18:45:22 +03:00
|
|
|
label: l10n("ToolboxCanvasDebugger.label"),
|
|
|
|
panelLabel: l10n("ToolboxCanvasDebugger.panelLabel"),
|
|
|
|
tooltip: l10n("ToolboxCanvasDebugger.tooltip"),
|
2015-04-23 12:24:49 +03:00
|
|
|
|
|
|
|
// Hide the Canvas Debugger in the Add-on Debugger and Browser Toolbox
|
|
|
|
// (bug 1047520).
|
2018-03-12 21:24:38 +03:00
|
|
|
isTargetSupported: function(target) {
|
2015-04-23 12:24:49 +03:00
|
|
|
return target.hasActor("canvas") && !target.chrome;
|
|
|
|
},
|
|
|
|
|
2018-03-12 21:24:38 +03:00
|
|
|
build: function(iframeWindow, toolbox) {
|
2015-04-23 12:24:49 +03:00
|
|
|
return new CanvasDebuggerPanel(iframeWindow, toolbox);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2017-11-28 22:47:41 +03:00
|
|
|
Tools.performance = {
|
2017-11-08 19:36:43 +03:00
|
|
|
id: "performance",
|
|
|
|
ordinal: 7,
|
|
|
|
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)) {
|
|
|
|
Tools.performance.url = "chrome://devtools/content/performance-new/perf.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) {
|
2017-11-08 19:36:43 +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.
|
|
|
|
return true;
|
|
|
|
};
|
|
|
|
} else {
|
|
|
|
Tools.performance.url = "chrome://devtools/content/performance/performance.xul";
|
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();
|
|
|
|
|
|
|
|
Services.prefs.addObserver(
|
|
|
|
"devtools.performance.new-panel-enabled",
|
|
|
|
{ observe: switchPerformancePanel }
|
|
|
|
);
|
2015-04-23 12:24:49 +03:00
|
|
|
|
2015-08-30 01:49:22 +03:00
|
|
|
Tools.memory = {
|
|
|
|
id: "memory",
|
|
|
|
ordinal: 8,
|
2015-10-30 21:59:30 +03:00
|
|
|
icon: "chrome://devtools/skin/images/tool-memory.svg",
|
2015-09-21 20:02:37 +03:00
|
|
|
url: "chrome://devtools/content/memory/memory.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) {
|
2016-07-21 20:10:12 +03:00
|
|
|
return target.getTrait("heapSnapshots") && !target.isAddon;
|
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"),
|
2015-04-23 12:24:49 +03:00
|
|
|
ordinal: 9,
|
|
|
|
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) {
|
2015-04-23 12:24:49 +03:00
|
|
|
return target.getTrait("networkMonitor");
|
|
|
|
},
|
|
|
|
|
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",
|
|
|
|
ordinal: 10,
|
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",
|
2015-09-21 20:02:37 +03:00
|
|
|
url: "chrome://devtools/content/storage/storage.xul",
|
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);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
Tools.webAudioEditor = {
|
|
|
|
id: "webaudioeditor",
|
|
|
|
ordinal: 11,
|
|
|
|
visibilityswitch: "devtools.webaudioeditor.enabled",
|
2015-10-30 21:59:30 +03:00
|
|
|
icon: "chrome://devtools/skin/images/tool-webaudio.svg",
|
2015-09-21 20:02:37 +03:00
|
|
|
url: "chrome://devtools/content/webaudioeditor/webaudioeditor.xul",
|
2016-09-02 18:45:22 +03:00
|
|
|
label: l10n("ToolboxWebAudioEditor1.label"),
|
|
|
|
panelLabel: l10n("ToolboxWebAudioEditor1.panelLabel"),
|
|
|
|
tooltip: l10n("ToolboxWebAudioEditor1.tooltip"),
|
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.chrome && target.hasActor("webaudio");
|
|
|
|
},
|
|
|
|
|
2018-03-12 21:24:38 +03:00
|
|
|
build: function(iframeWindow, toolbox) {
|
2015-04-23 12:24:49 +03:00
|
|
|
return new WebAudioEditorPanel(iframeWindow, toolbox);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
Tools.scratchpad = {
|
|
|
|
id: "scratchpad",
|
|
|
|
ordinal: 12,
|
|
|
|
visibilityswitch: "devtools.scratchpad.enabled",
|
2015-10-30 21:59:30 +03:00
|
|
|
icon: "chrome://devtools/skin/images/tool-scratchpad.svg",
|
2015-09-21 20:02:37 +03:00
|
|
|
url: "chrome://devtools/content/scratchpad/scratchpad.xul",
|
2016-09-02 18:45:22 +03:00
|
|
|
label: l10n("scratchpad.label"),
|
|
|
|
panelLabel: l10n("scratchpad.panelLabel"),
|
|
|
|
tooltip: l10n("scratchpad.tooltip"),
|
2015-04-23 12:24:49 +03:00
|
|
|
inMenu: false,
|
2015-09-21 20:04:18 +03:00
|
|
|
commands: "devtools/client/scratchpad/scratchpad-commands",
|
2015-04-23 12:24:49 +03:00
|
|
|
|
2018-03-12 21:24:38 +03:00
|
|
|
isTargetSupported: function(target) {
|
2016-02-04 13:20:55 +03:00
|
|
|
return target.hasActor("console");
|
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 ScratchpadPanel(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"),
|
2016-02-10 01:23:29 +03:00
|
|
|
ordinal: 13,
|
|
|
|
visibilityswitch: "devtools.dom.enabled",
|
|
|
|
icon: "chrome://devtools/skin/images/tool-dom.svg",
|
|
|
|
url: "chrome://devtools/content/dom/dom.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) {
|
2016-02-10 01:23:29 +03:00
|
|
|
return target.getTrait("webConsoleCommands");
|
|
|
|
},
|
|
|
|
|
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"),
|
|
|
|
ordinal: 14,
|
|
|
|
modifiers: osString == "Darwin" ? "accel,alt" : "accel,shift",
|
|
|
|
visibilityswitch: "devtools.accessibility.enabled",
|
|
|
|
icon: "chrome://devtools/skin/images/tool-accessibility.svg",
|
|
|
|
url: "chrome://devtools/content/accessibility/accessibility.html",
|
|
|
|
label: l10n("accessibility.label"),
|
|
|
|
panelLabel: l10n("accessibility.panelLabel"),
|
|
|
|
get tooltip() {
|
2018-04-04 21:37:30 +03:00
|
|
|
return l10n("accessibility.tooltip2");
|
2018-03-28 18:40:49 +03:00
|
|
|
},
|
|
|
|
inMenu: true,
|
|
|
|
|
|
|
|
isTargetSupported(target) {
|
|
|
|
return target.hasActor("accessibility");
|
|
|
|
},
|
|
|
|
|
|
|
|
build(iframeWindow, toolbox) {
|
|
|
|
return new AccessibilityPanel(iframeWindow, toolbox);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2018-03-14 23:21:02 +03:00
|
|
|
Tools.application = {
|
|
|
|
id: "application",
|
|
|
|
ordinal: 15,
|
|
|
|
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"),
|
2018-03-14 23:21:02 +03:00
|
|
|
inMenu: false,
|
|
|
|
hiddenInOptions: true,
|
|
|
|
|
|
|
|
isTargetSupported: function(target) {
|
|
|
|
return target.isLocalTab;
|
|
|
|
},
|
|
|
|
|
|
|
|
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.shaderEditor,
|
|
|
|
Tools.canvasDebugger,
|
|
|
|
Tools.webAudioEditor,
|
|
|
|
Tools.performance,
|
|
|
|
Tools.netMonitor,
|
|
|
|
Tools.storage,
|
2015-08-30 01:49:22 +03:00
|
|
|
Tools.scratchpad,
|
|
|
|
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,
|
|
|
|
];
|
|
|
|
|
2016-10-13 00:22:57 +03:00
|
|
|
// White-list buttons that can be toggled to prevent adding prefs for
|
|
|
|
// 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) {
|
|
|
|
CommandUtils.executeOnTarget(toolbox.target, "paintflashing toggle");
|
|
|
|
},
|
2017-03-20 16:54:03 +03:00
|
|
|
isChecked(toolbox) {
|
|
|
|
return CommandState.isEnabledForTarget(toolbox.target, "paintflashing");
|
|
|
|
},
|
|
|
|
setup(toolbox, onChange) {
|
|
|
|
CommandState.on("changed", onChange);
|
|
|
|
},
|
|
|
|
teardown(toolbox, onChange) {
|
|
|
|
CommandState.off("changed", onChange);
|
|
|
|
}
|
2017-01-05 21:27:31 +03:00
|
|
|
},
|
|
|
|
{ id: "command-button-scratchpad",
|
|
|
|
description: l10n("toolbox.buttons.scratchpad"),
|
|
|
|
isTargetSupported: target => target.isLocalTab,
|
|
|
|
onClick(event, toolbox) {
|
|
|
|
ScratchpadManager.openScratchpad();
|
2016-10-13 00:22:57 +03:00
|
|
|
}
|
|
|
|
},
|
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) {
|
2018-06-01 13:36:09 +03:00
|
|
|
const tab = toolbox.target.tab;
|
|
|
|
const browserWindow = tab.ownerDocument.defaultView;
|
2017-03-15 02:41:23 +03:00
|
|
|
ResponsiveUIManager.handleGcliCommand(browserWindow, tab,
|
|
|
|
"resize toggle", null);
|
2017-01-05 21:27:31 +03:00
|
|
|
},
|
|
|
|
isChecked(toolbox) {
|
|
|
|
if (!toolbox.target.tab) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return ResponsiveUIManager.isActiveForTab(toolbox.target.tab);
|
|
|
|
},
|
|
|
|
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"),
|
|
|
|
isTargetSupported: target => target.isLocalTab,
|
|
|
|
onClick(event, toolbox) {
|
|
|
|
// Special case for screenshot button to check for clipboard preference
|
|
|
|
const clipboardEnabled = Services.prefs
|
|
|
|
.getBoolPref("devtools.screenshot.clipboard.enabled");
|
|
|
|
let args = "--fullpage --file";
|
|
|
|
if (clipboardEnabled) {
|
|
|
|
args += " --clipboard";
|
|
|
|
}
|
|
|
|
CommandUtils.executeOnTarget(toolbox.target, "screenshot " + args);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{ id: "command-button-rulers",
|
|
|
|
description: l10n("toolbox.buttons.rulers"),
|
|
|
|
isTargetSupported: target => target.isLocalTab,
|
|
|
|
onClick(event, toolbox) {
|
|
|
|
CommandUtils.executeOnTarget(toolbox.target, "rulers");
|
|
|
|
},
|
2017-03-20 16:54:03 +03:00
|
|
|
isChecked(toolbox) {
|
|
|
|
return CommandState.isEnabledForTarget(toolbox.target, "rulers");
|
|
|
|
},
|
|
|
|
setup(toolbox, onChange) {
|
|
|
|
CommandState.on("changed", onChange);
|
|
|
|
},
|
|
|
|
teardown(toolbox, onChange) {
|
|
|
|
CommandState.off("changed", onChange);
|
|
|
|
}
|
2017-01-05 21:27:31 +03:00
|
|
|
},
|
|
|
|
{ id: "command-button-measure",
|
|
|
|
description: l10n("toolbox.buttons.measure"),
|
|
|
|
isTargetSupported: target => target.isLocalTab,
|
|
|
|
onClick(event, toolbox) {
|
|
|
|
CommandUtils.executeOnTarget(toolbox.target, "measure");
|
|
|
|
},
|
2017-03-20 16:54:03 +03:00
|
|
|
isChecked(toolbox) {
|
|
|
|
return CommandState.isEnabledForTarget(toolbox.target, "measure");
|
|
|
|
},
|
|
|
|
setup(toolbox, onChange) {
|
|
|
|
CommandState.on("changed", onChange);
|
|
|
|
},
|
|
|
|
teardown(toolbox, onChange) {
|
|
|
|
CommandState.off("changed", onChange);
|
|
|
|
}
|
2017-01-05 21:27:31 +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];
|
|
|
|
}
|