Bug 1412029 - pass key shortcut id to aboutdevtools page;r=bgrins
MozReview-Commit-ID: 4Fmj1p1bgsB
--- a/devtools/shim/devtools-startup.js
+++ b/devtools/shim/devtools-startup.js
@@ -466,24 +466,25 @@ DevToolsStartup.prototype = {
// Appending a <key> element is not always enough. The <keyset> needs
// to be detached and reattached to make sure the <key> is taken into
// account (see bug 832984).
let mainKeyset = doc.getElementById("mainKeyset");
mainKeyset.parentNode.insertBefore(keyset, mainKeyset);
},
onKey(window, key) {
- // Record the timing at which this event started in order to compute later in
- // gDevTools.showToolbox, the complete time it takes to open the toolbox.
- // i.e. especially take `initDevTools` into account.
-
- let startTime = window.performance.now();
- let require = this.initDevTools("KeyShortcut");
- if (require) {
- // require might be null if initDevTools was called while DevTools are disabled.
+ if (!Services.prefs.getBoolPref(DEVTOOLS_ENABLED_PREF)) {
+ let id = key.toolId || key.id;
+ this.openInstallPage("KeyShortcut", id);
+ } else {
+ // Record the timing at which this event started in order to compute later in
+ // gDevTools.showToolbox, the complete time it takes to open the toolbox.
+ // i.e. especially take `initDevTools` into account.
+ let startTime = window.performance.now();
+ let require = this.initDevTools("KeyShortcut");
let { gDevToolsBrowser } = require("devtools/client/framework/devtools-browser");
gDevToolsBrowser.onKeyShortcut(window, key, startTime);
}
},
// Create a <xul:key> DOM Element
createKey(doc, { id, toolId, shortcut, modifiers: mod }, oncommand) {
let k = doc.createElement("key");
@@ -529,17 +530,27 @@ DevToolsStartup.prototype = {
this.initialized = true;
let { require } = Cu.import("resource://devtools/shared/Loader.jsm", {});
// Ensure loading main devtools module that hooks up into browser UI
// and initialize all devtools machinery.
require("devtools/client/framework/devtools-browser");
return require;
},
- openInstallPage: function (reason) {
+ /**
+ * Open about:devtools to start the onboarding flow.
+ *
+ * @param {String} reason
+ * One of "KeyShortcut", "SystemMenu", "HamburgerMenu", "ContextMenu",
+ * "CommandLine".
+ * @param {String} keyId
+ * Optional. If the onboarding flow was triggered by a keyboard shortcut, pass
+ * the shortcut key id (or toolId) to about:devtools.
+ */
+ openInstallPage: function (reason, keyId) {
let { gBrowser } = Services.wm.getMostRecentWindow("navigator:browser");
// Focus about:devtools tab if there is already one opened in the current window.
for (let tab of gBrowser.tabs) {
let browser = tab.linkedBrowser;
// browser.documentURI might be undefined if the browser tab is still loading.
let location = browser.documentURI ? browser.documentURI.spec : "";
if (location.startsWith("about:devtools") &&
@@ -557,16 +568,20 @@ DevToolsStartup.prototype = {
params.push("reason=" + encodeURIComponent(reason));
}
let selectedBrowser = gBrowser.selectedBrowser;
if (selectedBrowser) {
params.push("tabid=" + selectedBrowser.outerWindowID);
}
+ if (keyId) {
+ params.push("keyid=" + keyId);
+ }
+
if (params.length > 0) {
url += "?" + params.join("&");
}
// Set relatedToCurrent: true to open the tab next to the current one.
gBrowser.selectedTab = gBrowser.addTab(url, {relatedToCurrent: true});
},