gecko-dev/devtools/client/definitions.js

643 строки
20 KiB
JavaScript
Исходник Обычный вид История

/* 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";
const Services = require("Services");
const osString = Services.appinfo.OS;
// Panels
loader.lazyGetter(this, "OptionsPanel", () => require("devtools/client/framework/toolbox-options").OptionsPanel);
loader.lazyGetter(this, "InspectorPanel", () => require("devtools/client/inspector/panel").InspectorPanel);
loader.lazyGetter(this, "WebConsolePanel", () => require("devtools/client/webconsole/panel").WebConsolePanel);
loader.lazyGetter(this, "DebuggerPanel", () => require("devtools/client/debugger/panel").DebuggerPanel);
loader.lazyGetter(this, "NewDebuggerPanel", () => require("devtools/client/debugger/new/panel").DebuggerPanel);
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);
loader.lazyGetter(this, "NewPerformancePanel", () => require("devtools/client/performance-new/panel").PerformancePanel);
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);
loader.lazyGetter(this, "DomPanel", () => require("devtools/client/dom/dom-panel").DomPanel);
loader.lazyGetter(this, "AccessibilityPanel", () => require("devtools/client/accessibility/accessibility-panel").AccessibilityPanel);
loader.lazyGetter(this, "ApplicationPanel", () => require("devtools/client/application/panel").ApplicationPanel);
// Other dependencies
loader.lazyRequireGetter(this, "CommandUtils", "devtools/client/shared/developer-toolbar", true);
loader.lazyRequireGetter(this, "CommandState", "devtools/shared/gcli/command-state", true);
loader.lazyRequireGetter(this, "ResponsiveUIManager", "devtools/client/responsive.html/manager", true);
loader.lazyImporter(this, "ScratchpadManager", "resource://devtools/client/scratchpad/scratchpad-manager.jsm");
const {MultiLocalizationHelper} = require("devtools/shared/l10n");
const L10N = new MultiLocalizationHelper(
"devtools/client/locales/startup.properties",
Bug 1444926 - Move devtools/shim to devtools/startup;r=ochameau MozReview-Commit-ID: K9WuJuTdYHS --HG-- rename : devtools/shim/DevToolsShim.jsm => devtools/startup/DevToolsShim.jsm rename : devtools/shim/aboutdebugging-registration.js => devtools/startup/aboutdebugging-registration.js rename : devtools/shim/aboutdebugging.manifest => devtools/startup/aboutdebugging.manifest rename : devtools/shim/aboutdevtools/aboutdevtools-registration.js => devtools/startup/aboutdevtools/aboutdevtools-registration.js rename : devtools/shim/aboutdevtools/aboutdevtools.css => devtools/startup/aboutdevtools/aboutdevtools.css rename : devtools/shim/aboutdevtools/aboutdevtools.js => devtools/startup/aboutdevtools/aboutdevtools.js rename : devtools/shim/aboutdevtools/aboutdevtools.manifest => devtools/startup/aboutdevtools/aboutdevtools.manifest rename : devtools/shim/aboutdevtools/aboutdevtools.xhtml => devtools/startup/aboutdevtools/aboutdevtools.xhtml rename : devtools/shim/aboutdevtools/images/dev-edition-logo.svg => devtools/startup/aboutdevtools/images/dev-edition-logo.svg rename : devtools/shim/aboutdevtools/images/external-link.svg => devtools/startup/aboutdevtools/images/external-link.svg rename : devtools/shim/aboutdevtools/images/feature-console.svg => devtools/startup/aboutdevtools/images/feature-console.svg rename : devtools/shim/aboutdevtools/images/feature-debugger.svg => devtools/startup/aboutdevtools/images/feature-debugger.svg rename : devtools/shim/aboutdevtools/images/feature-inspector.svg => devtools/startup/aboutdevtools/images/feature-inspector.svg rename : devtools/shim/aboutdevtools/images/feature-memory.svg => devtools/startup/aboutdevtools/images/feature-memory.svg rename : devtools/shim/aboutdevtools/images/feature-network.svg => devtools/startup/aboutdevtools/images/feature-network.svg rename : devtools/shim/aboutdevtools/images/feature-performance.svg => devtools/startup/aboutdevtools/images/feature-performance.svg rename : devtools/shim/aboutdevtools/images/feature-responsive.svg => devtools/startup/aboutdevtools/images/feature-responsive.svg rename : devtools/shim/aboutdevtools/images/feature-storage.svg => devtools/startup/aboutdevtools/images/feature-storage.svg rename : devtools/shim/aboutdevtools/images/feature-visualediting.svg => devtools/startup/aboutdevtools/images/feature-visualediting.svg rename : devtools/shim/aboutdevtools/images/otter.svg => devtools/startup/aboutdevtools/images/otter.svg rename : devtools/shim/aboutdevtools/moz.build => devtools/startup/aboutdevtools/moz.build rename : devtools/shim/aboutdevtools/subscribe.css => devtools/startup/aboutdevtools/subscribe.css rename : devtools/shim/aboutdevtools/subscribe.js => devtools/startup/aboutdevtools/subscribe.js rename : devtools/shim/aboutdevtools/test/.eslintrc.js => devtools/startup/aboutdevtools/test/.eslintrc.js rename : devtools/shim/aboutdevtools/test/browser.ini => devtools/startup/aboutdevtools/test/browser.ini rename : devtools/shim/aboutdevtools/test/browser_aboutdevtools_closes_page.js => devtools/startup/aboutdevtools/test/browser_aboutdevtools_closes_page.js rename : devtools/shim/aboutdevtools/test/browser_aboutdevtools_enables_devtools.js => devtools/startup/aboutdevtools/test/browser_aboutdevtools_enables_devtools.js rename : devtools/shim/aboutdevtools/test/browser_aboutdevtools_focus_owner_tab.js => devtools/startup/aboutdevtools/test/browser_aboutdevtools_focus_owner_tab.js rename : devtools/shim/aboutdevtools/test/browser_aboutdevtools_reuse_existing.js => devtools/startup/aboutdevtools/test/browser_aboutdevtools_reuse_existing.js rename : devtools/shim/aboutdevtools/test/head.js => devtools/startup/aboutdevtools/test/head.js rename : devtools/shim/aboutdevtoolstoolbox-registration.js => devtools/startup/aboutdevtoolstoolbox-registration.js rename : devtools/shim/aboutdevtoolstoolbox.manifest => devtools/startup/aboutdevtoolstoolbox.manifest rename : devtools/shim/devtools-startup-prefs.js => devtools/startup/devtools-startup-prefs.js rename : devtools/shim/devtools-startup.js => devtools/startup/devtools-startup.js rename : devtools/shim/devtools-startup.manifest => devtools/startup/devtools-startup.manifest rename : devtools/shim/jar.mn => devtools/startup/jar.mn rename : devtools/shim/locales/en-US/aboutdevtools.dtd => devtools/startup/locales/en-US/aboutdevtools.dtd rename : devtools/shim/locales/en-US/aboutdevtools.properties => devtools/startup/locales/en-US/aboutdevtools.properties rename : devtools/shim/locales/en-US/key-shortcuts.properties => devtools/startup/locales/en-US/key-shortcuts.properties rename : devtools/shim/locales/en-US/startup.properties => devtools/startup/locales/en-US/startup.properties rename : devtools/shim/locales/jar.mn => devtools/startup/locales/jar.mn rename : devtools/shim/locales/moz.build => devtools/startup/locales/moz.build rename : devtools/shim/moz.build => devtools/startup/moz.build rename : devtools/shim/tests/browser/.eslintrc.js => devtools/startup/tests/browser/.eslintrc.js rename : devtools/shim/tests/browser/browser.ini => devtools/startup/tests/browser/browser.ini rename : devtools/shim/tests/browser/browser_shim_disable_devtools.js => devtools/startup/tests/browser/browser_shim_disable_devtools.js rename : devtools/shim/tests/unit/.eslintrc.js => devtools/startup/tests/unit/.eslintrc.js rename : devtools/shim/tests/unit/test_devtools_shim.js => devtools/startup/tests/unit/test_devtools_shim.js rename : devtools/shim/tests/unit/xpcshell.ini => devtools/startup/tests/unit/xpcshell.ini extra : rebase_source : 7867a5b103d01dc936091a71deeaf526e7f0e47a
2018-03-12 16:41:48 +03:00
"devtools/startup/locales/key-shortcuts.properties"
);
var Tools = {};
exports.Tools = Tools;
// Definitions
Tools.options = {
id: "options",
ordinal: 0,
url: "chrome://devtools/content/framework/toolbox-options.xhtml",
icon: "chrome://devtools/skin/images/tool-options.svg",
bgTheme: "theme-body",
label: l10n("options.label"),
iconOnly: true,
panelLabel: l10n("options.panelLabel"),
tooltip: l10n("optionsButton.tooltip"),
inMenu: false,
isTargetSupported: function() {
return true;
},
build: function(iframeWindow, toolbox) {
return new OptionsPanel(iframeWindow, toolbox);
}
};
Tools.inspector = {
id: "inspector",
accesskey: l10n("inspector.accesskey"),
ordinal: 1,
icon: "chrome://devtools/skin/images/tool-inspector.svg",
url: "chrome://devtools/content/inspector/inspector.xhtml",
label: l10n("inspector.label"),
panelLabel: l10n("inspector.panelLabel"),
get tooltip() {
if (osString == "Darwin") {
const cmdShiftC = "Cmd+Shift+" + l10n("inspector.commandkey");
const cmdOptC = "Cmd+Opt+" + l10n("inspector.commandkey");
return l10n("inspector.mac.tooltip", cmdShiftC, cmdOptC);
}
return l10n("inspector.tooltip2", "Ctrl+Shift+") + l10n("inspector.commandkey");
},
inMenu: true,
commands: [
"devtools/client/responsive.html/commands",
"devtools/client/inspector/inspector-commands"
],
preventClosingOnKey: true,
onkey: function(panel, toolbox) {
toolbox.highlighterUtils.togglePicker();
},
isTargetSupported: function(target) {
return target.hasActor("inspector");
},
build: function(iframeWindow, toolbox) {
return new InspectorPanel(iframeWindow, toolbox);
}
};
Tools.webConsole = {
id: "webconsole",
accesskey: l10n("webConsoleCmd.accesskey"),
ordinal: 2,
url: "chrome://devtools/content/webconsole/webconsole.html",
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";
},
icon: "chrome://devtools/skin/images/tool-webconsole.svg",
label: l10n("ToolboxTabWebconsole.label"),
menuLabel: l10n("MenuWebconsole.label"),
panelLabel: l10n("ToolboxWebConsole.panelLabel"),
get tooltip() {
return l10n("ToolboxWebconsole.tooltip2",
(osString == "Darwin" ? "Cmd+Opt+" : "Ctrl+Shift+") +
l10n("webconsole.commandkey"));
},
inMenu: true,
commands: "devtools/client/webconsole/console-commands",
preventClosingOnKey: true,
onkey: function(panel, toolbox) {
if (toolbox.splitConsole) {
return toolbox.focusConsoleInput();
}
panel.focusInput();
return undefined;
},
isTargetSupported: function() {
return true;
},
build: function(iframeWindow, toolbox) {
return new WebConsolePanel(iframeWindow, toolbox);
}
};
Tools.jsdebugger = {
id: "jsdebugger",
accesskey: l10n("debuggerMenu.accesskey"),
ordinal: 3,
icon: "chrome://devtools/skin/images/tool-debugger.svg",
url: "chrome://devtools/content/debugger/debugger.xul",
label: l10n("ToolboxDebugger.label"),
panelLabel: l10n("ToolboxDebugger.panelLabel"),
get tooltip() {
return l10n("ToolboxDebugger.tooltip2",
(osString == "Darwin" ? "Cmd+Opt+" : "Ctrl+Shift+") +
l10n("debugger.commandkey"));
},
inMenu: true,
commands: "devtools/client/debugger/debugger-commands",
isTargetSupported: function() {
return true;
},
build: function(iframeWindow, toolbox) {
return new DebuggerPanel(iframeWindow, toolbox);
}
};
function switchDebugger() {
if (Services.prefs.getBoolPref("devtools.debugger.new-debugger-frontend")) {
Tools.jsdebugger.url = "chrome://devtools/content/debugger/new/index.html";
Tools.jsdebugger.build = function(iframeWindow, toolbox) {
return new NewDebuggerPanel(iframeWindow, toolbox);
};
} else {
Tools.jsdebugger.url = "chrome://devtools/content/debugger/debugger.xul";
Tools.jsdebugger.build = function(iframeWindow, toolbox) {
return new DebuggerPanel(iframeWindow, toolbox);
};
}
}
switchDebugger();
Services.prefs.addObserver(
"devtools.debugger.new-debugger-frontend",
{ observe: switchDebugger }
);
Tools.styleEditor = {
id: "styleeditor",
ordinal: 4,
visibilityswitch: "devtools.styleeditor.enabled",
accesskey: l10n("open.accesskey"),
icon: "chrome://devtools/skin/images/tool-styleeditor.svg",
url: "chrome://devtools/content/styleeditor/styleeditor.xul",
label: l10n("ToolboxStyleEditor.label"),
panelLabel: l10n("ToolboxStyleEditor.panelLabel"),
get tooltip() {
return l10n("ToolboxStyleEditor.tooltip3",
"Shift+" + functionkey(l10n("styleeditor.commandkey")));
},
inMenu: true,
commands: "devtools/client/styleeditor/styleeditor-commands",
isTargetSupported: function(target) {
return target.hasActor("styleSheets");
},
build: function(iframeWindow, toolbox) {
return new StyleEditorPanel(iframeWindow, toolbox);
}
};
Tools.shaderEditor = {
id: "shadereditor",
ordinal: 5,
visibilityswitch: "devtools.shadereditor.enabled",
icon: "chrome://devtools/skin/images/tool-shadereditor.svg",
url: "chrome://devtools/content/shadereditor/shadereditor.xul",
label: l10n("ToolboxShaderEditor.label"),
panelLabel: l10n("ToolboxShaderEditor.panelLabel"),
tooltip: l10n("ToolboxShaderEditor.tooltip"),
isTargetSupported: function(target) {
return target.hasActor("webgl") && !target.chrome;
},
build: function(iframeWindow, toolbox) {
return new ShaderEditorPanel(iframeWindow, toolbox);
}
};
Tools.canvasDebugger = {
id: "canvasdebugger",
ordinal: 6,
visibilityswitch: "devtools.canvasdebugger.enabled",
icon: "chrome://devtools/skin/images/tool-canvas.svg",
url: "chrome://devtools/content/canvasdebugger/canvasdebugger.xul",
label: l10n("ToolboxCanvasDebugger.label"),
panelLabel: l10n("ToolboxCanvasDebugger.panelLabel"),
tooltip: l10n("ToolboxCanvasDebugger.tooltip"),
// Hide the Canvas Debugger in the Add-on Debugger and Browser Toolbox
// (bug 1047520).
isTargetSupported: function(target) {
return target.hasActor("canvas") && !target.chrome;
},
build: function(iframeWindow, toolbox) {
return new CanvasDebuggerPanel(iframeWindow, toolbox);
}
};
Tools.performance = {
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,
};
function switchPerformancePanel() {
if (Services.prefs.getBoolPref("devtools.performance.new-panel-enabled", false)) {
Tools.performance.url = "chrome://devtools/content/performance-new/perf.xhtml";
Tools.performance.build = function(frame, target) {
return new NewPerformancePanel(frame, target);
};
Tools.performance.isTargetSupported = function(target) {
// 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";
Tools.performance.build = function(frame, target) {
return new PerformancePanel(frame, target);
};
Tools.performance.isTargetSupported = function(target) {
return target.hasActor("performance");
};
}
}
switchPerformancePanel();
Services.prefs.addObserver(
"devtools.performance.new-panel-enabled",
{ observe: switchPerformancePanel }
);
Tools.memory = {
id: "memory",
ordinal: 8,
icon: "chrome://devtools/skin/images/tool-memory.svg",
url: "chrome://devtools/content/memory/memory.xhtml",
visibilityswitch: "devtools.memory.enabled",
label: l10n("memory.label"),
panelLabel: l10n("memory.panelLabel"),
tooltip: l10n("memory.tooltip"),
isTargetSupported: function(target) {
return target.getTrait("heapSnapshots") && !target.isAddon;
},
build: function(frame, target) {
return new MemoryPanel(frame, target);
}
};
Tools.netMonitor = {
id: "netmonitor",
accesskey: l10n("netmonitor.accesskey"),
ordinal: 9,
visibilityswitch: "devtools.netmonitor.enabled",
icon: "chrome://devtools/skin/images/tool-network.svg",
url: "chrome://devtools/content/netmonitor/index.html",
label: l10n("netmonitor.label"),
panelLabel: l10n("netmonitor.panelLabel"),
get tooltip() {
return l10n("netmonitor.tooltip2",
(osString == "Darwin" ? "Cmd+Opt+" : "Ctrl+Shift+") +
l10n("netmonitor.commandkey"));
},
inMenu: true,
isTargetSupported: function(target) {
return target.getTrait("networkMonitor");
},
build: function(iframeWindow, toolbox) {
return new NetMonitorPanel(iframeWindow, toolbox);
}
};
Tools.storage = {
id: "storage",
ordinal: 10,
accesskey: l10n("storage.accesskey"),
visibilityswitch: "devtools.storage.enabled",
icon: "chrome://devtools/skin/images/tool-storage.svg",
url: "chrome://devtools/content/storage/storage.xul",
label: l10n("storage.label"),
menuLabel: l10n("storage.menuLabel"),
panelLabel: l10n("storage.panelLabel"),
get tooltip() {
return l10n("storage.tooltip3", "Shift+" +
functionkey(l10n("storage.commandkey")));
},
inMenu: true,
isTargetSupported: function(target) {
return target.isLocalTab ||
(target.hasActor("storage") && target.getTrait("storageInspector"));
},
build: function(iframeWindow, toolbox) {
return new StoragePanel(iframeWindow, toolbox);
}
};
Tools.webAudioEditor = {
id: "webaudioeditor",
ordinal: 11,
visibilityswitch: "devtools.webaudioeditor.enabled",
icon: "chrome://devtools/skin/images/tool-webaudio.svg",
url: "chrome://devtools/content/webaudioeditor/webaudioeditor.xul",
label: l10n("ToolboxWebAudioEditor1.label"),
panelLabel: l10n("ToolboxWebAudioEditor1.panelLabel"),
tooltip: l10n("ToolboxWebAudioEditor1.tooltip"),
isTargetSupported: function(target) {
return !target.chrome && target.hasActor("webaudio");
},
build: function(iframeWindow, toolbox) {
return new WebAudioEditorPanel(iframeWindow, toolbox);
}
};
Tools.scratchpad = {
id: "scratchpad",
ordinal: 12,
visibilityswitch: "devtools.scratchpad.enabled",
icon: "chrome://devtools/skin/images/tool-scratchpad.svg",
url: "chrome://devtools/content/scratchpad/scratchpad.xul",
label: l10n("scratchpad.label"),
panelLabel: l10n("scratchpad.panelLabel"),
tooltip: l10n("scratchpad.tooltip"),
inMenu: false,
commands: "devtools/client/scratchpad/scratchpad-commands",
isTargetSupported: function(target) {
return target.hasActor("console");
},
build: function(iframeWindow, toolbox) {
return new ScratchpadPanel(iframeWindow, toolbox);
}
};
Tools.dom = {
id: "dom",
accesskey: l10n("dom.accesskey"),
ordinal: 13,
visibilityswitch: "devtools.dom.enabled",
icon: "chrome://devtools/skin/images/tool-dom.svg",
url: "chrome://devtools/content/dom/dom.html",
label: l10n("dom.label"),
panelLabel: l10n("dom.panelLabel"),
get tooltip() {
return l10n("dom.tooltip",
(osString == "Darwin" ? "Cmd+Opt+" : "Ctrl+Shift+") +
l10n("dom.commandkey"));
},
inMenu: true,
isTargetSupported: function(target) {
return target.getTrait("webConsoleCommands");
},
build: function(iframeWindow, toolbox) {
return new DomPanel(iframeWindow, toolbox);
}
};
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() {
return l10n("accessibility.tooltip2");
},
inMenu: true,
isTargetSupported(target) {
return target.hasActor("accessibility");
},
build(iframeWindow, toolbox) {
return new AccessibilityPanel(iframeWindow, toolbox);
}
};
Tools.application = {
id: "application",
ordinal: 15,
visibilityswitch: "devtools.application.enabled",
icon: "chrome://devtools/skin/images/tool-application.svg",
url: "chrome://devtools/content/application/index.html",
label: l10n("application.label"),
panelLabel: l10n("application.panellabel"),
tooltip: l10n("application.tooltip"),
inMenu: false,
hiddenInOptions: true,
isTargetSupported: function(target) {
return target.isLocalTab;
},
build: function(iframeWindow, toolbox) {
return new ApplicationPanel(iframeWindow, toolbox);
}
};
var defaultTools = [
Tools.options,
Tools.webConsole,
Tools.inspector,
Tools.jsdebugger,
Tools.styleEditor,
Tools.shaderEditor,
Tools.canvasDebugger,
Tools.webAudioEditor,
Tools.performance,
Tools.netMonitor,
Tools.storage,
Tools.scratchpad,
Tools.memory,
Tools.dom,
Tools.accessibility,
Tools.application,
];
exports.defaultTools = defaultTools;
Tools.darkTheme = {
id: "dark",
label: l10n("options.darkTheme.label2"),
ordinal: 1,
stylesheets: ["chrome://devtools/skin/dark-theme.css"],
classList: ["theme-dark"],
};
Tools.lightTheme = {
id: "light",
label: l10n("options.lightTheme.label2"),
ordinal: 2,
stylesheets: ["chrome://devtools/skin/light-theme.css"],
classList: ["theme-light"],
};
exports.defaultThemes = [
Tools.darkTheme,
Tools.lightTheme,
];
// 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 = [
{ id: "command-button-paintflashing",
description: l10n("toolbox.buttons.paintflashing"),
isTargetSupported: target => target.isLocalTab,
onClick(event, toolbox) {
CommandUtils.executeOnTarget(toolbox.target, "paintflashing toggle");
},
isChecked(toolbox) {
return CommandState.isEnabledForTarget(toolbox.target, "paintflashing");
},
setup(toolbox, onChange) {
CommandState.on("changed", onChange);
},
teardown(toolbox, onChange) {
CommandState.off("changed", onChange);
}
},
{ id: "command-button-scratchpad",
description: l10n("toolbox.buttons.scratchpad"),
isTargetSupported: target => target.isLocalTab,
onClick(event, toolbox) {
ScratchpadManager.openScratchpad();
}
},
{ id: "command-button-responsive",
description: l10n("toolbox.buttons.responsive",
osString == "Darwin" ? "Cmd+Opt+M" : "Ctrl+Shift+M"),
isTargetSupported: target => target.isLocalTab,
onClick(event, toolbox) {
const tab = toolbox.target.tab;
const browserWindow = tab.ownerDocument.defaultView;
ResponsiveUIManager.handleGcliCommand(browserWindow, tab,
"resize toggle", null);
},
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");
},
isChecked(toolbox) {
return CommandState.isEnabledForTarget(toolbox.target, "rulers");
},
setup(toolbox, onChange) {
CommandState.on("changed", onChange);
},
teardown(toolbox, onChange) {
CommandState.off("changed", onChange);
}
},
{ id: "command-button-measure",
description: l10n("toolbox.buttons.measure"),
isTargetSupported: target => target.isLocalTab,
onClick(event, toolbox) {
CommandUtils.executeOnTarget(toolbox.target, "measure");
},
isChecked(toolbox) {
return CommandState.isEnabledForTarget(toolbox.target, "measure");
},
setup(toolbox, onChange) {
CommandState.on("changed", onChange);
},
teardown(toolbox, onChange) {
CommandState.off("changed", onChange);
}
},
];
/**
* Lookup l10n string from a string bundle.
*
* @param {string} name
* The key to lookup.
* @param {...string} args
* Optional format argument.
* @returns A localized version of the given key.
*/
function l10n(name, ...args) {
try {
return args ? L10N.getFormatStr(name, ...args) : L10N.getStr(name);
} catch (ex) {
console.log("Error reading '" + name + "'");
throw new Error("l10n error with " + name);
}
}
function functionkey(shortkey) {
return shortkey.split("_")[1];
}