Bug 1412456 - Change browser element's primary attribute immediately when tab change requested (r=mconley)

Currently the e10s tab switcher doesn't set the primary="true"
attribute on a browser element until the tab switcher is
destroyed. This means that using the |content| global is unreliable in
e10s since it may take as long as the tab switcher's unload delay
before the attribute changes. Normally this doesn't matter since
|content| isn't useful in e10s. However, tests that use tabs like
about:preferences rely on |content|, and there isn't a good reason to
fix them. So let's just change the attribute immediately upon changing
tabs.

MozReview-Commit-ID: 1cgJbmXD6of
This commit is contained in:
Bill McCloskey 2017-12-04 16:20:21 -08:00
Родитель 6d7335810e
Коммит e3badbc54e
1 изменённых файлов: 13 добавлений и 15 удалений

Просмотреть файл

@ -4301,10 +4301,10 @@
// Auxilliary state variables:
visibleTab: this.selectedTab, // Tab that's on screen.
spinnerTab: null, // Tab showing a spinner.
blankTab: null, // Tab showing blank.
originalTab: this.selectedTab, // Tab that we started on.
visibleTab: this.selectedTab, // Tab that's on screen.
spinnerTab: null, // Tab showing a spinner.
blankTab: null, // Tab showing blank.
lastPrimaryTab: this.selectedTab, // Tab with primary="true"
tabbrowser: this, // Reference to gBrowser.
loadTimer: null, // TAB_SWITCH_TIMEOUT nsITimer instance.
@ -4485,17 +4485,6 @@
this.destroy();
let toBrowser = this.requestedTab.linkedBrowser;
toBrowser.setAttribute("primary", "true");
let fromBrowser = this.originalTab.linkedBrowser;
// It's possible that the tab we're switching from closed
// before we were able to finalize, in which case, fromBrowser
// doesn't exist.
if (fromBrowser) {
fromBrowser.removeAttribute("primary");
}
document.commandDispatcher.unlock();
let event = new CustomEvent("TabSwitchDone", {
@ -4673,6 +4662,9 @@
if (this.lastVisibleTab && !this.lastVisibleTab.linkedBrowser) {
this.lastVisibleTab = null;
}
if (this.lastPrimaryTab && !this.lastPrimaryTab.linkedBrowser) {
this.lastPrimaryTab = null;
}
if (this.blankTab && !this.blankTab.linkedBrowser) {
this.blankTab = null;
}
@ -5051,6 +5043,12 @@
this.requestedTab = tab;
tab.linkedBrowser.setAttribute("primary", "true");
if (this.lastPrimaryTab && this.lastPrimaryTab != tab) {
this.lastPrimaryTab.linkedBrowser.removeAttribute("primary");
}
this.lastPrimaryTab = tab;
this.suppressDisplayPortAndQueueUnload(this.requestedTab, this.UNLOAD_DELAY);
this._requestingTab = false;
},