Bug 1346316 - Add URL and title to Browser Content Toolbox. r=ochameau
MozReview-Commit-ID: DB3GYavw5WV
--- a/devtools/server/actors/child-process.js
+++ b/devtools/server/actors/child-process.js
@@ -25,22 +25,23 @@ function ChildProcessActor(connection, o
// Use a see-everything debugger
this.makeDebugger = makeDebugger.bind(null, {
findDebuggees: dbg => dbg.findAllGlobals(),
shouldAddNewGlobalAsDebuggee: global => true
});
let sandboxPrototype = {};
if (outerWindowID) {
- let currentWindow = Services.wm.getOuterWindowWithId(outerWindowID);
- if (currentWindow) {
- let contentMM = currentWindow.QueryInterface(Ci.nsIInterfaceRequestor)
- .getInterface(Ci.nsIDocShell)
- .QueryInterface(Ci.nsIInterfaceRequestor)
- .getInterface(Ci.nsIContentFrameMessageManager);
+ this._currentWindow = Services.wm.getOuterWindowWithId(outerWindowID);
+ if (this._currentWindow) {
+ let contentMM = this._currentWindow
+ .QueryInterface(Ci.nsIInterfaceRequestor)
+ .getInterface(Ci.nsIDocShell)
+ .QueryInterface(Ci.nsIInterfaceRequestor)
+ .getInterface(Ci.nsIContentFrameMessageManager);
sandboxPrototype = contentMM;
}
}
// Scope into which the webconsole executes:
// If an outerWindowID was supplied, then a chrome sandbox that has the content frame
// message manager as its prototype (similar to the frame script environement).
// If there's no outerWindowID, then this will be an empty chrome sandbox.
@@ -63,47 +64,85 @@ ChildProcessActor.prototype = {
get isRootActor() {
return true;
},
get exited() {
return !this._contextPool;
},
- get url() {
- return undefined;
- },
-
get window() {
return this._consoleScope;
},
get sources() {
if (!this._sources) {
assert(this.threadActor, "threadActor should exist when creating sources.");
this._sources = new TabSources(this.threadActor);
}
return this._sources;
},
+ get docShell() {
+ if (!this._currentWindow) {
+ return null;
+ }
+ return this._currentWindow
+ .QueryInterface(Ci.nsIInterfaceRequestor)
+ .getInterface(Ci.nsIDocShell);
+ },
+
+ get webNavigation() {
+ if (!this.docShell) {
+ return null;
+ }
+ return this.docShell
+ .QueryInterface(Ci.nsIInterfaceRequestor)
+ .getInterface(Ci.nsIWebNavigation);
+ },
+
+ get contentDocument() {
+ if (!this.webNavigation) {
+ return null;
+ }
+ return this.webNavigation.document;
+ },
+
+ get title() {
+ if (!this.contentDocument) {
+ return null;
+ }
+ return this.contentDocument.title;
+ },
+
+ get url() {
+ if (!this.webNavigation || !this.webNavigation.currentURI) {
+ return null;
+ }
+ return this.webNavigation.currentURI.spec;
+ },
+
form: function () {
if (!this._consoleActor) {
this._consoleActor = new WebConsoleActor(this.conn, this);
this._contextPool.addActor(this._consoleActor);
}
if (!this.threadActor) {
this.threadActor = new ChromeDebuggerActor(this.conn, this);
this._contextPool.addActor(this.threadActor);
}
return {
actor: this.actorID,
name: "Content process",
+ url: this.url,
+ title: this.title,
+
consoleActor: this._consoleActor.actorID,
chromeDebugger: this.threadActor.actorID,
traits: {
highlightable: false,
networkMonitor: false,
},
};
@@ -133,16 +172,18 @@ ChildProcessActor.prototype = {
},
_onWorkerListChanged: function () {
this.conn.send({ from: this.actorID, type: "workerListChanged" });
this._workerList.onListChanged = null;
},
destroy: function () {
+ this._currentWindow = null;
+
this.conn.removeActorPool(this._contextPool);
this._contextPool = null;
// Tell the live lists we aren't watching any more.
if (this._workerList) {
this._workerList.onListChanged = null;
}
},