Bug 1313863 - Copy progress state flags when moving tabs between windows. r=Gijs, r=mconley, a=jcristau
authorKris Maglione <maglione.k@gmail.com>
Fri, 30 Dec 2016 10:32:11 -0800
changeset 353594 bec2c550fede26f7420bf8a8869ede3a8761ba0d
parent 353593 6700e062f852de615d12120f8b4067d98ff500d1
child 353595 d4bf0c2182b64c7b66b893e2153c192dc8eae3fe
push id6795
push userjlund@mozilla.com
push dateMon, 23 Jan 2017 14:19:46 +0000
treeherdermozilla-esr52@76101b503191 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersGijs, mconley, jcristau
bugs1313863
milestone52.0a2
Bug 1313863 - Copy progress state flags when moving tabs between windows. r=Gijs, r=mconley, a=jcristau 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
@@ -532,19 +532,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;
@@ -2794,16 +2795,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"]);
             }
 
@@ -2851,17 +2855,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);
+              this._swapBrowserDocShells(aOurTab, otherBrowser, stateFlags);
             }
 
             // Handle findbar data (if any)
             let otherFindBar = aOtherTab._findBar;
             if (otherFindBar &&
                 otherFindBar.findMode == otherFindBar.FIND_NORMAL) {
               let ourFindBar = this.getFindBar(aOurTab);
               ourFindBar._findField.value = otherFindBar._findField.value;
@@ -2887,16 +2891,17 @@
             }
           ]]>
         </body>
       </method>
 
       <method name="_swapBrowserDocShells">
         <parameter name="aOurTab"/>
         <parameter name="aOtherBrowser"/>
+        <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);
@@ -2941,17 +2946,18 @@
             if (remoteBrowser) {
               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);
+});