Bug 1307765 - Implement about:devtools-toolbox URL parameter in the console. r=nchevobbe
MozReview-Commit-ID: 9d45naaWI2K
--- a/devtools/client/webconsole/webconsole.xul
+++ b/devtools/client/webconsole/webconsole.xul
@@ -26,20 +26,45 @@
<script type="application/javascript"
src="chrome://devtools/content/shared/theme-switching.js"/>
<script type="application/javascript"
src="resource://devtools/client/webconsole/new-console-output/main.js"/>
<script type="text/javascript" src="chrome://global/content/globalOverlay.js"/>
<script type="text/javascript" src="resource://devtools/client/webconsole/net/main.js"/>
<script type="text/javascript"><![CDATA[
-function goUpdateConsoleCommands() {
- goUpdateCommand("consoleCmd_openURL");
- goUpdateCommand("consoleCmd_copyURL");
-}
+ function goUpdateConsoleCommands() {
+ goUpdateCommand("consoleCmd_openURL");
+ goUpdateCommand("consoleCmd_copyURL");
+ }
+
+ // Implement support for chrome://devtools/content/webconsole/webconsole.xul?type=tab&id=1234 URLs
+ // where 1234 is the tab id, you can retrieve from about:debugging#tabs links.
+ // Simply copy the id from about:devtools-toolbox?type=tab&id=1234 URLs.
+
+ // URL constructor doesn't support chrome: scheme
+ let href = window.location.href.replace(/chrome:/, "http://");
+ let url = new window.URL(href);
+
+ // If query parameters are given in a chrome tab, the inspector is running in standalone.
+ if (window.location.protocol === "chrome:" && url.search.length > 1) {
+ const { targetFromURL } = require("devtools/client/framework/target-from-url");
+ const HUDService = require("devtools/client/webconsole/hudservice");
+ const { Ci } = require("chrome");
+
+ (async function () {
+ let target = await targetFromURL(url);
+ let utils = window.QueryInterface(Ci.nsIInterfaceRequestor)
+ .getInterface(Ci.nsIDOMWindowUtils);
+ let chromeWindow = utils.containerElement.ownerGlobal;
+ HUDService.openWebConsole(target, window, chromeWindow);
+ })().catch(e => {
+ window.alert("Unable to start the console:" + e.message + "\n" + e.stack);
+ });
+ }
// ]]></script>
<commandset id="editMenuCommands"/>
<commandset id="consoleCommands"
commandupdater="true"
events="focus,select"
oncommandupdate="goUpdateConsoleCommands();">