mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-08-15 08:53:07 +09:00
Bug 1307736 - Store triggeringPrincipal with all history entries
This commit is contained in:
parent
9fca6b7ced
commit
46ef98acf7
4 changed files with 22 additions and 6 deletions
|
|
@ -95,7 +95,10 @@ var SessionHistoryInternal = {
|
|||
// 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())) {
|
||||
data.entries.push({ url: uri });
|
||||
data.entries.push({
|
||||
url: uri,
|
||||
triggeringPrincipal_base64: Utils.SERIALIZED_SYSTEMPRINCIPAL
|
||||
});
|
||||
data.index = 1;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,6 +11,9 @@ Cu.import("resource://gre/modules/XPCOMUtils.jsm", this);
|
|||
Cu.import("resource://gre/modules/Task.jsm", this);
|
||||
Cu.import("resource://gre/modules/osfile.jsm", this);
|
||||
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "Utils",
|
||||
"resource://gre/modules/sessionstore/Utils.jsm");
|
||||
|
||||
// An encoder to UTF-8.
|
||||
XPCOMUtils.defineLazyGetter(this, "gEncoder", function () {
|
||||
return new TextEncoder();
|
||||
|
|
@ -27,7 +30,7 @@ var SessionMigrationInternal = {
|
|||
* only contain:
|
||||
* - open windows
|
||||
* - with tabs
|
||||
* - with history entries with only title, url
|
||||
* - with history entries with only title, url, triggeringPrincipal
|
||||
* - with pinned state
|
||||
* - with tab group info (hidden + group id)
|
||||
* - with selected tab info
|
||||
|
|
@ -45,9 +48,11 @@ var SessionMigrationInternal = {
|
|||
var win = {extData: {}};
|
||||
win.tabs = oldWin.tabs.map(function(oldTab) {
|
||||
var tab = {};
|
||||
// Keep only titles and urls for history entries
|
||||
// Keep only titles, urls and triggeringPrincipals for history entries
|
||||
tab.entries = oldTab.entries.map(function(entry) {
|
||||
return {url: entry.url, title: entry.title};
|
||||
return { url: entry.url,
|
||||
triggeringPrincipal_base64: entry.triggeringPrincipal_base64,
|
||||
title: entry.title };
|
||||
});
|
||||
tab.index = oldTab.index;
|
||||
tab.hidden = oldTab.hidden;
|
||||
|
|
@ -60,7 +65,8 @@ var SessionMigrationInternal = {
|
|||
});
|
||||
let url = "about:welcomeback";
|
||||
let formdata = {id: {sessionData: state}, url};
|
||||
return {windows: [{tabs: [{entries: [{url}], formdata}]}]};
|
||||
let entry = { url, triggeringPrincipal_base64: Utils.SERIALIZED_SYSTEMPRINCIPAL };
|
||||
return { windows: [{ tabs: [{ entries: [ entry ], formdata}]}]};
|
||||
},
|
||||
/**
|
||||
* Asynchronously read session restore state (JSON) from a path
|
||||
|
|
|
|||
|
|
@ -603,12 +603,14 @@ var SessionStoreInternal = {
|
|||
// replace the crashed session with a restore-page-only session
|
||||
let url = "about:sessionrestore";
|
||||
let formdata = {id: {sessionData: state}, url};
|
||||
state = { windows: [{ tabs: [{ entries: [{url}], formdata }] }] };
|
||||
let entry = {url, triggeringPrincipal_base64: Utils.SERIALIZED_SYSTEMPRINCIPAL };
|
||||
state = { windows: [{ tabs: [{ entries: [entry], formdata }] }] };
|
||||
} else if (this._hasSingleTabWithURL(state.windows,
|
||||
"about:welcomeback")) {
|
||||
// On a single about:welcomeback URL that crashed, replace about:welcomeback
|
||||
// with about:sessionrestore, to make clear to the user that we crashed.
|
||||
state.windows[0].tabs[0].entries[0].url = "about:sessionrestore";
|
||||
state.windows[0].tabs[0].entries[0].triggeringPrincipal_base64 = Utils.SERIALIZED_SYSTEMPRINCIPAL;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -16,12 +16,17 @@ Cu.import("resource://gre/modules/XPCOMUtils.jsm", this);
|
|||
XPCOMUtils.defineLazyServiceGetter(this, "serializationHelper",
|
||||
"@mozilla.org/network/serialization-helper;1",
|
||||
"nsISerializationHelper");
|
||||
XPCOMUtils.defineLazyGetter(this, "SERIALIZED_SYSTEMPRINCIPAL", function() {
|
||||
return Utils.serializePrincipal(Services.scriptSecurityManager.getSystemPrincipal());
|
||||
});
|
||||
|
||||
function debug(msg) {
|
||||
Services.console.logStringMessage("Utils: " + msg);
|
||||
}
|
||||
|
||||
this.Utils = Object.freeze({
|
||||
get SERIALIZED_SYSTEMPRINCIPAL() { return SERIALIZED_SYSTEMPRINCIPAL; },
|
||||
|
||||
makeURI: function (url) {
|
||||
return Services.io.newURI(url, null, null);
|
||||
},
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue