Bug 1343174 - Part 1 - When looking for tabs with the same URL, fall back to the session store data for zombie tabs. r?ahunt
Delay-loaded tabs all have browsers pointing to about:blank, so there's not much sense in querying browser.currentURI for them. Instead we read their session data to determine the correct URL, which allows selectOrAddTab to successfully detect duplicate tabs even when they are zombified.
MozReview-Commit-ID: JZ179Y85Ehe
--- a/mobile/android/chrome/content/browser.js
+++ b/mobile/android/chrome/content/browser.js
@@ -1342,21 +1342,21 @@ var BrowserApp = {
* @return the tab with the given URL, or null if no such tab exists
*/
getTabWithURL: function getTabWithURL(aURL, aOptions) {
aOptions = aOptions || {};
let uri = Services.io.newURI(aURL);
for (let i = 0; i < this._tabs.length; ++i) {
let tab = this._tabs[i];
if (aOptions.startsWith) {
- if (tab.browser.currentURI.spec.startsWith(aURL)) {
+ if (tab.currentURI.spec.startsWith(aURL)) {
return tab;
}
} else {
- if (tab.browser.currentURI.equals(uri)) {
+ if (tab.currentURI.equals(uri)) {
return tab;
}
}
}
return null;
},
/**
@@ -3971,16 +3971,27 @@ Tab.prototype = {
this._parentId = newParentId;
GlobalEventDispatcher.sendRequest({
type: "Tab:SetParentId",
tabID: this.id,
parentID: newParentId
});
},
+ get currentURI() {
+ if (!this.browser.__SS_restore) {
+ return this.browser.currentURI;
+ } else {
+ // For zombie tabs we need to fall back to the session store data.
+ let data = this.browser.__SS_data;
+ let url = data.entries[data.index - 1].url;
+ return Services.io.newURI(url);
+ }
+ },
+
handleEvent: function(aEvent) {
switch (aEvent.type) {
case "DOMContentLoaded": {
let target = aEvent.originalTarget;
// ignore on frames and other documents
if (target != this.browser.contentDocument)
return;