Bug 1458840 - Allow restarting the browser with the keyboard shortcut in the Browser Console in all builds;r=jryans
MozReview-Commit-ID: D7Hswr7IfvW
--- a/devtools/client/webconsole/new-webconsole.js
+++ b/devtools/client/webconsole/new-webconsole.js
@@ -235,35 +235,27 @@ NewWebConsoleFrame.prototype = {
shortcuts.on(clearShortcut, () => this.jsterm.clearOutput(true));
if (this.isBrowserConsole) {
shortcuts.on(l10n.getStr("webconsole.close.key"),
this.window.top.close.bind(this.window.top));
ZoomKeys.register(this.window);
-
- if (!AppConstants.MOZILLA_OFFICIAL) {
- // In local builds, inject the "quick restart" shortcut.
- // This script expects to have Services on the global and we haven't yet imported
- // it into the window, so assign it.
- this.window.Services = Services;
- Services.scriptloader.loadSubScript(
- "chrome://browser/content/browser-development-helpers.js", this.window);
- shortcuts.on("CmdOrCtrl+Alt+R", this.window.DevelopmentHelpers.quickRestart);
- }
+ shortcuts.on("CmdOrCtrl+Alt+R", quickRestart);
} else if (Services.prefs.getBoolPref(PREF_SIDEBAR_ENABLED)) {
shortcuts.on("Esc", event => {
if (!this.jsterm.autocompletePopup || !this.jsterm.autocompletePopup.isOpen) {
this.newConsoleOutput.dispatchSidebarClose();
this.jsterm.focus();
}
});
}
},
+
/**
* Handler for page location changes.
*
* @param string uri
* New page location.
* @param string title
* New page title.
*/
@@ -337,9 +329,22 @@ NewWebConsoleFrame.prototype = {
}
if (packet.url) {
this.onLocationChange(packet.url, packet.title);
}
}
};
+/* This is the same as DevelopmentHelpers.quickRestart, but it runs in all
+ * builds (even official). This allows a user to do a restart + session restore
+ * with Ctrl+Shift+J (open Browser Console) and then Ctrl+Shift+R (restart).
+ */
+function quickRestart() {
+ const { Cc, Ci } = require("chrome");
+ Services.obs.notifyObservers(null, "startupcache-invalidate");
+ let env = Cc["@mozilla.org/process/environment;1"]
+ .getService(Ci.nsIEnvironment);
+ env.set("MOZ_DISABLE_SAFE_MODE_KEY", "1");
+ Services.startup.quit(Ci.nsIAppStartup.eAttemptQuit | Ci.nsIAppStartup.eRestart);
+}
+
exports.NewWebConsoleFrame = NewWebConsoleFrame;