mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-01-23 13:04:28 +00:00
Bug 810543 - Testing the behavior of OS.Constants.Path.profileDir;r=froydnj
This commit is contained in:
parent
d4de9b2c67
commit
f0a0fc99a0
@ -17,6 +17,7 @@ var _passedChecks = 0, _falsePassedChecks = 0;
|
||||
var _todoChecks = 0;
|
||||
var _cleanupFunctions = [];
|
||||
var _pendingTimers = [];
|
||||
var _profileInitialized = false;
|
||||
|
||||
function _dump(str) {
|
||||
let start = /^TEST-/.test(str) ? "\n" : "";
|
||||
@ -728,15 +729,17 @@ function do_register_cleanup(aFunction)
|
||||
* @return nsILocalFile of the profile directory.
|
||||
*/
|
||||
function do_get_profile() {
|
||||
// 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);
|
||||
});
|
||||
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);
|
||||
@ -768,12 +771,21 @@ function do_get_profile() {
|
||||
dirSvc.QueryInterface(Components.interfaces.nsIDirectoryService)
|
||||
.registerProvider(provider);
|
||||
|
||||
// The methods of 'provider' will entrain this scope so null out everything
|
||||
let obsSvc = Components.classes["@mozilla.org/observer-service;1"].
|
||||
getService(Components.interfaces.nsIObserverService);
|
||||
|
||||
if (!_profileInitialized) {
|
||||
obsSvc.notifyObservers(null, "profile-do-change", "xpcshell-do-get-profile");
|
||||
_profileInitialized = true;
|
||||
}
|
||||
|
||||
// The methods of 'provider' will retain this scope so null out everything
|
||||
// to avoid spurious leak reports.
|
||||
env = null;
|
||||
profd = null;
|
||||
dirSvc = null;
|
||||
provider = null;
|
||||
obsSvc = null;
|
||||
return file.clone();
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user