Bug 1304941 - reject update promise in BrowserTabActor destroy;r=jryans

MozReview-Commit-ID: LNclCPv1Zo

--HG--
extra : rebase_source : 22f3a1b0099641990b73861088c62312b948fd97
This commit is contained in:
Julian Descottes 2017-02-10 23:43:37 +01:00
Родитель 5be1442c92
Коммит f665f5b5a6
1 изменённых файлов: 22 добавлений и 4 удалений

Просмотреть файл

@ -283,6 +283,14 @@ BrowserTabList.prototype.getList = function () {
// Set the 'selected' properties on all actors correctly.
actor.selected = selected;
return actor;
}, e => {
if (e.error === "tabDestroyed") {
// Return null if a tab was destroyed while retrieving the tab list.
return null;
}
// Forward unexpected errors.
throw e;
})
);
}
@ -294,7 +302,10 @@ BrowserTabList.prototype.getList = function () {
this._mustNotify = true;
this._checkListening();
return promise.all(actorPromises);
return promise.all(actorPromises).then(values => {
// Filter out null values if we received a tabDestroyed error.
return values.filter(value => value != null);
});
};
BrowserTabList.prototype._getActorForBrowser = function (browser) {
@ -694,6 +705,13 @@ function BrowserTabActor(connection, browser) {
BrowserTabActor.prototype = {
connect() {
let onDestroy = () => {
if (this._deferredUpdate) {
// Reject the update promise if the tab was destroyed while requesting an update
this._deferredUpdate.reject({
error: "tabDestroyed",
message: "Tab destroyed while performing a BrowserTabActor update"
});
}
this._form = null;
};
let connect = DebuggerServer.connectToChild(this._conn, this._browser, onDestroy);
@ -722,7 +740,7 @@ BrowserTabActor.prototype = {
// so only request form update if some code is still listening on the other
// side.
if (this._form) {
let deferred = promise.defer();
this._deferredUpdate = promise.defer();
let onFormUpdate = msg => {
// There may be more than just one childtab.js up and running
if (this._form.actor != msg.json.actor) {
@ -730,11 +748,11 @@ BrowserTabActor.prototype = {
}
this._mm.removeMessageListener("debug:form", onFormUpdate);
this._form = msg.json;
deferred.resolve(this);
this._deferredUpdate.resolve(this);
};
this._mm.addMessageListener("debug:form", onFormUpdate);
this._mm.sendAsyncMessage("debug:form");
return deferred.promise;
return this._deferredUpdate.promise;
}
return this.connect();