Bug 1211637 - If there's no docShell (on a local tab) or permitUnload times out (on a remote tab), close the tab. r=billm, a=ritu
authorGijs Kruitbosch <gijskruitbosch@gmail.com>
Thu, 15 Sep 2016 16:17:17 +0100
changeset 355736 e4269c82e54f8b6dd340e99384f7dd80e21a5914
parent 355735 7a1cb386eaa6f1b65d845a4ca1caf4befb67a159
child 355737 6113e35158152399c30ad5f86ccfa21532b2b3d8
push id6570
push userraliiev@mozilla.com
push dateMon, 14 Nov 2016 12:26:13 +0000
treeherdermozilla-beta@f455459b2ae5 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbillm, ritu
bugs1211637
milestone51.0a2
Bug 1211637 - If there's no docShell (on a local tab) or permitUnload times out (on a remote tab), close the tab. r=billm, a=ritu MozReview-Commit-ID: Cihru0TVxNc
browser/base/content/tabbrowser.xml
toolkit/content/widgets/browser.xml
--- a/browser/base/content/tabbrowser.xml
+++ b/browser/base/content/tabbrowser.xml
@@ -2363,22 +2363,22 @@
 
             var browser = this.getBrowserForTab(aTab);
 
             if (!aTab._pendingPermitUnload && !aAdoptedByTab && !aSkipPermitUnload) {
               // We need to block while calling permitUnload() because it
               // processes the event queue and may lead to another removeTab()
               // call before permitUnload() returns.
               aTab._pendingPermitUnload = true;
-              let {permitUnload} = browser.permitUnload();
+              let {permitUnload, timedOut} = browser.permitUnload();
               delete aTab._pendingPermitUnload;
               // If we were closed during onbeforeunload, we return false now
               // so we don't (try to) close the same tab again. Of course, we
               // also stop if the unload was cancelled by the user:
-              if (aTab.closing || !permitUnload) {
+              if (aTab.closing || (!timedOut && !permitUnload)) {
                 // NB: deliberately keep the _closedDuringPermitUnload set to
                 // true so we keep exiting early in case of multiple calls.
                 return false;
               }
             }
 
 
             var closeWindow = false;
--- a/toolkit/content/widgets/browser.xml
+++ b/toolkit/content/widgets/browser.xml
@@ -1307,17 +1307,17 @@
         ]]>
         </body>
       </method>
 
       <method name="permitUnload">
         <body>
         <![CDATA[
           if (!this.docShell || !this.docShell.contentViewer) {
-            return true;
+            return {permitUnload: true, timedOut: false};
           }
           return {permitUnload: this.docShell.contentViewer.permitUnload(), timedOut: false};
         ]]>
         </body>
       </method>
 
       <method name="print">
         <parameter name="aOuterWindowID"/>