Bug 1373271 - Handle crashes in preloaded browsers in tabbrowser r=mconley
authork88hudson <khudson@mozilla.com>
Thu, 15 Jun 2017 12:27:06 -0400
changeset 416199 761383b60ca2b25ff6667f948dcd0e2aeebf8869
parent 416198 bfe1b0bc5aedad91d737103317eb4607915ee5a9
child 416200 a012b5a75d3c1b598594bdff5c0e09201b5e8c92
push id1517
push userjlorenzo@mozilla.com
push dateThu, 14 Sep 2017 16:50:54 +0000
treeherdermozilla-release@3b41fd564418 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmconley
bugs1373271
milestone56.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1373271 - Handle crashes in preloaded browsers in tabbrowser r=mconley MozReview-Commit-ID: IVMQOOsyMnZ
browser/base/content/tabbrowser.xml
browser/components/sessionstore/test/browser_background_tab_crash.js
--- a/browser/base/content/tabbrowser.xml
+++ b/browser/base/content/tabbrowser.xml
@@ -5638,16 +5638,26 @@
         ]]>
       </handler>
       <handler event="oop-browser-crashed">
         <![CDATA[
           if (!event.isTrusted)
             return;
 
           let browser = event.originalTarget;
+
+          // Preloaded browsers do not actually have any tabs. If one crashes,
+          // it should be released and removed.
+          if (browser === this._preloadedBrowser) {
+            // Calling _getPreloadedBrowser is necessary to actually consume the preloaded browser
+            let preloaded = this._getPreloadedBrowser();
+            preloaded.remove();
+            return;
+          }
+
           let icon = browser.mIconURL;
           let tab = this.getTabForBrowser(browser);
 
           if (this.selectedBrowser == browser) {
             TabCrashHandler.onSelectedBrowserCrash(browser);
           } else {
             this.updateBrowserRemoteness(browser, false);
             SessionStore.reviveCrashedTab(tab);
--- a/browser/components/sessionstore/test/browser_background_tab_crash.js
+++ b/browser/components/sessionstore/test/browser_background_tab_crash.js
@@ -214,8 +214,35 @@ add_task(async function test_background_
 
       // Selecting the third tab should restore it.
       tabRestored = promiseTabRestored(tab3);
       await BrowserTestUtils.switchTab(gBrowser, tab3);
       await tabRestored;
     });
   });
 });
+
+// Tests that crashed preloaded tabs are removed and no unexpected errors are
+// thrown.
+add_task(async function test_preload_crash() {
+  if (!Services.prefs.getBoolPref("browser.newtab.preload")) {
+    return;
+  }
+
+  // Since new tab is only crashable for the activity-stream version,
+  // we need to flip the pref
+  await SpecialPowers.pushPrefEnv({
+    set: [[ "browser.newtabpage.activity-stream.enabled", true ]]
+  });
+
+  // Release any existing preloaded browser
+  let preloaded = gBrowser._getPreloadedBrowser();
+  if (preloaded) {
+    preloaded.remove();
+  }
+
+  // Create a fresh preloaded browser
+  gBrowser._createPreloadBrowser();
+
+  await BrowserTestUtils.crashBrowser(gBrowser._preloadedBrowser, false);
+
+  Assert.ok(!gBrowser._preloadedBrowser);
+});