Bug 1391421 - Part 3 - 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 665964 132853c164f622926113482f1db8bd9da524fd81
parent 665963 71361a0a2979581828a8b0e6d7d3b1c8c7cc7204
child 665965 e17b451164109e2bb6d248a5090ba04e2fd88af5
push id80237
push usermozilla@buttercookie.de
push dateSat, 16 Sep 2017 21:17:08 +0000
reviewersmikedeboer
bugs1391421
milestone57.0a1
Bug 1391421 - Part 3 - 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.displaySpec,
         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) {