Bug 1391421 - Part 5 - Normalise the saved "appOrigin" to Unicode. r?jwu
To avoid mismatches between the Unicode and Punycode versions of a domain, we should normalise the "appOrigin" that can get stored as part of a tab's extra session store data.
To that extent, we move the code that stores the appOrigin into the Tab object's constructor, so we don't have to parse the URL twice.
MozReview-Commit-ID: KFr8CeeOYTe
--- a/mobile/android/chrome/content/browser.js
+++ b/mobile/android/chrome/content/browser.js
@@ -1208,22 +1208,16 @@ var BrowserApp = {
} else {
this._tabs.push(newTab);
}
let selected = "selected" in aParams ? aParams.selected : true;
if (selected)
this.selectedTab = newTab;
- let pinned = "pinned" in aParams ? aParams.pinned : false;
- if (pinned) {
- let ss = Cc["@mozilla.org/browser/sessionstore;1"].getService(Ci.nsISessionStore);
- ss.setTabValue(newTab, "appOrigin", aURI);
- }
-
let evt = document.createEvent("UIEvents");
evt.initUIEvent("TabOpen", true, false, window, null);
newTab.browser.dispatchEvent(evt);
return newTab;
},
// Use this method to close a tab from JS. This method sends a message
@@ -3382,17 +3376,17 @@ nsBrowserAccess.prototype = {
} catch(e) { }
}
let ss = Cc["@mozilla.org/browser/sessionstore;1"].getService(Ci.nsISessionStore);
let pinned = false;
if (aURI && aWhere == Ci.nsIBrowserDOMWindow.OPEN_SWITCHTAB) {
pinned = true;
- let spec = aURI.spec;
+ let spec = aURI.displaySpec;
let tabs = BrowserApp.tabs;
for (let i = 0; i < tabs.length; i++) {
let appOrigin = ss.getTabValue(tabs[i], "appOrigin");
if (appOrigin == spec) {
let tab = tabs[i];
BrowserApp.selectTab(tab);
return tab.browser;
}
@@ -3670,16 +3664,22 @@ Tab.prototype = {
}],
index: 1,
desktopMode: this.desktopMode,
isPrivate: isPrivate,
tabId: this.id,
parentId: this.parentId
};
+ let pinned = "pinned" in aParams ? aParams.pinned : false;
+ if (pinned && uri) {
+ let ss = Cc["@mozilla.org/browser/sessionstore;1"].getService(Ci.nsISessionStore);
+ ss.setTabValue(this, "appOrigin", uri);
+ }
+
if (aParams.delayLoad) {
// If this is a zombie tab, mark the browser for delay loading, which will
// restore the tab when selected using the session data added above
this.browser.__SS_restore = true;
this.browser.setAttribute("pending", "true");
} else {
let flags = "flags" in aParams ? aParams.flags : Ci.nsIWebNavigation.LOAD_FLAGS_NONE;
let postData = ("postData" in aParams && aParams.postData) ? aParams.postData.value : null;