diff --git a/toolkit/mozapps/extensions/test/browser/browser_globalwarnings.js b/toolkit/mozapps/extensions/test/browser/browser_globalwarnings.js index 0541f0c9afef..663905a90fd0 100644 --- a/toolkit/mozapps/extensions/test/browser/browser_globalwarnings.js +++ b/toolkit/mozapps/extensions/test/browser/browser_globalwarnings.js @@ -16,23 +16,8 @@ function end_test() { add_test(function() { info("Testing compatibility checking warning"); - var channel = "default"; - try { - channel = Services.prefs.getCharPref("app.update.channel"); - } - catch (e) { } - if (channel != "aurora" && - channel != "beta" && - channel != "release") { - var version = "nightly"; - } - else { - version = Services.appinfo.version.replace(/^([^\.]+\.[0-9]+[a-z]*).*/gi, "$1"); - } - - var pref = "extensions.checkCompatibility." + version; - info("Setting " + pref + " pref to false") - Services.prefs.setBoolPref(pref, false); + info("Setting checkCompatibility to false"); + AddonManager.checkCompatibility = false; open_manager("addons://list/extension", function(aWindow) { var hbox = aWindow.document.querySelector("#list-view hbox.global-warning-checkcompatibility"); @@ -42,7 +27,7 @@ add_test(function() { info("Clicking 'Enable' button"); EventUtils.synthesizeMouse(button, 2, 2, { }, aWindow); - is(Services.prefs.prefHasUserValue(pref), false, "Check Compatibility pref should be cleared"); + is(AddonManager.checkCompatibility, true, "Check Compatibility pref should be cleared"); is_element_hidden(hbox, "Check Compatibility warning hbox should be hidden"); is_element_hidden(button, "Check Compatibility warning button should be hidden"); diff --git a/toolkit/mozapps/extensions/test/browser/browser_searching.js b/toolkit/mozapps/extensions/test/browser/browser_searching.js index 6bfcac66f418..d08fe89f3be8 100644 --- a/toolkit/mozapps/extensions/test/browser/browser_searching.js +++ b/toolkit/mozapps/extensions/test/browser/browser_searching.js @@ -19,22 +19,6 @@ var gProvider; var gServer; var gAddonInstalled = false; -var channel = "default"; -try { - channel = Services.prefs.getCharPref("app.update.channel"); -} -catch (e) { } -if (channel != "aurora" && - channel != "beta" && - channel != "release") { - var version = "nightly"; -} -else { - version = Services.appinfo.version.replace(/^([^\.]+\.[0-9]+[a-z]*).*/gi, "$1"); -} - -const COMPATIBILITY_PREF = "extensions.checkCompatibility." + version; - function test() { requestLongerTimeout(2); // Turn on searching for this test @@ -603,16 +587,16 @@ add_test(function() { // Tests that incompatible add-ons are shown with a warning if compatibility checking is disabled add_test(function() { - Services.prefs.setBoolPref(COMPATIBILITY_PREF, false); + AddonManager.checkCompatibility = false; search("incompatible", false, function() { var item = get_addon_item("remote5"); is_element_visible(item, "Incompatible addon should be visible"); is(item.getAttribute("notification"), "warning", "Compatibility warning should be shown"); - var item = get_addon_item("remote6"); + item = get_addon_item("remote6"); is(item, null, "Addon incompatible with the product should not be visible"); - Services.prefs.clearUserPref(COMPATIBILITY_PREF); + AddonManager.checkCompatibility = true; run_next_test(); }); }); diff --git a/toolkit/mozapps/extensions/test/xpcshell/head_addons.js b/toolkit/mozapps/extensions/test/xpcshell/head_addons.js index 95e77599627d..7ed0bedbaf5e 100644 --- a/toolkit/mozapps/extensions/test/xpcshell/head_addons.js +++ b/toolkit/mozapps/extensions/test/xpcshell/head_addons.js @@ -26,6 +26,16 @@ var gAddonsList; var TEST_UNPACKED = false; +function isNightlyChannel() { + var channel = "default"; + try { + channel = Services.prefs.getCharPref("app.update.channel"); + } + catch (e) { } + + return channel != "aurora" && channel != "beta" && channel != "release" && channel != "esr"; +} + function createAppInfo(id, name, version, platformVersion) { gAppInfo = { // nsIXULAppInfo diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_AddonRepository_compatmode.js b/toolkit/mozapps/extensions/test/xpcshell/test_AddonRepository_compatmode.js index 78d7e4ac6bb2..aaf368ba4f37 100644 --- a/toolkit/mozapps/extensions/test/xpcshell/test_AddonRepository_compatmode.js +++ b/toolkit/mozapps/extensions/test/xpcshell/test_AddonRepository_compatmode.js @@ -15,19 +15,6 @@ function run_test() { do_test_pending(); createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9.2"); - var channel = "default"; - try { - channel = Services.prefs.getCharPref("app.update.channel"); - } catch (e) { } - if (channel != "aurora" && - channel != "beta" && - channel != "release") { - var version = "nightly"; - } else { - version = Services.appinfo.version.replace(/^([^\.]+\.[0-9]+[a-z]*).*/gi, "$1"); - } - COMPATIBILITY_PREF = "extensions.checkCompatibility." + version; - // Create and configure the HTTP server. gServer = new HttpServer(); gServer.registerDirectory("/data/", do_get_file("data")); @@ -84,7 +71,7 @@ function run_test_2() { // Compatibility checking disabled. function run_test_3() { do_print("Testing with all compatibility checking disabled"); - Services.prefs.setBoolPref(COMPATIBILITY_PREF, false); + AddonManager.checkCompatibility = false; AddonRepository.searchAddons("test", 6, { searchSucceeded: function(aAddons) { diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_bug470377_2.js b/toolkit/mozapps/extensions/test/xpcshell/test_bug470377_2.js index 59c6baf50e9a..3deff9ffb30a 100644 --- a/toolkit/mozapps/extensions/test/xpcshell/test_bug470377_2.js +++ b/toolkit/mozapps/extensions/test/xpcshell/test_bug470377_2.js @@ -5,21 +5,8 @@ // Disables security checking our updates which haven't been signed Services.prefs.setBoolPref("extensions.checkUpdateSecurity", false); -// Disables compatibility checking -var channel = "default"; -try { - channel = Services.prefs.getCharPref("app.update.channel"); -} -catch (e) { } -if (channel != "aurora" && - channel != "beta" && - channel != "release") { - Services.prefs.setBoolPref("extensions.checkCompatibility.nightly", false); -} -else { - Services.prefs.setBoolPref("extensions.checkCompatibility.2", false); -} +AddonManager.checkCompatibility = false; var ADDONS = [ "test_bug470377_1", diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_bug470377_3.js b/toolkit/mozapps/extensions/test/xpcshell/test_bug470377_3.js index 7c398c44d6d8..f20fdc5e2c4b 100644 --- a/toolkit/mozapps/extensions/test/xpcshell/test_bug470377_3.js +++ b/toolkit/mozapps/extensions/test/xpcshell/test_bug470377_3.js @@ -69,21 +69,8 @@ function run_test_1() { } function run_test_2() { - // Disable compatibility checks - var channel = "default"; - try { - channel = Services.prefs.getCharPref("app.update.channel"); - } - catch (e) { } + AddonManager.checkCompatibility = false; - if (channel != "aurora" && - channel != "beta" && - channel != "release") { - Services.prefs.setBoolPref("extensions.checkCompatibility.nightly", false); - } - else { - Services.prefs.setBoolPref("extensions.checkCompatibility.2.2", false); - } restartManager(); AddonManager.getAddonsByIDs(["bug470377_1@tests.mozilla.org", diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_bug470377_3_strictcompat.js b/toolkit/mozapps/extensions/test/xpcshell/test_bug470377_3_strictcompat.js index c7acfeb3b6ba..d293ae87de1a 100644 --- a/toolkit/mozapps/extensions/test/xpcshell/test_bug470377_3_strictcompat.js +++ b/toolkit/mozapps/extensions/test/xpcshell/test_bug470377_3_strictcompat.js @@ -68,21 +68,8 @@ function run_test_1() { } function run_test_2() { - // Disable compatibility checks - var channel = "default"; - try { - channel = Services.prefs.getCharPref("app.update.channel"); - } - catch (e) { } + AddonManager.checkCompatibility = false; - if (channel != "aurora" && - channel != "beta" && - channel != "release") { - Services.prefs.setBoolPref("extensions.checkCompatibility.nightly", false); - } - else { - Services.prefs.setBoolPref("extensions.checkCompatibility.2.2", false); - } restartManager(); AddonManager.getAddonsByIDs(["bug470377_1@tests.mozilla.org", diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_bug470377_4.js b/toolkit/mozapps/extensions/test/xpcshell/test_bug470377_4.js index 2a4d66494a63..378043597e1b 100644 --- a/toolkit/mozapps/extensions/test/xpcshell/test_bug470377_4.js +++ b/toolkit/mozapps/extensions/test/xpcshell/test_bug470377_4.js @@ -3,21 +3,6 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -var channel = "default"; -try { - channel = Services.prefs.getCharPref("app.update.channel"); -} -catch (e) { } - -if (channel != "aurora" && - channel != "beta" && - channel != "release") { - var checkCompatPref = "extensions.checkCompatibility.nightly"; -} -else { - checkCompatPref = "extensions.checkCompatibility.2.1a"; -} - function run_test() { do_test_pending(); createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "2.1a4", "2"); @@ -55,8 +40,8 @@ function run_test() { } function run_test_1() { - // Disable compatibility checks - Services.prefs.setBoolPref(checkCompatPref, false); + AddonManager.checkCompatibility = false; + startupManager(); AddonManager.getAddonsByIDs(["bug470377_1@tests.mozilla.org", @@ -81,8 +66,8 @@ function run_test_1() { } function run_test_2() { - // Enable compatibility checks - Services.prefs.setBoolPref(checkCompatPref, true); + AddonManager.checkCompatibility = true; + restartManager(); AddonManager.getAddonsByIDs(["bug470377_1@tests.mozilla.org", diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_bug521905.js b/toolkit/mozapps/extensions/test/xpcshell/test_bug521905.js index 1c474947aa66..d978acce5cee 100644 --- a/toolkit/mozapps/extensions/test/xpcshell/test_bug521905.js +++ b/toolkit/mozapps/extensions/test/xpcshell/test_bug521905.js @@ -8,21 +8,12 @@ const ID = "bug521905@tests.mozilla.org"; // Disables security checking our updates which haven't been signed Services.prefs.setBoolPref("extensions.checkUpdateSecurity", false); -// Disables compatibility checking -Services.prefs.setBoolPref("extensions.checkCompatibility.2.0pre", false); +AddonManager.checkCompatibility = false; function run_test() { - var channel = "default"; - try { - channel = Services.prefs.getCharPref("app.update.channel"); - } - catch (e) { } - // This test is only relevant on builds where the version is included in the // checkCompatibility preference name - if (channel != "aurora" && - channel != "beta" && - channel != "release") { + if (isNightlyChannel()) { return; } diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_checkcompatibility.js b/toolkit/mozapps/extensions/test/xpcshell/test_checkcompatibility.js index a49cafc7bd26..b87e3518de05 100644 --- a/toolkit/mozapps/extensions/test/xpcshell/test_checkcompatibility.js +++ b/toolkit/mozapps/extensions/test/xpcshell/test_checkcompatibility.js @@ -69,15 +69,7 @@ function run_test() { writeInstallRDFForExtension(a, profileDir); }); - var channel = "default"; - try { - channel = Services.prefs.getCharPref("app.update.channel"); - } - catch (e) { } - - gIsNightly = channel != "aurora" && - channel != "beta" && - channel != "release"; + gIsNightly = isNightlyChannel(); startupManager(); diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_pref_properties.js b/toolkit/mozapps/extensions/test/xpcshell/test_pref_properties.js index e7961a9fac07..c6a10e7c1772 100644 --- a/toolkit/mozapps/extensions/test/xpcshell/test_pref_properties.js +++ b/toolkit/mozapps/extensions/test/xpcshell/test_pref_properties.js @@ -128,13 +128,7 @@ function run_test() { // AddonManager.checkCompatibility - var channel = "default"; - try { - channel = Services.prefs.getCharPref("app.update.channel"); - } catch (e) { } - if (channel != "aurora" && - channel != "beta" && - channel != "release") { + if (isNightlyChannel()) { var version = "nightly"; } else { version = Services.appinfo.version.replace(/^([^\.]+\.[0-9]+[a-z]*).*/gi, "$1"); diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_update_compatmode.js b/toolkit/mozapps/extensions/test/xpcshell/test_update_compatmode.js index 8842fdc109c4..6128f43cd1d3 100644 --- a/toolkit/mozapps/extensions/test/xpcshell/test_update_compatmode.js +++ b/toolkit/mozapps/extensions/test/xpcshell/test_update_compatmode.js @@ -14,25 +14,10 @@ var testserver; const profileDir = gProfD.clone(); profileDir.append("extensions"); -var COMPATIBILITY_PREF; - function run_test() { do_test_pending(); createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9.2"); - var channel = "default"; - try { - channel = Services.prefs.getCharPref("app.update.channel"); - } catch (e) { } - if (channel != "aurora" && - channel != "beta" && - channel != "release") { - var version = "nightly"; - } else { - version = Services.appinfo.version.replace(/^([^\.]+\.[0-9]+[a-z]*).*/gi, "$1"); - } - COMPATIBILITY_PREF = "extensions.checkCompatibility." + version; - // Create and configure the HTTP server. testserver = new HttpServer(); testserver.registerDirectory("/data/", do_get_file("data")); @@ -174,7 +159,7 @@ function run_test_3() { // Compatibility checking disabled. function run_test_4() { do_print("Testing with all compatibility checking disabled"); - Services.prefs.setBoolPref(COMPATIBILITY_PREF, false); + AddonManager.checkCompatibility = false; AddonManager.getAddonByID("compatmode-ignore@tests.mozilla.org", function(addon) { do_check_neq(addon, null); addon.findUpdates({ diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_updatecheck.js b/toolkit/mozapps/extensions/test/xpcshell/test_updatecheck.js index 0cea7c5251dc..8b7dc4cfbdfb 100644 --- a/toolkit/mozapps/extensions/test/xpcshell/test_updatecheck.js +++ b/toolkit/mozapps/extensions/test/xpcshell/test_updatecheck.js @@ -6,24 +6,12 @@ Components.utils.import("resource://gre/modules/AddonUpdateChecker.jsm"); -var COMPATIBILITY_PREF; - Components.utils.import("resource://testing-common/httpd.js"); var testserver; function run_test() { createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9.2"); - var channel = "default"; - try { - channel = Services.prefs.getCharPref("app.update.channel"); - } catch (e) { } - if (channel != "aurora" && channel != "beta" && channel != "release") - var version = "nightly"; - else - version = Services.appinfo.version.replace(/^([^\.]+\.[0-9]+[a-z]*).*/gi, "$1"); - COMPATIBILITY_PREF = "extensions.checkCompatibility." + version; - // Create and configure the HTTP server. testserver = new HttpServer(); testserver.registerDirectory("/data/", do_get_file("data"));