Bug 1338893 - Don't use the window on application-foreground if it doesn't yet exist. r=sebastian, a=jcristau
authorJan Henning <jh+bugzilla@buttercookie.de>
Sun, 12 Feb 2017 15:09:32 +0100
changeset 354299 189be0f13dfce7ddd53c8d4c15e0a9aa2bb7fadc
parent 354298 7703bdf63084d45879fdad3d71f455ecd47b309e
child 354300 23b6c61a00882647e9275d67a5d608fd83f04915
push id6895
push userryanvm@gmail.com
push dateFri, 17 Feb 2017 14:19:07 +0000
treeherdermozilla-esr52@41c9d8ee2649 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssebastian, jcristau
bugs1338893
milestone52.0
Bug 1338893 - Don't use the window on application-foreground if it doesn't yet exist. r=sebastian, a=jcristau During a cold startup, depending how this exactly plays out we might receive an application-foreground notification before the browser window is ready. Since the code to restore the selected tab if it has been left zombified while in background is only relevant if Gecko was already running and backgrounded, we can simply add a null check for the window before accessing it. MozReview-Commit-ID: Ahp5NAODKRF
mobile/android/components/SessionStore.js
--- a/mobile/android/components/SessionStore.js
+++ b/mobile/android/components/SessionStore.js
@@ -328,20 +328,21 @@ SessionStore.prototype = {
         // Reset minimum interval between session store writes back to default.
         log("application-foreground");
         this._interval = Services.prefs.getIntPref("browser.sessionstore.interval");
         this._minSaveDelay = MINIMUM_SAVE_DELAY;
 
         // If we skipped restoring a zombified tab before backgrounding,
         // we might have to do it now instead.
         let window = Services.wm.getMostRecentWindow("navigator:browser");
-        let tab = window.BrowserApp.selectedTab;
-
-        if (tab.browser.__SS_restore) {
-          this._restoreZombieTab(tab.browser, tab.id);
+        if (window) { // Might not yet be ready during a cold startup.
+          let tab = window.BrowserApp.selectedTab;
+          if (tab.browser.__SS_restore) {
+            this._restoreZombieTab(tab.browser, tab.id);
+          }
         }
         break;
       case "ClosedTabs:StartNotifications":
         this._notifyClosedTabs = true;
         log("ClosedTabs:StartNotifications");
         this._sendClosedTabsToJava(Services.wm.getMostRecentWindow("navigator:browser"));
         break;
       case "ClosedTabs:StopNotifications":