Bug 1382746 - Provide a helper function to remove the preloaded browser r=Mardak
authork88hudson <khudson@mozilla.com>
Thu, 20 Jul 2017 14:32:39 -0400
changeset 418771 e357672c1dd1b9723a55188d8be3bbecac7d7902
parent 418770 fe76c2e3e5e69ba89c4440794bed8627defa609b
child 418772 034a44ef2565fffa48a75fcdb6036ca6cdba32be
push id7566
push usermtabara@mozilla.com
push dateWed, 02 Aug 2017 08:25:16 +0000
treeherdermozilla-beta@86913f512c3c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersMardak
bugs1382746
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 1382746 - Provide a helper function to remove the preloaded browser r=Mardak MozReview-Commit-ID: 2PSIhwvKTKA
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
@@ -1975,16 +1975,32 @@
               return this.updateBrowserRemoteness(aBrowser, remote, aOptions);
             }
 
             return false;
           ]]>
         </body>
       </method>
 
+      <method name="removePreloadedBrowser">
+        <body>
+          <![CDATA[
+            if (!this._isPreloadingEnabled()) {
+              return;
+            }
+
+            let browser = this._getPreloadedBrowser();
+
+            if (browser) {
+              browser.remove();
+            }
+          ]]>
+        </body>
+      </method>
+
       <field name="_preloadedBrowser">null</field>
       <method name="_getPreloadedBrowser">
         <body>
           <![CDATA[
             if (!this._isPreloadingEnabled()) {
               return null;
             }
 
@@ -5689,19 +5705,17 @@
           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();
+            this.removePreloadedBrowser();
             return;
           }
 
           let icon = browser.mIconURL;
           let tab = this.getTabForBrowser(browser);
 
           if (this.selectedBrowser == browser) {
             TabCrashHandler.onSelectedBrowserCrash(browser);
--- a/browser/components/sessionstore/test/browser_background_tab_crash.js
+++ b/browser/components/sessionstore/test/browser_background_tab_crash.js
@@ -229,20 +229,17 @@ add_task(async function test_preload_cra
 
   // 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();
-  }
+  gBrowser.removePreloadedBrowser();
 
   // Create a fresh preloaded browser
   gBrowser._createPreloadBrowser();
 
   await BrowserTestUtils.crashBrowser(gBrowser._preloadedBrowser, false);
 
   Assert.ok(!gBrowser._preloadedBrowser);
 });