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
--- 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) {