From 11769462eef6b53111a2cb94f76a44699dbb5385 Mon Sep 17 00:00:00 2001 From: Mark Banner Date: Wed, 26 Jun 2013 10:06:30 +0100 Subject: [PATCH] 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 --- docshell/test/unit/test_nsIDownloadHistory.js | 2 -- testing/xpcshell/head.js | 10 ++++++++++ .../downloads/test/unit/test_history_expiration.js | 3 --- toolkit/components/places/tests/head_common.js | 3 --- toolkit/components/social/test/xpcshell/head.js | 3 --- .../test/unit/test_removeDataFromDomain.js | 2 -- 6 files changed, 10 insertions(+), 13 deletions(-) diff --git a/docshell/test/unit/test_nsIDownloadHistory.js b/docshell/test/unit/test_nsIDownloadHistory.js index 63db845086e2..2030f0702cef 100644 --- a/docshell/test/unit/test_nsIDownloadHistory.js +++ b/docshell/test/unit/test_nsIDownloadHistory.js @@ -61,8 +61,6 @@ function run_test() // 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](); diff --git a/testing/xpcshell/head.js b/testing/xpcshell/head.js index 6f99d4ea4390..112c0c85b685 100644 --- a/testing/xpcshell/head.js +++ b/testing/xpcshell/head.js @@ -36,6 +36,16 @@ let (ios = Components.classes["@mozilla.org/network/io-service;1"] ios.offline = false; } +// Only if building of places is enabled. +if ("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); + }; +} + // Determine if we're running on parent or child let runningInParent = true; try { diff --git a/toolkit/components/downloads/test/unit/test_history_expiration.js b/toolkit/components/downloads/test/unit/test_history_expiration.js index bd71f391ed3d..d7bc2407aa62 100644 --- a/toolkit/components/downloads/test/unit/test_history_expiration.js +++ b/toolkit/components/downloads/test/unit/test_history_expiration.js @@ -36,9 +36,6 @@ add_task(function test_execute() 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; diff --git a/toolkit/components/places/tests/head_common.js b/toolkit/components/places/tests/head_common.js index 8f1956b221d6..e19429a08d9e 100644 --- a/toolkit/components/places/tests/head_common.js +++ b/toolkit/components/places/tests/head_common.js @@ -55,9 +55,6 @@ function LOG(aMsg) { let gTestDir = do_get_cwd(); -// Ensure history is enabled. -Services.prefs.setBoolPref("places.history.enabled", true); - // Initialize profile. let gProfD = do_get_profile(); diff --git a/toolkit/components/social/test/xpcshell/head.js b/toolkit/components/social/test/xpcshell/head.js index e1c7d57f000b..1bf261d668f7 100644 --- a/toolkit/components/social/test/xpcshell/head.js +++ b/toolkit/components/social/test/xpcshell/head.js @@ -6,9 +6,6 @@ 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", diff --git a/toolkit/forgetaboutsite/test/unit/test_removeDataFromDomain.js b/toolkit/forgetaboutsite/test/unit/test_removeDataFromDomain.js index ab10e8a598e2..26c2234e444f 100644 --- a/toolkit/forgetaboutsite/test/unit/test_removeDataFromDomain.js +++ b/toolkit/forgetaboutsite/test/unit/test_removeDataFromDomain.js @@ -733,8 +733,6 @@ let tests = [ function run_test() { - Services.prefs.setBoolPref("places.history.enabled", true); - for (let i = 0; i < tests.length; i++) add_task(tests[i]);