Bug 741972 - Test failures on ESR when channel is set to ESR, TEST-UNEXPECTED-FAIL | test_AddonRepository_compatmode.js | compatmode-strict@tests.mozilla.org == compatmode-ignore@tests.mozilla.org and more. Change tests to re-use the new AddonManager.checkCompatibility attribute for future-proofing channel additions/changes. r=bmcbride
authorMark Banner <bugzilla@standard8.plus.com>
Thu, 16 Aug 2012 08:49:46 +0100
changeset 108525 6b0193cd6bf9dc33c001cedc673a0c0175d6607f
parent 108511 bc01b7e45d032dd61cd749a401bdd9ea19f7396a
child 108526 2759cfa65dc57d57c917423689f9aff1e383e6a9
push id214
push userakeybl@mozilla.com
push dateWed, 14 Nov 2012 20:38:59 +0000
treeherdermozilla-release@c8b08ec8e1aa [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbmcbride
bugs741972
milestone17.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 741972 - Test failures on ESR when channel is set to ESR, TEST-UNEXPECTED-FAIL | test_AddonRepository_compatmode.js | compatmode-strict@tests.mozilla.org == compatmode-ignore@tests.mozilla.org and more. Change tests to re-use the new AddonManager.checkCompatibility attribute for future-proofing channel additions/changes. r=bmcbride
toolkit/mozapps/extensions/test/browser/browser_globalwarnings.js
toolkit/mozapps/extensions/test/browser/browser_searching.js
toolkit/mozapps/extensions/test/xpcshell/head_addons.js
toolkit/mozapps/extensions/test/xpcshell/test_AddonRepository_compatmode.js
toolkit/mozapps/extensions/test/xpcshell/test_bug470377_2.js
toolkit/mozapps/extensions/test/xpcshell/test_bug470377_3.js
toolkit/mozapps/extensions/test/xpcshell/test_bug470377_3_strictcompat.js
toolkit/mozapps/extensions/test/xpcshell/test_bug470377_4.js
toolkit/mozapps/extensions/test/xpcshell/test_bug521905.js
toolkit/mozapps/extensions/test/xpcshell/test_checkcompatibility.js
toolkit/mozapps/extensions/test/xpcshell/test_pref_properties.js
toolkit/mozapps/extensions/test/xpcshell/test_update_compatmode.js
toolkit/mozapps/extensions/test/xpcshell/test_updatecheck.js
--- a/toolkit/mozapps/extensions/test/browser/browser_globalwarnings.js
+++ b/toolkit/mozapps/extensions/test/browser/browser_globalwarnings.js
@@ -11,43 +11,28 @@ function test() {
 
 function end_test() {
   finish();
 }
 
 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");
     is_element_visible(hbox, "Check Compatibility warning hbox should be visible");
     var button = aWindow.document.querySelector("#list-view button.global-warning-checkcompatibility");
     is_element_visible(button, "Check Compatibility warning button should be visible");
 
     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");
 
     close_manager(aWindow, function() {
       run_next_test();
     });
   });
 });
--- a/toolkit/mozapps/extensions/test/browser/browser_searching.js
+++ b/toolkit/mozapps/extensions/test/browser/browser_searching.js
@@ -14,32 +14,16 @@ const REMOTE_TO_INSTALL = "remote1";
 const REMOTE_INSTALL_URL = TESTROOT + "addons/browser_searching.xpi";
 
 var gManagerWindow;
 var gCategoryUtilities;
 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
   Services.prefs.setIntPref(PREF_SEARCH_MAXRESULTS, 15);
   Services.prefs.setBoolPref(PREF_STRICT_COMPAT, true);
 
   waitForExplicitFinish();
 
@@ -598,26 +582,26 @@ add_test(function() {
       check_filtered_results(QUERY, "relevancescore", false);
       run_next_test();
     });
   });
 });
 
 // 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();
   });
 });
 
 // Tests that compatible-by-default addons are shown if strict compatibility checking is disabled
 add_test(function() {
   restart_manager(gManagerWindow, null, function(aWindow) {
     gManagerWindow = aWindow;
--- a/toolkit/mozapps/extensions/test/xpcshell/head_addons.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/head_addons.js
@@ -21,16 +21,26 @@ Components.utils.import("resource://gre/
 Components.utils.import("resource://gre/modules/NetUtil.jsm");
 
 var gInternalManager = null;
 var gAppInfo = null;
 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
     vendor: "Mozilla",
     name: name,
     ID: id,
     version: version,
     appBuildID: "2007010101",
--- a/toolkit/mozapps/extensions/test/xpcshell/test_AddonRepository_compatmode.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_AddonRepository_compatmode.js
@@ -10,29 +10,16 @@ const PREF_GETADDONS_GETSEARCHRESULTS   
 Components.utils.import("resource://testing-common/httpd.js");
 var gServer;
 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.
   gServer = new HttpServer();
   gServer.registerDirectory("/data/", do_get_file("data"));
   gServer.start(4444);
 
   Services.prefs.setCharPref(PREF_GETADDONS_GETSEARCHRESULTS,
                              "http://localhost:4444/data/test_AddonRepository_compatmode_%COMPATIBILITY_MODE%.xml");
   startupManager();
@@ -79,17 +66,17 @@ function run_test_2() {
       do_throw("Search should not have failed");
     }
   });
 }
 
 // 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) {
       do_check_neq(aAddons, null);
       do_check_eq(aAddons.length, 1);
       do_check_eq(aAddons[0].id, "compatmode-ignore@tests.mozilla.org");
 
       end_test();
--- a/toolkit/mozapps/extensions/test/xpcshell/test_bug470377_2.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_bug470377_2.js
@@ -1,30 +1,17 @@
 /* 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/.
  */
 
 // 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",
   "test_bug470377_2",
   "test_bug470377_3",
   "test_bug470377_4",
   "test_bug470377_5",
 ];
--- a/toolkit/mozapps/extensions/test/xpcshell/test_bug470377_3.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_bug470377_3.js
@@ -64,31 +64,18 @@ function run_test_1() {
     do_check_neq(a5, null);
     do_check_true(a5.isActive);
 
     run_test_2();
   });
 }
 
 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",
                                "bug470377_2@tests.mozilla.org",
                                "bug470377_3@tests.mozilla.org",
                                "bug470377_4@tests.mozilla.org",
                                "bug470377_5@tests.mozilla.org"],
                                function([a1, a2, a3, a4, a5]) {
--- a/toolkit/mozapps/extensions/test/xpcshell/test_bug470377_3_strictcompat.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_bug470377_3_strictcompat.js
@@ -63,31 +63,18 @@ function run_test_1() {
     do_check_neq(a5, null);
     do_check_true(a5.isActive);
 
     run_test_2();
   });
 }
 
 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",
                                "bug470377_2@tests.mozilla.org",
                                "bug470377_3@tests.mozilla.org",
                                "bug470377_4@tests.mozilla.org",
                                "bug470377_5@tests.mozilla.org"],
                                function([a1, a2, a3, a4, a5]) {
--- a/toolkit/mozapps/extensions/test/xpcshell/test_bug470377_4.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_bug470377_4.js
@@ -1,28 +1,13 @@
 /* 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/.
  */
 
-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");
 
   // inject the add-ons into the profile
   var profileDir = gProfD.clone();
   profileDir.append("extensions");
   var dest = profileDir.clone();
@@ -50,18 +35,18 @@ function run_test() {
   dest.create(Components.interfaces.nsIFile.DIRECTORY_TYPE, 0755);
   source = do_get_file("data/test_bug470377/install_5.rdf");
   source.copyTo(dest, "install.rdf");
 
   run_test_1();
 }
 
 function run_test_1() {
-  // Disable compatibility checks
-  Services.prefs.setBoolPref(checkCompatPref, false);
+  AddonManager.checkCompatibility = false;
+
   startupManager();
 
   AddonManager.getAddonsByIDs(["bug470377_1@tests.mozilla.org",
                                "bug470377_2@tests.mozilla.org",
                                "bug470377_3@tests.mozilla.org",
                                "bug470377_4@tests.mozilla.org",
                                "bug470377_5@tests.mozilla.org"],
                                function([a1, a2, a3, a4, a5]) {
@@ -76,18 +61,18 @@ function run_test_1() {
     do_check_neq(a5, null);
     do_check_true(a5.isActive);
 
     run_test_2();
   });
 }
 
 function run_test_2() {
-  // Enable compatibility checks
-  Services.prefs.setBoolPref(checkCompatPref, true);
+  AddonManager.checkCompatibility = true;
+
   restartManager();
 
   AddonManager.getAddonsByIDs(["bug470377_1@tests.mozilla.org",
                                "bug470377_2@tests.mozilla.org",
                                "bug470377_3@tests.mozilla.org",
                                "bug470377_4@tests.mozilla.org",
                                "bug470377_5@tests.mozilla.org"],
                                function([a1, a2, a3, a4, a5]) {
--- a/toolkit/mozapps/extensions/test/xpcshell/test_bug521905.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_bug521905.js
@@ -3,31 +3,22 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
  */
 
 const ADDON = "test_bug521905";
 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;
   }
 
   do_test_pending();
   createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "2.0pre", "2");
 
   startupManager();
   installAllFiles([do_get_addon(ADDON)], function() {
--- a/toolkit/mozapps/extensions/test/xpcshell/test_checkcompatibility.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_checkcompatibility.js
@@ -64,25 +64,17 @@ var gIsNightly = false;
 function run_test() {
   do_test_pending();
   createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "2.2.3", "2");
 
   ADDONS.forEach(function(a) {
     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();
 
   run_test_1();
 }
 
 /**
  * Checks that the add-ons are enabled as expected.
--- a/toolkit/mozapps/extensions/test/xpcshell/test_pref_properties.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_pref_properties.js
@@ -123,23 +123,17 @@ function run_test() {
   gManagerEventsListener.expect([]);
   AddonManager.strictCompatibility = true;
   gManagerEventsListener.checkExpected();
   do_check_true(AddonManager.strictCompatibility);
   do_check_true(Services.prefs.getBoolPref("extensions.strictCompatibility"));
 
 
   // 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");
   }
   const COMPATIBILITY_PREF = "extensions.checkCompatibility." + version;
 
   gManagerEventsListener.expect(["onCompatibilityModeChanged"]);
   AddonManager.checkCompatibility = false;
--- a/toolkit/mozapps/extensions/test/xpcshell/test_update_compatmode.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_update_compatmode.js
@@ -9,35 +9,20 @@
 // The test extension uses an insecure update url.
 Services.prefs.setBoolPref(PREF_EM_CHECK_UPDATE_SECURITY, false);
 
 Components.utils.import("resource://testing-common/httpd.js");
 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"));
   testserver.registerDirectory("/addons/", do_get_file("addons"));
   testserver.start(4444);
 
   writeInstallRDFForExtension({
     id: "compatmode-normal@tests.mozilla.org",
@@ -169,17 +154,17 @@ function run_test_3() {
       }
     }, AddonManager.UPDATE_WHEN_USER_REQUESTED);
   });
 }
 
 // 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({
       onCompatibilityUpdateAvailable: function() {
         do_throw("Should have not have seen compatibility information");
       },
 
       onNoUpdateAvailable: function() {
--- a/toolkit/mozapps/extensions/test/xpcshell/test_updatecheck.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_updatecheck.js
@@ -1,34 +1,22 @@
 /* Any copyright is dedicated to the Public Domain.
  * http://creativecommons.org/publicdomain/zero/1.0/
  */
 
 // This verifies that AddonUpdateChecker works correctly
 
 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"));
   testserver.start(4444);
 
   do_test_pending();
   run_test_1();
 }