bug 459114 - helper function to provide a clean profile directory for xpcshell tests. r=sdwilsh
☠☠ backed out by 76e33161580e ☠ ☠
authorTed Mielczarek <ted.mielczarek@gmail.com>
Thu, 14 May 2009 07:37:40 -0400
changeset 26280 5e82a8ce486243db2244c981ea1588ec66303965
parent 26279 b307a643012f62992fe9cd72f1dc9db8961481b3
child 26281 76e33161580e382c7a20b6b63d65215d0f1aad8e
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
bug 459114 - helper function to provide a clean profile directory for xpcshell tests. r=sdwilsh
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,48 +38,38 @@
 
 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;
 
-// If there's no location registered for the profile direcotry, register one now.
+var profDir = do_get_profile();
+
 let dirSvc = Cc["@mozilla.org/file/directory_service;1"].getService(Ci.nsIProperties);
-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;
+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;
     }
-  };
-  dirSvc.QueryInterface(Ci.nsIDirectoryService).registerProvider(provider);
-}
+    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);
 
 // 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);