Bug 1244723 - xpcshell should shutdown profile after all the registered cleanup functions, not before them. r=ted

This commit is contained in:
Marco Bonardo 2016-02-03 12:35:07 +01:00
parent 3f7102cf80
commit d4b2a19a2a

View File

@ -613,6 +613,18 @@ function _execute_test() {
// Restore idle service to avoid leaks.
_fakeIdleService.deactivate();
if (_profileInitialized) {
// Since we have a profile, we will notify profile shutdown topics at
// the end of the current test, to ensure correct cleanup on shutdown.
let obs = Components.classes["@mozilla.org/observer-service;1"]
.getService(Components.interfaces.nsIObserverService);
obs.notifyObservers(null, "profile-change-net-teardown", null);
obs.notifyObservers(null, "profile-change-teardown", null);
obs.notifyObservers(null, "profile-before-change", null);
_profileInitialized = false;
}
if (!_passed)
return;
}
@ -1145,18 +1157,6 @@ function do_get_profile(notifyProfileAfterChange = false) {
return null;
}
if (!_profileInitialized) {
// Since we have a profile, we will notify profile shutdown topics at
// the end of the current test, to ensure correct cleanup on shutdown.
do_register_cleanup(function() {
let obsSvc = Components.classes["@mozilla.org/observer-service;1"].
getService(Components.interfaces.nsIObserverService);
obsSvc.notifyObservers(null, "profile-change-net-teardown", null);
obsSvc.notifyObservers(null, "profile-change-teardown", null);
obsSvc.notifyObservers(null, "profile-before-change", null);
});
}
let env = Components.classes["@mozilla.org/process/environment;1"]
.getService(Components.interfaces.nsIEnvironment);
// the python harness sets this in the environment for us