Bug 886263 - Make places be enabled by default in all xpcshell-tests to avoid having to set it in lots of places (so that tests work with apps where places is disabled by default). r=mak,a=bajaj
authorMark Banner <bugzilla@standard8.plus.com>
Wed, 26 Jun 2013 14:56:11 +0100
changeset 147799 2d506101638507b16c5813975fe49a696c0be975
parent 147798 cd11b56ef7c9581b9cc25fd41127976e840b7bb3
child 147800 5309228d21a6a19911dd5046b42e7fe3fd39334f
push id2697
push userbbajaj@mozilla.com
push dateMon, 05 Aug 2013 18:49:53 +0000
treeherdermozilla-beta@dfec938c7b63 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmak, bajaj
bugs886263
milestone24.0a2
Bug 886263 - Make places be enabled by default in all xpcshell-tests to avoid having to set it in lots of places (so that tests work with apps where places is disabled by default). r=mak,a=bajaj
docshell/test/unit/test_nsIDownloadHistory.js
testing/xpcshell/head.js
toolkit/components/downloads/test/unit/test_history_expiration.js
toolkit/components/places/tests/head_common.js
toolkit/components/social/test/xpcshell/head.js
toolkit/forgetaboutsite/test/unit/test_removeDataFromDomain.js
--- a/docshell/test/unit/test_nsIDownloadHistory.js
+++ b/docshell/test/unit/test_nsIDownloadHistory.js
@@ -56,15 +56,13 @@ function run_test()
   }
   catch (ex) {
     return;
   }
 
   // Needed to properly setup and shutdown the profile.
   do_get_profile();
 
-  Services.prefs.setBoolPref("places.history.enabled", true);
-
   for (var i = 0; i < tests.length; i++)
     tests[i]();
 
   cleanup();
 }
--- a/testing/xpcshell/head.js
+++ b/testing/xpcshell/head.js
@@ -40,16 +40,27 @@ let (ios = Components.classes["@mozilla.
 let runningInParent = true;
 try {
   runningInParent = Components.classes["@mozilla.org/xre/runtime;1"].
                     getService(Components.interfaces.nsIXULRuntime).processType
                     == Components.interfaces.nsIXULRuntime.PROCESS_TYPE_DEFAULT;
 } 
 catch (e) { }
 
+// Only if building of places is enabled.
+if (runningInParent &&
+    "mozIAsyncHistory" in Components.interfaces) {
+  // Ensure places history is enabled for xpcshell-tests as some non-FF
+  // apps disable it.
+  let (prefs = Components.classes["@mozilla.org/preferences-service;1"]
+               .getService(Components.interfaces.nsIPrefBranch)) {
+    prefs.setBoolPref("places.history.enabled", true);
+  };
+}
+
 try {
   if (runningInParent) {
     let prefs = Components.classes["@mozilla.org/preferences-service;1"]
                 .getService(Components.interfaces.nsIPrefBranch);
 
     // disable necko IPC security checks for xpcshell, as they lack the
     // docshells needed to pass them
     prefs.setBoolPref("network.disable.ipc.security", true);
--- a/toolkit/components/downloads/test/unit/test_history_expiration.js
+++ b/toolkit/components/downloads/test/unit/test_history_expiration.js
@@ -31,19 +31,16 @@ function run_test()
 
 add_task(function test_execute()
 {
   // Like the code, we check to see if nav-history-service exists
   // (i.e MOZ_PLACES is enabled), so that we don't run this test if it doesn't.
   if (!("@mozilla.org/browser/nav-history-service;1" in Cc))
     return;
 
-  // Ensure places is enabled.
-  Services.prefs.setBoolPref("places.history.enabled", true);
-
   let dm = Cc["@mozilla.org/download-manager;1"].
            getService(Ci.nsIDownloadManager);
   let db = dm.DBConnection;
 
   // Empty any old downloads
   db.executeSimpleSQL("DELETE FROM moz_downloads");
 
   let stmt = db.createStatement(
--- a/toolkit/components/places/tests/head_common.js
+++ b/toolkit/components/places/tests/head_common.js
@@ -50,19 +50,16 @@ XPCOMUtils.defineLazyGetter(this, "SMALL
 function LOG(aMsg) {
   aMsg = ("*** PLACES TESTS: " + aMsg);
   Services.console.logStringMessage(aMsg);
   print(aMsg);
 }
 
 let gTestDir = do_get_cwd();
 
-// Ensure history is enabled.
-Services.prefs.setBoolPref("places.history.enabled", true);
-
 // Initialize profile.
 let gProfD = do_get_profile();
 
 // Remove any old database.
 clearDB();
 
 /**
  * Shortcut to create a nsIURI.
--- a/toolkit/components/social/test/xpcshell/head.js
+++ b/toolkit/components/social/test/xpcshell/head.js
@@ -1,19 +1,16 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this file,
  * You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 const { classes: Cc, interfaces: Ci, utils: Cu, results: Cr } = Components;
 Cu.import("resource://gre/modules/Services.jsm");
 Cu.import("resource://gre/modules/XPCOMUtils.jsm");
 
-// Ensure history is enabled.
-Services.prefs.setBoolPref("places.history.enabled", true);
-
 XPCOMUtils.defineLazyModuleGetter(this, "Promise",
   "resource://gre/modules/commonjs/sdk/core/promise.js");
 XPCOMUtils.defineLazyModuleGetter(this, "PlacesUtils",
   "resource://gre/modules/PlacesUtils.jsm");
 
 const MANIFEST_PREFS = Services.prefs.getBranch("social.manifest.");
 const gProfD = do_get_profile();
 
--- a/toolkit/forgetaboutsite/test/unit/test_removeDataFromDomain.js
+++ b/toolkit/forgetaboutsite/test/unit/test_removeDataFromDomain.js
@@ -728,15 +728,13 @@ let tests = [
   test_storage_cleared,
 
   // Cache
   test_cache_cleared,
 ];
 
 function run_test()
 {
-  Services.prefs.setBoolPref("places.history.enabled", true);
-
   for (let i = 0; i < tests.length; i++)
     add_task(tests[i]);
 
   run_next_test();
 }