Bug 989137 - Part 18: Fix experiments uninit behavior. r=bsmedberg

This commit is contained in:
Georg Fritzsche 2014-04-17 15:47:37 +02:00
parent ceb826d852
commit 17b11996ae
2 changed files with 15 additions and 2 deletions

View File

@ -327,6 +327,14 @@ Experiments.Policy.prototype = {
},
};
function AlreadyShutdownError(message="already shut down") {
this.name = "AlreadyShutdownError";
this.message = message;
}
AlreadyShutdownError.prototype = new Error();
AlreadyShutdownError.prototype.constructor = AlreadyShutdownError;
/**
* Manages the experiments and provides an interface to control them.
*/
@ -434,7 +442,11 @@ Experiments.Experiments.prototype = {
this._shutdown = true;
if (this._mainTask) {
yield this._mainTask;
try {
yield this._mainTask;
} catch (e if e instanceof AlreadyShutdownError) {
// We error out of tasks after shutdown via that exception.
}
}
this._log.info("Completed uninitialization.");
@ -457,7 +469,7 @@ Experiments.Experiments.prototype = {
*/
_checkForShutdown: function() {
if (this._shutdown) {
throw Error("uninit() already called");
throw new AlreadyShutdownError("uninit() already called");
}
},

View File

@ -39,6 +39,7 @@ add_task(function* initializeState() {
// this test running. We have to initialize the instance first, then
// uninitialize it to prevent this.
gExperiments = tmp.Experiments.instance();
yield gExperiments._mainTask;
yield gExperiments.uninit();
}
});