Bug 1391421 - Part 4 - Switch Session Store to save the "display" URL. r?mikedeboer draft
authorJan Henning <jh+bugzilla@buttercookie.de>
Thu, 14 Sep 2017 21:29:45 +0200
changeset 666448 6ec808350092387f6bde13e208c1612885f60154
parent 666447 0ef4a646eba39aac9a021fd896ba0aba6960fd79
child 666449 4b447648f7735f22c0fb464f463dfe3b8d85830a
push id80411
push usermozilla@buttercookie.de
push dateMon, 18 Sep 2017 19:20:36 +0000
reviewersmikedeboer
bugs1391421
milestone57.0a1
Bug 1391421 - Part 4 - Switch Session Store to save the "display" URL. r?mikedeboer The URL can end up being user-visible for "Recently closed tabs" (certainly on Android, and also when hovering over an entry on Desktop, at least in the old menu bar), so we should use pretty URLs instead of Punycode. MozReview-Commit-ID: Kil2ChToYa8
mobile/android/chrome/content/browser.js
toolkit/modules/sessionstore/SessionHistory.jsm
--- a/mobile/android/chrome/content/browser.js
+++ b/mobile/android/chrome/content/browser.js
@@ -3660,17 +3660,17 @@ Tab.prototype = {
     Services.obs.addObserver(this, "audioFocusChanged", false);
     Services.obs.addObserver(this, "before-first-paint");
     Services.obs.addObserver(this, "media-playback");
 
     // Always initialise new tabs with basic session store data to avoid
     // problems with functions that always expect it to be present
     this.browser.__SS_data = {
       entries: [{
-        url: aURL,
+        url: uri,
         title: truncate(title, MAX_TITLE_LENGTH)
       }],
       index: 1,
       desktopMode: this.desktopMode,
       isPrivate: isPrivate,
       tabId: this.id,
       parentId: this.parentId
     };
--- a/toolkit/modules/sessionstore/SessionHistory.jsm
+++ b/toolkit/modules/sessionstore/SessionHistory.jsm
@@ -101,17 +101,17 @@ var SessionHistoryInternal = {
       // Ensure the index isn't out of bounds if an exception was thrown above.
       data.index = Math.min(history.index + 1, entryCount);
     }
 
     // If either the session history isn't available yet or doesn't have any
     // valid entries, make sure we at least include the current page,
     // unless of course we just skipped all entries because aFromIdx was big enough.
     if (data.entries.length == 0 && (skippedCount != entryCount || aFromIdx < 0)) {
-      let uri = webNavigation.currentURI.spec;
+      let uri = webNavigation.currentURI.displaySpec;
       let body = webNavigation.document.body;
       // We landed here because the history is inaccessible or there are no
       // history entries. In that case we should at least record the docShell's
       // current URL as a single history entry. If the URL is not about:blank
       // or it's a blank tab that was modified (like a custom newtab page),
       // record it. For about:blank we explicitly want an empty array without
       // an 'index' property to denote that there are no history entries.
       if (uri != "about:blank" || (body && body.hasChildNodes())) {
@@ -141,17 +141,17 @@ var SessionHistoryInternal = {
   /**
    * Get an object that is a serialized representation of a History entry.
    *
    * @param shEntry
    *        nsISHEntry instance
    * @return object
    */
   serializeEntry(shEntry) {
-    let entry = { url: shEntry.URI.spec, title: shEntry.title };
+    let entry = { url: shEntry.URI.displaySpec, title: shEntry.title };
 
     if (shEntry.isSubFrame) {
       entry.subframe = true;
     }
 
     let cacheKey = shEntry.cacheKey;
     if (cacheKey && cacheKey instanceof Ci.nsISupportsPRUint32 &&
         cacheKey.data != 0) {