Bug 1302148 - Fix potential race in toolbox.destroy. r=bgrins

MozReview-Commit-ID: 8qSwjLVrRL6

--HG--
extra : rebase_source : 45367a73594c19b20b40e0bb62b4018ff0a83303
This commit is contained in:
Alexandre Poirot 2016-09-12 02:44:17 -07:00
Родитель fa55fd3615
Коммит 05b003282b
1 изменённых файлов: 4 добавлений и 2 удалений

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

@ -2048,6 +2048,8 @@ Toolbox.prototype = {
if (this._destroyer) {
return this._destroyer;
}
let deferred = defer();
this._destroyer = deferred.promise;
this.emit("destroy");
@ -2143,7 +2145,7 @@ Toolbox.prototype = {
// Finish all outstanding tasks (which means finish destroying panels and
// then destroying the host, successfully or not) before destroying the
// target.
this._destroyer = settleAll(outstanding)
deferred.resolve(settleAll(outstanding)
.catch(console.error)
.then(() => this.destroyHost())
.catch(console.error)
@ -2177,7 +2179,7 @@ Toolbox.prototype = {
.getInterface(Ci.nsIDOMWindowUtils)
.garbageCollect();
}
}).then(null, console.error);
}).then(null, console.error));
let leakCheckObserver = ({wrappedJSObject: barrier}) => {
// Make the leak detector wait until this toolbox is properly destroyed.