Bug 1391421 - Part 5 - Normalise the saved "appOrigin" to Punycode. r?jwu draft
authorJan Henning <jh+bugzilla@buttercookie.de>
Thu, 14 Sep 2017 21:09:44 +0200
changeset 665966 8adee8be304d97d2eab8c80f05a39d356469a87d
parent 665965 e17b451164109e2bb6d248a5090ba04e2fd88af5
child 665967 30adf66019d155dba82ecf235a9f9fb617625015
push id80237
push usermozilla@buttercookie.de
push dateSat, 16 Sep 2017 21:17:08 +0000
reviewersjwu
bugs1391421
milestone57.0a1
Bug 1391421 - Part 5 - Normalise the saved "appOrigin" to Punycode. r?jwu We already use nsUri.spec for comparison when retrieving the stored appOrigin again, so instead of storing the user-entered URL as-is, we should normalise it accordingly. Otherwise, we might end up running into mismatches between the Unicode and Punycode versions of a domain. 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
mobile/android/chrome/content/browser.js
--- 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
@@ -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.spec);
+    }
+
     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;