Bug 1331601 - Copy tab listener state flags in RDM. r=ochameau

When starting and stopping RDM, we need want to ensure tab listener state flags
are preserved for the tab involved, which is a bit tricky with the tab dance
RDM is doing.

The state flags ensure the browser will call the correct handlers when switching
tabs to update the primary browser UI.  For example, this is needed to correctly
update the enabled state of the view source command for the current tab.

MozReview-Commit-ID: 7lKY0DKxgJH

--HG--
extra : rebase_source : 5cc2deafc31f8f58d13d78e5b2524d60897bf5b9
This commit is contained in:
J. Ryan Stinnett 2017-01-19 13:25:14 -06:00
parent c6a3f8a08d
commit 5f485b1aa7

View File

@ -64,6 +64,13 @@ function swapToInnerBrowser({ tab, containerURL, getInnerBrowser }) {
gBrowser.hideTab(containerTab);
let containerBrowser = containerTab.linkedBrowser;
// Copy tab listener state flags to container tab. Each tab gets its own tab
// listener and state flags which cache document loading progress. The state flags
// are checked when switching tabs to update the browser UI. The later step of
// `swapBrowsersAndCloseOther` will fold the state back into the main tab.
let stateFlags = gBrowser._tabListeners.get(tab).mStateFlags;
gBrowser._tabListeners.get(containerTab).mStateFlags = stateFlags;
// 2. Mark the tool tab browser's docshell as active so the viewport frame
// is created eagerly and will be ready to swap.
// This line is crucial when the tool UI is loaded into a background tab.
@ -147,6 +154,11 @@ function swapToInnerBrowser({ tab, containerURL, getInnerBrowser }) {
gBrowser._swapBrowserDocShells(contentTab, innerBrowser);
innerBrowser = null;
// Copy tab listener state flags to content tab. See similar comment in `start`
// above for more details.
let stateFlags = gBrowser._tabListeners.get(tab).mStateFlags;
gBrowser._tabListeners.get(contentTab).mStateFlags = stateFlags;
// 5. Force the original browser tab to be remote since web content is
// loaded in the child process, and we're about to swap the content
// into this tab.