Bug 1134268 - Part 2 - Fixup TelemetryEnvironment shutdown if the module wasnt initialized. r=vladan

This commit is contained in:
Georg Fritzsche 2015-02-25 23:54:33 +01:00
parent 54d2e0dda2
commit 159334c163
2 changed files with 10 additions and 4 deletions

View File

@ -261,8 +261,12 @@ this.TelemetryEnvironment = {
*/
shutdown: Task.async(function* () {
if (this._shutdown) {
this._log.error("shutdown - Already shut down");
throw new Error("Already shut down");
if (this._log) {
this._log.error("shutdown - Already shut down");
} else {
Cu.reportError("TelemetryEnvironment.shutdown - Already shut down");
}
return;
}
this._log.trace("shutdown");

View File

@ -615,8 +615,10 @@ add_task(function* test_initAndShutdown() {
TelemetryEnvironment.registerChangeListener("foo", () => {});
TelemetryEnvironment.unregisterChangeListener("foo");
// Other calls after shutdown should reject.
Assert.ok(yield isRejected(TelemetryEnvironment.shutdown()));
// Shutting down again should be ignored.
yield TelemetryEnvironment.shutdown();
// Getting the environment data should reject after shutdown.
Assert.ok(yield isRejected(TelemetryEnvironment.getEnvironmentData()));
});