Bug 1342927 - Transfer pendingTabChild state when swapping docShells in tabswitcher. r?billm
MozReview-Commit-ID: CY26wdxSIiS
--- a/browser/base/content/tabbrowser.xml
+++ b/browser/base/content/tabbrowser.xml
@@ -4238,29 +4238,41 @@
onSwapDocShells(ourBrowser, otherBrowser) {
// This event fires before the swap. ourBrowser is from
// our window. We save the state of otherBrowser since ourBrowser
// needs to take on that state at the end of the swap.
let otherTabbrowser = otherBrowser.ownerGlobal.gBrowser;
let otherState;
+ let pendingTabChild = false;
if (otherTabbrowser && otherTabbrowser._switcher) {
let otherTab = otherTabbrowser.getTabForBrowser(otherBrowser);
- otherState = otherTabbrowser._switcher.getTabState(otherTab);
+ let otherSwitcher = otherTabbrowser._switcher;
+ otherState = otherSwitcher.getTabState(otherTab);
+ pendingTabChild = otherSwitcher.pendingTabChild.has(otherBrowser);
+
+ if (pendingTabChild) {
+ this.assert(otherState == this.STATE_LOADING);
+ }
+
+ otherSwitcher.pendingTabChild.delete(otherBrowser);
} else {
otherState = (otherBrowser.docShellIsActive
? this.STATE_LOADED
: this.STATE_UNLOADED);
}
if (!this.swapMap) {
this.swapMap = new WeakMap();
}
- this.swapMap.set(otherBrowser, otherState);
+ this.swapMap.set(otherBrowser, {
+ state: otherState,
+ pendingTabChild,
+ });
},
onEndSwapDocShells(ourBrowser, otherBrowser) {
// The swap has happened. We reset the loadingTab in
// case it has been swapped. We also set ourBrowser's state
// to whatever otherBrowser's state was before the swap.
if (this.loadTimer) {
@@ -4269,22 +4281,27 @@
// ready yet. Typically it will already be ready
// though. If it's not, we're probably in a new window,
// in which case we have no other tabs to display anyway.
this.clearTimer(this.loadTimer);
this.loadTimer = null;
}
this.loadingTab = null;
- let otherState = this.swapMap.get(otherBrowser);
+ let { state: otherState, pendingTabChild } =
+ this.swapMap.get(otherBrowser);
+
this.swapMap.delete(otherBrowser);
let ourTab = this.tabbrowser.getTabForBrowser(ourBrowser);
if (ourTab) {
this.setTabStateNoAction(ourTab, otherState);
+ if (pendingTabChild) {
+ this.pendingTabChild.add(ourTab.linkedBrowser);
+ }
}
},
shouldActivateDocShell(browser) {
let tab = this.tabbrowser.getTabForBrowser(browser);
let state = this.getTabState(tab);
return state == this.STATE_LOADING || state == this.STATE_LOADED;
},