Bug 1172708: Don't show the compatibility UI for add-ons that are already compatible. r=dveditz, a=sledru
authorDave Townsend <dtownsend@oxymoronical.com>
Mon, 08 Jun 2015 17:11:48 -0700
changeset 275071 624c93de3cd3cf2728df9a9bccbb6a82b18724f4
parent 275070 0af869625d14ccda1696e214f7e8224cc06f2f50
child 275072 2719f3b54c6c723dfe423d837a03d9a1a53d01b1
push id863
push userraliiev@mozilla.com
push dateMon, 03 Aug 2015 13:22:43 +0000
treeherdermozilla-release@f6321b14228d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdveditz, sledru
bugs1172708
milestone40.0a2
Bug 1172708: Don't show the compatibility UI for add-ons that are already compatible. r=dveditz, a=sledru
toolkit/mozapps/extensions/internal/XPIProvider.jsm
toolkit/mozapps/extensions/test/xpcshell/test_signed_migrate.js
--- a/toolkit/mozapps/extensions/internal/XPIProvider.jsm
+++ b/toolkit/mozapps/extensions/internal/XPIProvider.jsm
@@ -2502,17 +2502,18 @@ this.XPIProvider = {
     logger.debug("shouldForceUpdateCheck startupChanges: " + startupChanges.toSource());
     AddonManagerPrivate.recordSimpleMeasure("XPIDB_startup_disabled", startupChanges.length);
 
     let forceUpdate = [];
     if (startupChanges.length > 0) {
     let addons = XPIDatabase.getAddons();
       for (let addon of addons) {
         if ((startupChanges.indexOf(addon.id) != -1) &&
-            (addon.permissions() & AddonManager.PERM_CAN_UPGRADE)) {
+            (addon.permissions() & AddonManager.PERM_CAN_UPGRADE) &&
+            !addon.isCompatible) {
           logger.debug("shouldForceUpdateCheck: can upgrade disabled add-on " + addon.id);
           forceUpdate.push(addon.id);
         }
       }
     }
 
     if (AddonRepository.isMetadataStale()) {
       logger.debug("shouldForceUpdateCheck: metadata is stale");
--- a/toolkit/mozapps/extensions/test/xpcshell/test_signed_migrate.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_signed_migrate.js
@@ -1,12 +1,14 @@
 // Enable signature checks for these tests
 Services.prefs.setBoolPref(PREF_XPI_SIGNATURES_REQUIRED, true);
 // Disable update security
 Services.prefs.setBoolPref(PREF_EM_CHECK_UPDATE_SECURITY, false);
+// Allow attempting to show the compatibility UI which should not happen
+Services.prefs.setBoolPref("extensions.showMismatchUI", true);
 
 const DATA = "data/signing_checks/";
 const ADDONS = {
   bootstrap: {
     unsigned: "unsigned_bootstrap_2.xpi",
     badid: "signed_bootstrap_badid_2.xpi",
     signed: "signed_bootstrap_2.xpi",
   },
@@ -16,16 +18,36 @@ const ADDONS = {
     signed: "signed_nonbootstrap_2.xpi",
   }
 };
 const ID = "test@tests.mozilla.org";
 
 const profileDir = gProfD.clone();
 profileDir.append("extensions");
 
+// Override the window watcher
+var WindowWatcher = {
+  sawAddon: false,
+
+  openWindow: function(parent, url, name, features, arguments) {
+    let ids = arguments.QueryInterface(AM_Ci.nsIVariant);
+    this.sawAddon = ids.indexOf(ID) >= 0;
+  },
+
+  QueryInterface: function(iid) {
+    if (iid.equals(AM_Ci.nsIWindowWatcher)
+        || iid.equals(AM_Ci.nsISupports))
+      return this;
+
+    throw Components.results.NS_ERROR_NO_INTERFACE;
+  }
+}
+
+MockRegistrar.register("@mozilla.org/embedcomp/window-watcher;1", WindowWatcher);
+
 function resetPrefs() {
   Services.prefs.setIntPref("bootstraptest.active_version", -1);
   Services.prefs.setIntPref("bootstraptest.installed_version", -1);
   Services.prefs.setIntPref("bootstraptest.startup_reason", -1);
   Services.prefs.setIntPref("bootstraptest.shutdown_reason", -1);
   Services.prefs.setIntPref("bootstraptest.install_reason", -1);
   Services.prefs.setIntPref("bootstraptest.uninstall_reason", -1);
   Services.prefs.setIntPref("bootstraptest.startup_oldversion", -1);
@@ -96,16 +118,20 @@ function* test_breaking_migrate(addons, 
   else
     do_check_false(isExtensionInAddonsList(profileDir, ID));
 
   // Should have flagged the change during startup
   let changes = AddonManager.getStartupChanges(AddonManager.STARTUP_CHANGE_DISABLED);
   do_check_eq(changes.length, 1);
   do_check_eq(changes[0], ID);
 
+  // Shouldn't have checked for updates for the add-on
+  do_check_false(WindowWatcher.sawAddon);
+  WindowWatcher.sawAddon = false;
+
   addon.uninstall();
   // Restart to let non-restartless add-ons uninstall fully
   yield promiseRestartManager();
   yield shutdownManager();
   resetPrefs();
 }
 
 function* test_working_migrate(addons, test, expectedSignedState) {
@@ -136,16 +162,20 @@ function* test_working_migrate(addons, t
   do_check_true(addon.isActive);
   do_check_eq(addon.signedState, expectedSignedState);
 
   if (addons == ADDONS.bootstrap)
     do_check_eq(getActiveVersion(), 2);
   else
     do_check_true(isExtensionInAddonsList(profileDir, ID));
 
+  // Shouldn't have checked for updates for the add-on
+  do_check_false(WindowWatcher.sawAddon);
+  WindowWatcher.sawAddon = false;
+
   addon.uninstall();
   // Restart to let non-restartless add-ons uninstall fully
   yield promiseRestartManager();
   yield shutdownManager();
   resetPrefs();
 }
 
 add_task(function*() {