Backed out changeset 5e82a8ce4862 - bug 459114 - helper function to provide a clean profile directory for xpcshell tests. r=sdwilsh - for test failures
authorTed Mielczarek <ted.mielczarek@gmail.com>
Wed, 05 Aug 2009 15:36:20 -0400
changeset 26281 76e33161580e382c7a20b6b63d65215d0f1aad8e
parent 26280 5e82a8ce486243db2244c981ea1588ec66303965
child 26282 43af583d6464a628236e26c258d6535e3890141d
push id1834
push userclokep@gmail.com
push dateMon, 23 Jan 2017 21:48:40 +0000
treeherdercomm-beta@293cffe83e59 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssdwilsh
bugs459114
backs out5e82a8ce486243db2244c981ea1588ec66303965
Backed out changeset 5e82a8ce4862 - bug 459114 - helper function to provide a clean profile directory for xpcshell tests. r=sdwilsh - for test failures
suite/common/places/tests/autocomplete/head_000.js
--- a/suite/common/places/tests/autocomplete/head_000.js
+++ b/suite/common/places/tests/autocomplete/head_000.js
@@ -38,38 +38,48 @@
 
 const NS_APP_USER_PROFILE_50_DIR = "ProfD";
 const NS_APP_HISTORY_50_FILE = "UHist";
 
 const Ci = Components.interfaces;
 const Cc = Components.classes;
 const Cr = Components.results;
 
-var profDir = do_get_profile();
-
+// If there's no location registered for the profile direcotry, register one now.
 let dirSvc = Cc["@mozilla.org/file/directory_service;1"].getService(Ci.nsIProperties);
-let provider = {
-  getFile: function(prop, persistent) {
-    persistent.value = true;
-    if (prop == NS_APP_HISTORY_50_FILE) {
-      let histFile = profDir.clone();
-      histFile.append("history.dat");
-      return histFile;
+let profileDir = null;
+try {
+  profileDir = dirSvc.get(NS_APP_USER_PROFILE_50_DIR, Ci.nsIFile);
+} catch (e) {}
+if (!profileDir) {
+  // Register our own provider for the profile directory.
+  // It will simply return the current directory.
+  let provider = {
+    getFile: function(prop, persistent) {
+      persistent.value = true;
+      if (prop == NS_APP_USER_PROFILE_50_DIR) {
+        return dirSvc.get("CurProcD", Ci.nsIFile);
+      }
+      if (prop == NS_APP_HISTORY_50_FILE) {
+        let histFile = dirSvc.get("CurProcD", Ci.nsIFile);
+        histFile.append("history.dat");
+        return histFile;
+      }
+      throw Cr.NS_ERROR_FAILURE;
+    },
+    QueryInterface: function(iid) {
+      if (iid.equals(Ci.nsIDirectoryServiceProvider) ||
+          iid.equals(Ci.nsISupports)) {
+        return this;
+      }
+      throw Cr.NS_ERROR_NO_INTERFACE;
     }
-    throw Cr.NS_ERROR_FAILURE;
-  },
-  QueryInterface: function(iid) {
-    if (iid.equals(Ci.nsIDirectoryServiceProvider) ||
-        iid.equals(Ci.nsISupports)) {
-      return this;
-    }
-    throw Cr.NS_ERROR_NO_INTERFACE;
-  }
-};
-dirSvc.QueryInterface(Ci.nsIDirectoryService).registerProvider(provider);
+  };
+  dirSvc.QueryInterface(Ci.nsIDirectoryService).registerProvider(provider);
+}
 
 // Delete a previously created sqlite file
 function clearDB() {
   try {
     let file = dirSvc.get('ProfD', Ci.nsIFile);
     file.append("places.sqlite");
     if (file.exists())
       file.remove(false);