Bug 1318675 - Reconnect find bar when toggling RDM. r=ochameau draft
authorJ. Ryan Stinnett <jryans@gmail.com>
Mon, 28 Nov 2016 20:46:47 -0600
changeset 446651 9635ad51d8d88a4e1a9e5c7f462004dbecc4c3ce
parent 444725 8387a4ada9a5c4cab059d8fafe0f8c933e83c149
child 538831 fbe1e1fc9e476295d283910f9f61968f1b89855d
push id37844
push userbmo:jryans@gmail.com
push dateThu, 01 Dec 2016 18:25:16 +0000
reviewersochameau
bugs1318675
milestone53.0a1
Bug 1318675 - Reconnect find bar when toggling RDM. r=ochameau MozReview-Commit-ID: 4IoXvTZXbKW
devtools/client/responsive.html/browser/swap.js
devtools/client/responsive.html/browser/tunnel.js
--- a/devtools/client/responsive.html/browser/swap.js
+++ b/devtools/client/responsive.html/browser/swap.js
@@ -102,16 +102,27 @@ function swapToInnerBrowser({ tab, conta
       gBrowser.swapBrowsersAndCloseOther(tab, containerTab);
 
       // 7. Start a tunnel from the tool tab's browser to the viewport browser
       //    so that some browser UI functions, like navigation, are connected to
       //    the content in the viewport, instead of the tool page.
       tunnel = tunnelToInnerBrowser(tab.linkedBrowser, innerBrowser);
       yield tunnel.start();
 
+      // Swapping browsers disconnects the find bar UI from the browser.
+      // If the find bar has been initialized, reconnect it.
+      if (gBrowser.isFindBarInitialized(tab)) {
+        let findBar = gBrowser.getFindBar(tab);
+        findBar.browser = tab.linkedBrowser;
+        if (!findBar.hidden) {
+          // Force the find bar to activate again, restoring the search string.
+          findBar.onFindCommand();
+        }
+      }
+
       // Force the browser UI to match the new state of the tab and browser.
       thawNavigationState(tab);
       gBrowser.setTabTitle(tab);
       gBrowser.updateCurrentBrowser(true);
     }),
 
     stop() {
       // 1. Stop the tunnel between outer and inner browsers.
@@ -142,16 +153,28 @@ function swapToInnerBrowser({ tab, conta
       gBrowser.updateBrowserRemoteness(tab.linkedBrowser, true,
                                        contentBrowser.remoteType);
 
       // 6. Swap the content into the original browser tab and close the
       //    temporary tab used to hold the content via
       //    `swapBrowsersAndCloseOther`.
       dispatchDevToolsBrowserSwap(contentBrowser, tab.linkedBrowser);
       gBrowser.swapBrowsersAndCloseOther(tab, contentTab);
+
+      // Swapping browsers disconnects the find bar UI from the browser.
+      // If the find bar has been initialized, reconnect it.
+      if (gBrowser.isFindBarInitialized(tab)) {
+        let findBar = gBrowser.getFindBar(tab);
+        findBar.browser = tab.linkedBrowser;
+        if (!findBar.hidden) {
+          // Force the find bar to activate again, restoring the search string.
+          findBar.onFindCommand();
+        }
+      }
+
       gBrowser = null;
 
       // The focus manager seems to get a little dizzy after all this swapping.  If a
       // content element had been focused inside the viewport before stopping, it will
       // have lost focus.  Activate the frame to restore expected focus.
       tab.linkedBrowser.frameLoader.activateRemoteFrame();
 
       delete tab.isResponsiveDesignMode;
--- a/devtools/client/responsive.html/browser/tunnel.js
+++ b/devtools/client/responsive.html/browser/tunnel.js
@@ -18,16 +18,17 @@ function debug(msg) {
   // console.log(msg);
 }
 
 /**
  * Properties swapped between browsers by browser.xml's `swapDocShells`.  See also the
  * list at /devtools/client/responsive.html/docs/browser-swap.md.
  */
 const SWAPPED_BROWSER_STATE = [
+  "_remoteFinder",
   "_securityUI",
   "_documentURI",
   "_documentContentType",
   "_contentTitle",
   "_characterSet",
   "_contentPrincipal",
   "_imageDocument",
   "_fullZoom",