Bug 1313863: Copy progress state flags when moving tabs between windows. r=Gijs,mconley
authorKris Maglione <maglione.k@gmail.com>
Fri, 30 Dec 2016 10:32:11 -0800
changeset 328860 dc76b4cad2f917e0ef7c966f6b2846c01e56e05d
parent 328859 9532ebc3faf001a04f12b97cb9e95224898f22ff
child 328861 c41f6dabe834dba31143a83a1c1405ae50e33584
push id31191
push usercbook@mozilla.com
push dateWed, 11 Jan 2017 15:24:19 +0000
treeherdermozilla-central@63ad56438630 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersGijs, mconley
bugs1313863
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 1313863: Copy progress state flags when moving tabs between windows. r=Gijs,mconley MozReview-Commit-ID: FO0CfvSr81K
browser/base/content/tabbrowser.xml
browser/base/content/test/general/browser_tab_drag_drop_perwindow.js
--- a/browser/base/content/tabbrowser.xml
+++ b/browser/base/content/tabbrowser.xml
@@ -533,19 +533,20 @@
       </method>
 
       <!-- A web progress listener object definition for a given tab. -->
       <method name="mTabProgressListener">
         <parameter name="aTab"/>
         <parameter name="aBrowser"/>
         <parameter name="aStartsBlank"/>
         <parameter name="aWasPreloadedBrowser"/>
+        <parameter name="aOrigStateFlags"/>
         <body>
         <![CDATA[
-          let stateFlags = 0;
+          let stateFlags = aOrigStateFlags || 0;
           // Initialize mStateFlags to non-zero e.g. when creating a progress
           // listener for preloaded browsers as there was no progress listener
           // around when the content started loading. If the content didn't
           // quite finish loading yet, mStateFlags will very soon be overridden
           // with the correct value and end up at STATE_STOP again.
           if (aWasPreloadedBrowser) {
             stateFlags = Ci.nsIWebProgressListener.STATE_STOP |
                          Ci.nsIWebProgressListener.STATE_IS_REQUEST;
@@ -2834,16 +2835,19 @@
             if (otherBrowser.hasAttribute("usercontextid")) {
               ourBrowser.setAttribute("usercontextid", otherBrowser.getAttribute("usercontextid"));
             }
 
             // That's gBrowser for the other window, not the tab's browser!
             var remoteBrowser = aOtherTab.ownerDocument.defaultView.gBrowser;
             var isPending = aOtherTab.hasAttribute("pending");
 
+            let otherTabListener = remoteBrowser._tabListeners.get(aOtherTab);
+            let stateFlags = otherTabListener.mStateFlags;
+
             // Expedite the removal of the icon if it was already scheduled.
             if (aOtherTab._soundPlayingAttrRemovalTimer) {
               clearTimeout(aOtherTab._soundPlayingAttrRemovalTimer);
               aOtherTab._soundPlayingAttrRemovalTimer = 0;
               aOtherTab.removeAttribute("soundplaying");
               remoteBrowser._tabAttrModified(aOtherTab, ["soundplaying"]);
             }
 
@@ -2891,17 +2895,17 @@
               var isBusy = aOtherTab.hasAttribute("busy");
               if (isBusy) {
                 aOurTab.setAttribute("busy", "true");
                 modifiedAttrs.push("busy");
                 if (aOurTab.selected)
                   this.mIsBusy = true;
               }
 
-              this._swapBrowserDocShells(aOurTab, otherBrowser, Ci.nsIBrowser.SWAP_DEFAULT);
+              this._swapBrowserDocShells(aOurTab, otherBrowser, Ci.nsIBrowser.SWAP_DEFAULT, stateFlags);
             }
 
             // Unregister the previously opened URI
             if (otherBrowser.registeredOpenURI) {
               this._unifiedComplete.unregisterOpenPage(otherBrowser.registeredOpenURI,
                                                        otherBrowser.getAttribute("usercontextid") || 0);
               delete otherBrowser.registeredOpenURI;
             }
@@ -2964,16 +2968,17 @@
           ]]>
         </body>
       </method>
 
       <method name="_swapBrowserDocShells">
         <parameter name="aOurTab"/>
         <parameter name="aOtherBrowser"/>
         <parameter name="aFlags"/>
+        <parameter name="aStateFlags"/>
         <body>
           <![CDATA[
             // Unhook our progress listener
             const filter = this._tabFilters.get(aOurTab);
             let tabListener = this._tabListeners.get(aOurTab);
             let ourBrowser = this.getBrowserForTab(aOurTab);
             ourBrowser.webProgress.removeProgressListener(filter);
             filter.removeProgressListener(tabListener);
@@ -3020,17 +3025,18 @@
                 let otherTab = remoteBrowser.getTabForBrowser(aOtherBrowser);
                 if (otherTab) {
                   otherTab.permanentKey = aOtherBrowser.permanentKey;
                 }
               }
             }
 
             // Restore the progress listener
-            tabListener = this.mTabProgressListener(aOurTab, ourBrowser, false, false);
+            tabListener = this.mTabProgressListener(aOurTab, ourBrowser, false, false,
+                                                    aStateFlags);
             this._tabListeners.set(aOurTab, tabListener);
 
             const notifyAll = Ci.nsIWebProgress.NOTIFY_ALL;
             filter.addProgressListener(tabListener, notifyAll);
             ourBrowser.webProgress.addProgressListener(filter, notifyAll);
           ]]>
         </body>
       </method>
--- a/browser/base/content/test/general/browser_tab_drag_drop_perwindow.js
+++ b/browser/base/content/test/general/browser_tab_drag_drop_perwindow.js
@@ -172,8 +172,45 @@ add_task(function* test_dragging_adoptio
   let openEvent = yield awaitOpenEvent;
 
   is(openEvent.detail.adoptedTab, tab1, "New tab adopted old tab");
   is(closeEvent.detail.adoptedBy, openEvent.target, "Old tab adopted by new tab");
 
   yield BrowserTestUtils.closeWindow(win1);
   yield BrowserTestUtils.closeWindow(win2);
 });
+
+
+/**
+ * Tests that per-site zoom settings remain active after a tab is
+ * dragged between windows.
+ */
+add_task(function* test_dragging_zoom_handling() {
+  const ZOOM_FACTOR = 1.62;
+
+  let win1 = yield BrowserTestUtils.openNewBrowserWindow();
+  let win2 = yield BrowserTestUtils.openNewBrowserWindow();
+
+  let tab1 = yield BrowserTestUtils.openNewForegroundTab(win1.gBrowser);
+  let tab2 = yield BrowserTestUtils.openNewForegroundTab(win2.gBrowser,
+                                                         "http://example.com/");
+
+  win2.FullZoom.setZoom(ZOOM_FACTOR);
+  FullZoomHelper.zoomTest(tab2, ZOOM_FACTOR,
+                          "Original tab should have correct zoom factor");
+
+  let effect = EventUtils.synthesizeDrop(tab2, tab1,
+    [[{type: TAB_DROP_TYPE, data: tab2}]],
+    null, win2, win1);
+  is(effect, "move", "Tab should be moved from win2 to win1.");
+
+  // Delay slightly to make sure we've finished executing any promise
+  // chains in the zoom code.
+  yield new Promise(resolve => setTimeout(resolve, 0));
+
+  FullZoomHelper.zoomTest(win1.gBrowser.selectedTab, ZOOM_FACTOR,
+                          "Dragged tab should have correct zoom factor");
+
+  win1.FullZoom.reset();
+
+  yield BrowserTestUtils.closeWindow(win1);
+  yield BrowserTestUtils.closeWindow(win2);
+});