mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-27 06:43:32 +00:00
Bug 860672 - Command line option -jsconsole should open the Browser Console. r=robcee
This commit is contained in:
parent
fc5271e9ca
commit
147edc04a3
40
browser/devtools/devtools-clhandler.js
Normal file
40
browser/devtools/devtools-clhandler.js
Normal file
@ -0,0 +1,40 @@
|
||||
/* 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/. */
|
||||
|
||||
const { classes: Cc, interfaces: Ci, utils: Cu } = Components;
|
||||
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
|
||||
function devtoolsCommandlineHandler() {
|
||||
}
|
||||
devtoolsCommandlineHandler.prototype = {
|
||||
handle: function(cmdLine) {
|
||||
if (!cmdLine.handleFlag("jsconsole", false)) {
|
||||
return;
|
||||
}
|
||||
|
||||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
let window = Services.wm.getMostRecentWindow("devtools:webconsole");
|
||||
if (!window) {
|
||||
let devtools = Cu.import("resource://gre/modules/devtools/Loader.jsm", {}).devtools;
|
||||
// Load the browser devtools main module as the loader's main module.
|
||||
devtools.main("main");
|
||||
let hudservice = devtools.require("devtools/webconsole/hudservice");
|
||||
let console = Cu.import("resource://gre/modules/devtools/Console.jsm", {}).console;
|
||||
hudservice.toggleBrowserConsole().then(null, console.error);
|
||||
} else {
|
||||
window.focus(); // the Browser Console was already open
|
||||
}
|
||||
|
||||
if (cmdLine.state == Ci.nsICommandLine.STATE_REMOTE_AUTO) {
|
||||
cmdLine.preventDefault = true;
|
||||
}
|
||||
},
|
||||
|
||||
helpInfo : " -jsconsole Open the Browser Console.\n",
|
||||
|
||||
classID: Components.ID("{9e9a9283-0ce9-4e4a-8f1c-ba129a032c32}"),
|
||||
QueryInterface: XPCOMUtils.generateQI([Ci.nsICommandLineHandler]),
|
||||
};
|
||||
|
||||
this.NSGetFactory = XPCOMUtils.generateNSGetFactory([devtoolsCommandlineHandler]);
|
2
browser/devtools/devtools-clhandler.manifest
Normal file
2
browser/devtools/devtools-clhandler.manifest
Normal file
@ -0,0 +1,2 @@
|
||||
component {9e9a9283-0ce9-4e4a-8f1c-ba129a032c32} devtools-clhandler.js
|
||||
contract @mozilla.org/toolkit/console-clh;1 {9e9a9283-0ce9-4e4a-8f1c-ba129a032c32}
|
@ -24,3 +24,8 @@ DIRS += [
|
||||
'fontinspector',
|
||||
'app-manager',
|
||||
]
|
||||
|
||||
EXTRA_COMPONENTS += [
|
||||
'devtools-clhandler.js',
|
||||
'devtools-clhandler.manifest',
|
||||
]
|
||||
|
@ -254,13 +254,14 @@ HUD_SERVICE.prototype =
|
||||
return deferred.promise;
|
||||
}
|
||||
|
||||
connect().then(getTarget).then(openWindow).then((aWindow) =>
|
||||
connect().then(getTarget).then(openWindow).then((aWindow) => {
|
||||
this.openBrowserConsole(target, aWindow, aWindow)
|
||||
.then((aBrowserConsole) => {
|
||||
this._browserConsoleID = aBrowserConsole.hudId;
|
||||
this._browserConsoleDefer.resolve(aBrowserConsole);
|
||||
this._browserConsoleDefer = null;
|
||||
}));
|
||||
})
|
||||
}, console.error);
|
||||
|
||||
return this._browserConsoleDefer.promise;
|
||||
},
|
||||
|
@ -62,7 +62,7 @@ function consoleOpened(hud)
|
||||
let text = output.textContent;
|
||||
chromeConsole = text.indexOf("bug587757a");
|
||||
contentConsole = text.indexOf("bug587757b");
|
||||
execValue = text.indexOf("browser.xul");
|
||||
execValue = text.indexOf("webconsole.xul");
|
||||
exception = text.indexOf("foobarExceptionBug587757");
|
||||
xhrRequest = text.indexOf("test-console.html");
|
||||
}
|
||||
|
@ -24,7 +24,10 @@ function test()
|
||||
ok(hud, "browser console opened");
|
||||
|
||||
hud.jsterm.clearOutput();
|
||||
hud.jsterm.execute("foobarzTezt = content.document", onAddVariable);
|
||||
hud.jsterm.execute("Cu = Components.utils;" +
|
||||
"Cu.import('resource://gre/modules/Services.jsm');" +
|
||||
"chromeWindow = Services.wm.getMostRecentWindow('navigator:browser');" +
|
||||
"foobarzTezt = chromeWindow.content.document", onAddVariable);
|
||||
}
|
||||
|
||||
function onAddVariable()
|
||||
|
@ -185,8 +185,18 @@ function BrowserTabList(aConnection)
|
||||
BrowserTabList.prototype.constructor = BrowserTabList;
|
||||
|
||||
|
||||
/**
|
||||
* Get the selected browser for the given navigator:browser window.
|
||||
* @private
|
||||
* @param aWindow nsIChromeWindow
|
||||
* The navigator:browser window for which you want the selected browser.
|
||||
* @return nsIDOMElement|null
|
||||
* The currently selected xul:browser element, if any. Note that the
|
||||
* browser window might not be loaded yet - the function will return
|
||||
* |null| in such cases.
|
||||
*/
|
||||
BrowserTabList.prototype._getSelectedBrowser = function(aWindow) {
|
||||
return aWindow.gBrowser.selectedBrowser;
|
||||
return aWindow.gBrowser ? aWindow.gBrowser.selectedBrowser : null;
|
||||
};
|
||||
|
||||
BrowserTabList.prototype._getChildren = function(aWindow) {
|
||||
@ -209,6 +219,9 @@ BrowserTabList.prototype.getList = function() {
|
||||
// Iterate over all navigator:browser XUL windows.
|
||||
for (let win of allAppShellDOMWindows(DebuggerServer.chromeWindowType)) {
|
||||
let selectedBrowser = this._getSelectedBrowser(win);
|
||||
if (!selectedBrowser) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// For each tab in this XUL window, ensure that we have an actor for
|
||||
// it, reusing existing actors where possible. We actually iterate
|
||||
|
@ -118,10 +118,18 @@ WebConsoleActor.prototype =
|
||||
conn: null,
|
||||
|
||||
/**
|
||||
* The content window we work with.
|
||||
* The window we work with.
|
||||
* @type nsIDOMWindow
|
||||
*/
|
||||
get window() this.parentActor.window,
|
||||
get window() {
|
||||
if (this.parentActor.isRootActor) {
|
||||
// Try to find the Browser Console window, otherwise use the window of
|
||||
// the root actor.
|
||||
let window = Services.wm.getMostRecentWindow("devtools:webconsole");
|
||||
return window || this.parentActor.window;
|
||||
}
|
||||
return this.parentActor.window;
|
||||
},
|
||||
|
||||
/**
|
||||
* The ConsoleServiceListener instance.
|
||||
|
Loading…
Reference in New Issue
Block a user