Bug 1391421 - Part 5 - Normalise the saved "appOrigin" to Unicode. r?jwu draft
authorJan Henning <jh+bugzilla@buttercookie.de>
Thu, 14 Sep 2017 21:09:44 +0200
changeset 666449 4b447648f7735f22c0fb464f463dfe3b8d85830a
parent 666448 6ec808350092387f6bde13e208c1612885f60154
child 666450 dfa4aec27a6c51e106425a485702cee63c1802fa
push id80411
push usermozilla@buttercookie.de
push dateMon, 18 Sep 2017 19:20:36 +0000
reviewersjwu
bugs1391421
milestone57.0a1
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
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
@@ -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;