Bug 690316 - Disable the what's new tab for users updating to minor/security release versions. r+a=Standard8
authorIrving Reid <irving@mozilla.com>
Wed, 12 Oct 2011 10:44:55 -0400
changeset 9288 0d449996337bce261abb925c36d1ea0d3a977874
parent 9287 868e7582656b7cfe195767f510ee42c31e513ea7
child 9289 cab170bfadec5b619b7b04704d73d6b2c433283e
push id230
push userbugzilla@standard8.plus.com
push dateTue, 08 Nov 2011 22:55:24 +0000
treeherdercomm-beta@63dad5648415 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs690316
Bug 690316 - Disable the what's new tab for users updating to minor/security release versions. r+a=Standard8
mail/base/content/specialTabs.js
--- a/mail/base/content/specialTabs.js
+++ b/mail/base/content/specialTabs.js
@@ -304,17 +304,17 @@ var specialTabs = {
     tabmail.registerTabType(this.contentTabType);
     tabmail.registerTabType(this.chromeTabType);
 
     // If we've upgraded:
     let [fromVer, toVer] = this.getApplicationUpgradeVersions(prefs);
 
     // Only show what's new tab if this is actually an upgraded version,
     // not just a new installation/profile.
-    if (fromVer && fromVer != toVer)
+    if (fromVer && ((fromVer[0] != toVer[0]) || (fromVer[1] != toVer[1])))
       this.showWhatsNewPage();
 
     // Show the about rights notification if we need to.
     if (this.shouldShowAboutRightsNotification(prefs))
       this.showAboutRightsNotification(prefs);
     else if (this.shouldShowTelemetryNotification(prefs))
       this.showTelemetryNotification(prefs);
   },
@@ -608,38 +608,55 @@ var specialTabs = {
       aTab.closeListener = onDOMWindowClose;
       // Add the listener.
       aTab.browser.addEventListener("DOMWindowClose",
                                     aTab.closeListener, true);
     }
   },
 
   /**
+   * Split a version number into a triple (major, minor, extension)
+   * For example, 7.0.1 => [7, 0, 1]
+   *             10.1a3 => [10, 1, a3]
+   *             10.0 => [10, 0, ""]
+   * This could be a static function, but no current reason for it to
+   * be available outside this object's scope; as a method, it doesn't
+   * pollute anyone else's namespace
+   */
+  splitVersion: function(version) {
+    let re = /^(\d+)\.(\d+)\.?(.*)$/;
+    let fields = re.exec(version);
+    /* First element of the array from regex match is the entire string; drop that */
+    fields.shift();
+    return fields;
+  },
+
+  /**
    * In the case of an upgrade, returns the version we're upgrading
    * from, as well as the current version.  In the case of a fresh profile,
    * or the pref being set to ignore - return null and the current version.
    * In either case, updates the pref with the latest version.
    */
   getApplicationUpgradeVersions: function(prefs) {
     let savedAppVersion = null;
     let prefstring = "mailnews.start_page_override.mstone";
 
     try {
       savedAppVersion = prefs.getCharPref(prefstring);
     } catch (ex) {}
 
     let currentApplicationVersion = Application.version;
 
     if (savedAppVersion == "ignore")
-      return [null, currentApplicationVersion];
+      return [null, this.splitVersion(currentApplicationVersion)];
 
     if (savedAppVersion != currentApplicationVersion)
       prefs.setCharPref(prefstring, currentApplicationVersion);
 
-    return [savedAppVersion, currentApplicationVersion];
+    return [this.splitVersion(savedAppVersion), this.splitVersion(currentApplicationVersion)];
   },
 
   /**
    * Shows the what's new page in a content tab.
    */
   showWhatsNewPage: function onShowWhatsNewPage() {
     openWhatsNew();
   },