Skip to content
This repository has been archived by the owner on Aug 4, 2022. It is now read-only.

Commit

Permalink
Bug 810543 - Testing the behavior of OS.Constants.Path.profileDir;r=f…
Browse files Browse the repository at this point in the history
…roydnj
  • Loading branch information
David Rajchenbach-Teller committed Dec 11, 2012
1 parent 86738d2 commit dbb2f46
Showing 1 changed file with 22 additions and 10 deletions.
32 changes: 22 additions & 10 deletions testing/xpcshell/head.js
Original file line number Diff line number Diff line change
Expand Up @@ -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" : "";
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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();
}

Expand Down

0 comments on commit dbb2f46

Please sign in to comment.