Bug 1318767 - Part 2: Correctly swap web progress listeners when swapping frameloaders, r=dao
authorMichael Layzell <michael@thelayzells.com>
Fri, 25 Nov 2016 10:06:00 +0800
changeset 325863 447db63f9b10e75fd48a42a38ce9298ddd839930
parent 325862 a9d879cfa0f7a7af35a85e118ac51f7b237f583a
child 325864 44a95445e11d8eff6ca5c10f1b2b913a9f44eeb0
push id31076
push usercbook@mozilla.com
push dateWed, 14 Dec 2016 15:41:53 +0000
treeherdermozilla-central@18b5a7a5d833 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdao
bugs1318767
milestone53.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 1318767 - Part 2: Correctly swap web progress listeners when swapping frameloaders, r=dao MozReview-Commit-ID: KbUd2Os5qac
browser/base/content/tabbrowser.xml
toolkit/content/widgets/browser.xml
--- a/browser/base/content/tabbrowser.xml
+++ b/browser/base/content/tabbrowser.xml
@@ -2919,21 +2919,39 @@
               this._tabAttrModified(aOurTab, modifiedAttrs);
             }
           ]]>
         </body>
       </method>
 
       <method name="swapBrowsers">
         <parameter name="aOurTab"/>
-        <parameter name="aOtherBrowser"/>
+        <parameter name="aOtherTab"/>
         <parameter name="aFlags"/>
         <body>
           <![CDATA[
-            this._swapBrowserDocShells(aOurTab, aOtherBrowser, aFlags);
+            let otherBrowser = aOtherTab.linkedBrowser;
+            let otherTabBrowser = otherBrowser.getTabBrowser();
+
+            // We aren't closing the other tab so, we also need to swap its tablisteners.
+            let filter = otherTabBrowser._tabFilters.get(aOtherTab);
+            let tabListener = otherTabBrowser._tabListeners.get(aOtherTab);
+            otherBrowser.webProgress.removeProgressListener(filter);
+            filter.removeProgressListener(tabListener);
+
+            // Perform the docshell swap through the common mechanism.
+            this._swapBrowserDocShells(aOurTab, otherBrowser, aFlags);
+
+            // Restore the listeners for the swapped in tab.
+            tabListener = otherTabBrowser.mTabProgressListener(aOtherTab, otherBrowser, false, false);
+            otherTabBrowser._tabListeners.set(aOtherTab, tabListener);
+
+            const notifyAll = Ci.nsIWebProgress.NOTIFY_ALL;
+            filter.addProgressListener(tabListener, notifyAll);
+            otherBrowser.webProgress.addProgressListener(filter, notifyAll);
           ]]>
         </body>
       </method>
 
       <method name="_swapBrowserDocShells">
         <parameter name="aOurTab"/>
         <parameter name="aOtherBrowser"/>
         <parameter name="aFlags"/>
--- a/toolkit/content/widgets/browser.xml
+++ b/toolkit/content/widgets/browser.xml
@@ -1276,26 +1276,26 @@
       <method name="swapBrowsers">
         <parameter name="aOtherBrowser"/>
         <parameter name="aFlags"/>
         <body>
         <![CDATA[
           // The request comes from a XPCOM component, we'd want to redirect
           // the request to tabbrowser so tabbrowser will be setup correctly,
           // and it will eventually call swapDocShells.
-          let tabbrowser = this.getTabBrowser();
-          if (tabbrowser) {
-            let tab = tabbrowser.getTabForBrowser(this);
-            if (tab) {
-              tabbrowser.swapBrowsers(tab, aOtherBrowser, aFlags);
-              return;
-            }
+          let ourTabBrowser = this.getTabBrowser();
+          let otherTabBrowser = aOtherBrowser.getTabBrowser();
+          if (ourTabBrowser && otherTabBrowser) {
+            let ourTab = ourTabBrowser.getTabForBrowser(this);
+            let otherTab = otherTabBrowser.getTabForBrowser(aOtherBrowser);
+            ourTabBrowser.swapBrowsers(ourTab, otherTab, aFlags);
+            return;
           }
 
-          // If we're not attached to a tabbrowser, just swap.
+          // One of us is not connected to a tabbrowser, so just swap.
           this.swapDocShells(aOtherBrowser);
         ]]>
         </body>
       </method>
 
       <method name="swapDocShells">
         <parameter name="aOtherBrowser"/>
         <body>