Bug 1391187 - compare build id to perform full directory scan in addon manager draft
authorJulian Descottes <jdescottes@mozilla.com>
Thu, 17 Aug 2017 19:13:32 +0200
changeset 648779 bf62e1947dfa17a43203615dc102a585bd685ccb
parent 648046 932388b8c22c9775264e543697ce918415db9e23
child 726938 fd22389b490496a921260e315715d0c39293f6cf
push id74879
push userjdescottes@mozilla.com
push dateFri, 18 Aug 2017 09:27:21 +0000
bugs1391187
milestone57.0a1
Bug 1391187 - compare build id to perform full directory scan in addon manager MozReview-Commit-ID: 4ex9JrMm3NT
toolkit/mozapps/extensions/AddonManager.jsm
--- a/toolkit/mozapps/extensions/AddonManager.jsm
+++ b/toolkit/mozapps/extensions/AddonManager.jsm
@@ -24,16 +24,17 @@ if ("@mozilla.org/xre/app-info;1" in Cc)
 Cu.import("resource://gre/modules/AppConstants.jsm");
 
 const MOZ_COMPATIBILITY_NIGHTLY = !["aurora", "beta", "release", "esr"].includes(AppConstants.MOZ_UPDATE_CHANNEL);
 
 const PREF_BLOCKLIST_PINGCOUNTVERSION = "extensions.blocklist.pingCountVersion";
 const PREF_DEFAULT_PROVIDERS_ENABLED  = "extensions.defaultProviders.enabled";
 const PREF_EM_UPDATE_ENABLED          = "extensions.update.enabled";
 const PREF_EM_LAST_APP_VERSION        = "extensions.lastAppVersion";
+const PREF_EM_LAST_APP_BUILD_ID       = "extensions.lastAppBuildId";
 const PREF_EM_LAST_PLATFORM_VERSION   = "extensions.lastPlatformVersion";
 const PREF_EM_AUTOUPDATE_DEFAULT      = "extensions.update.autoUpdateDefault";
 const PREF_EM_STRICT_COMPATIBILITY    = "extensions.strictCompatibility";
 const PREF_EM_CHECK_UPDATE_SECURITY   = "extensions.checkUpdateSecurity";
 const PREF_EM_UPDATE_BACKGROUND_URL   = "extensions.update.background.url";
 const PREF_APP_UPDATE_ENABLED         = "app.update.enabled";
 const PREF_APP_UPDATE_AUTO            = "app.update.auto";
 const PREF_EM_HOTFIX_ID               = "extensions.hotfix.id";
@@ -782,30 +783,43 @@ var AddonManagerInternal = {
       this.recordTimestamp("AMI_startup_begin");
 
       // clear this for xpcshell test restarts
       for (let provider in this.telemetryDetails)
         delete this.telemetryDetails[provider];
 
       let appChanged = undefined;
 
-      let oldAppVersion = null;
       try {
-        oldAppVersion = Services.prefs.getCharPref(PREF_EM_LAST_APP_VERSION);
-        appChanged = Services.appinfo.version != oldAppVersion;
+        let oldAppVersion = Services.prefs.getCharPref(PREF_EM_LAST_APP_VERSION);
+        let oldAppBuildId = Services.prefs.getCharPref(PREF_EM_LAST_APP_BUILD_ID);
+        if (Services.appinfo.version != oldAppVersion) {
+          // Different app version, consider that the application changed.
+          appChanged = true;
+        } else if (Services.appinfo.appBuildId == oldAppBuildId) {
+          // Same app version and build id, application did not change.
+          appChanged = false
+        } else {
+          // Same version but different build id, this is just a nightly update.
+          // Keep appChanged as undefined to avoid the Dialog "checking compatibility"
+          // TODO: Find a better way to handle this use case.
+          appChanged = undefined;
+        }
       } catch (e) { }
 
       gBrowserUpdated = appChanged;
 
       let oldPlatformVersion = Services.prefs.getCharPref(PREF_EM_LAST_PLATFORM_VERSION, "");
 
       if (appChanged !== false) {
         logger.debug("Application has been upgraded");
         Services.prefs.setCharPref(PREF_EM_LAST_APP_VERSION,
                                    Services.appinfo.version);
+        Services.prefs.setCharPref(PREF_EM_LAST_APP_BUILD_ID,
+                                   Services.appinfo.appBuildId + "");
         Services.prefs.setCharPref(PREF_EM_LAST_PLATFORM_VERSION,
                                    Services.appinfo.platformVersion);
         Services.prefs.setIntPref(PREF_BLOCKLIST_PINGCOUNTVERSION,
                                   (appChanged === undefined ? 0 : -1));
         this.validateBlocklist();
       }
 
       if (!MOZ_COMPATIBILITY_NIGHTLY) {