Bug 883603 - Don't reply to getWalker request until DOM content is loaded. r=paul

This commit is contained in:
Dave Camp 2013-06-17 06:52:51 -07:00
parent fee8937e4e
commit 71d54a5b47

View File

@ -1615,16 +1615,36 @@ var InspectorActor = protocol.ActorClass({
initialize: function(conn, tabActor) {
protocol.Actor.prototype.initialize.call(this, conn);
this.tabActor = tabActor;
},
get window() {
let tabActor = this.tabActor;
if (tabActor.browser instanceof Ci.nsIDOMWindow) {
this.window = tabActor.browser;
return tabActor.browser;
} else if (tabActor.browser instanceof Ci.nsIDOMElement) {
this.window = tabActor.browser.contentWindow;
return tabActor.browser.contentWindow;
}
this.webProgress = tabActor._tabbrowser;
return null;
},
getWalker: method(function(options={}) {
return WalkerActor(this.conn, this.window.document, this.webProgress, options);
let deferred = promise.defer();
let window = this.window;
var domReady = () => {
let tabActor = this.tabActor;
window.removeEventListener("DOMContentLoaded", domReady, true);
deferred.resolve(WalkerActor(this.conn, window.document, tabActor._tabbrowser, options));
};
if (window.document.readyState === "loading") {
window.addEventListener("DOMContentLoaded", domReady, true);
} else {
domReady();
}
return deferred.promise;
}, {
request: {},
response: {