Bug 1351739 - Part 4 - Handle selected tab temporarily being undefined. r=sebastian,walkingice

This can happen if closing a tab (via the back button) simultaneously also triggered an activity switch (by selecting the parent tab). In that case the tab is closed, but formal selection of the new tab only completes after we've switched activities. At the moment activity switching might trigger an application-background/foreground cycle, which means we could hit the selected tab temporarily being undefined in Gecko.

MozReview-Commit-ID: 6p4cOqj29HX

--HG--
extra : rebase_source : 81db83e79d31cf6398f449bba14a4fb1bdc97810
This commit is contained in:
Jan Henning 2017-04-09 19:49:02 +02:00
Родитель 65014acc8c
Коммит 4cc5180850
1 изменённых файлов: 6 добавлений и 2 удалений

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

@ -230,6 +230,8 @@ SessionStore.prototype = {
}
},
// Removal of line below tracked by bug 1360287
// eslint-disable-next-line complexity
observe: function ss_observe(aSubject, aTopic, aData) {
let observerService = Services.obs;
switch (aTopic) {
@ -404,9 +406,11 @@ SessionStore.prototype = {
// If we skipped restoring a zombified tab before backgrounding,
// we might have to do it now instead.
let window = Services.wm.getMostRecentWindow("navigator:browser");
if (window) { // Might not yet be ready during a cold startup.
if (window && window.BrowserApp) { // Might not yet be ready during a cold startup.
let tab = window.BrowserApp.selectedTab;
this.restoreZombieTab(tab);
if (tab) { // Can be null if closing a tab triggered an activity switch.
this.restoreZombieTab(tab);
}
}
break;
case "last-pb-context-exited":