Bug 1386224 - Use the active update and fallback to the latest update in the update history when determining whether to show the what's new page. r=mhowell, a=lizzard
authorRobert Strong <robert.bugzilla@gmail.com>
Fri, 18 Aug 2017 12:06:10 -0700
changeset 421293 cb49f51c66fa8d62fff8818bad92ea1fde823958
parent 421292 9f0bb349eced23af8fe8835d0bc3b0b40f1f1fe6
child 421294 37a05ddf9427ac9a2976640fddab25b02bca0d94
push id7646
push userryanvm@gmail.com
push dateMon, 21 Aug 2017 19:04:57 +0000
treeherdermozilla-beta@cb49f51c66fa [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmhowell, lizzard
bugs1386224
milestone56.0
Bug 1386224 - Use the active update and fallback to the latest update in the update history when determining whether to show the what's new page. r=mhowell, a=lizzard
browser/components/nsBrowserContentHandler.js
--- a/browser/components/nsBrowserContentHandler.js
+++ b/browser/components/nsBrowserContentHandler.js
@@ -133,24 +133,31 @@ function needHomepageOverride(prefb) {
  * updated.
  * @param  defaultOverridePage
  *         The default override page.
  * @return The override page.
  */
 function getPostUpdateOverridePage(defaultOverridePage) {
   var um = Components.classes["@mozilla.org/updates/update-manager;1"]
                      .getService(Components.interfaces.nsIUpdateManager);
-  try {
-    // If the updates.xml file is deleted then getUpdateAt will throw.
-    var update = um.getUpdateAt(0)
+  // The active update should be present when this code is called. If for
+  // whatever reason it isn't fallback to the latest update in the update
+  // history.
+  if (um.activeUpdate) {
+    var update = um.activeUpdate
                    .QueryInterface(Components.interfaces.nsIPropertyBag);
-  } catch (e) {
-    // This should never happen.
-    Components.utils.reportError("Unable to find update: " + e);
-    return defaultOverridePage;
+  } else {
+    // If the updates.xml file is deleted then getUpdateAt will throw.
+    try {
+      update = um.getUpdateAt(0)
+                 .QueryInterface(Components.interfaces.nsIPropertyBag);
+    } catch (e) {
+      Components.utils.reportError("Unable to find update: " + e);
+      return defaultOverridePage;
+    }
   }
 
   let actions = update.getProperty("actions");
   // When the update doesn't specify actions fallback to the original behavior
   // of displaying the default override page.
   if (!actions)
     return defaultOverridePage;