зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1521549 - Move (de)serializePrincipal from sessionstore Utils to E10SUtils. r=Gijs
Differential Revision: https://phabricator.services.mozilla.com/D17261 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
c607e645dc
Коммит
cf14643de4
|
@ -8,8 +8,8 @@ const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
|
|||
var EXPORTED_SYMBOLS = ["BlockedSiteChild"];
|
||||
|
||||
const {ActorChild} = ChromeUtils.import("resource://gre/modules/ActorChild.jsm");
|
||||
ChromeUtils.defineModuleGetter(this, "Utils",
|
||||
"resource://gre/modules/sessionstore/Utils.jsm");
|
||||
ChromeUtils.defineModuleGetter(this, "E10SUtils",
|
||||
"resource://gre/modules/E10SUtils.jsm");
|
||||
|
||||
ChromeUtils.defineModuleGetter(this, "SafeBrowsing",
|
||||
"resource://gre/modules/SafeBrowsing.jsm");
|
||||
|
@ -31,7 +31,7 @@ function getSiteBlockedErrorDetails(docShell) {
|
|||
.finalize();
|
||||
}
|
||||
|
||||
let triggeringPrincipal = docShell.failedChannel.loadInfo ? Utils.serializePrincipal(docShell.failedChannel.loadInfo.triggeringPrincipal) : null;
|
||||
let triggeringPrincipal = docShell.failedChannel.loadInfo ? E10SUtils.serializePrincipal(docShell.failedChannel.loadInfo.triggeringPrincipal) : null;
|
||||
blockedInfo = { list: classifiedChannel.matchedList,
|
||||
triggeringPrincipal,
|
||||
provider: classifiedChannel.matchedProvider,
|
||||
|
|
|
@ -69,7 +69,6 @@ XPCOMUtils.defineLazyModuleGetters(this, {
|
|||
UrlbarTokenizer: "resource:///modules/UrlbarTokenizer.jsm",
|
||||
UrlbarUtils: "resource:///modules/UrlbarUtils.jsm",
|
||||
UrlbarValueFormatter: "resource:///modules/UrlbarValueFormatter.jsm",
|
||||
Utils: "resource://gre/modules/sessionstore/Utils.jsm",
|
||||
Weave: "resource://services-sync/main.js",
|
||||
WebNavigationFrames: "resource://gre/modules/WebNavigationFrames.jsm",
|
||||
fxAccounts: "resource://gre/modules/FxAccounts.jsm",
|
||||
|
@ -3105,7 +3104,7 @@ var BrowserOnClick = {
|
|||
},
|
||||
|
||||
ignoreWarningLink(reason, blockedInfo) {
|
||||
let triggeringPrincipal = Utils.deserializePrincipal(blockedInfo.triggeringPrincipal) || _createNullPrincipalFromTabUserContextId();
|
||||
let triggeringPrincipal = E10SUtils.deserializePrincipal(blockedInfo.triggeringPrincipal) || _createNullPrincipalFromTabUserContextId();
|
||||
// Allow users to override and continue through to the site,
|
||||
// but add a notify bar as a reminder, so that they don't lose
|
||||
// track after, e.g., tab switching.
|
||||
|
|
|
@ -2554,7 +2554,7 @@ window._gBrowser = {
|
|||
entries: [{
|
||||
url: lazyBrowserURI ? lazyBrowserURI.spec : "about:blank",
|
||||
title: lazyTabTitle,
|
||||
triggeringPrincipal_base64: Utils.serializePrincipal(triggeringPrincipal),
|
||||
triggeringPrincipal_base64: E10SUtils.serializePrincipal(triggeringPrincipal),
|
||||
}],
|
||||
});
|
||||
} else {
|
||||
|
@ -5599,7 +5599,7 @@ var TabContextMenu = {
|
|||
// from SessionStore
|
||||
let tabState = JSON.parse(SessionStore.getTabState(tab));
|
||||
try {
|
||||
triggeringPrincipal = Utils.deserializePrincipal(tabState.triggeringPrincipal_base64);
|
||||
triggeringPrincipal = E10SUtils.deserializePrincipal(tabState.triggeringPrincipal_base64);
|
||||
} catch (ex) {
|
||||
continue;
|
||||
}
|
||||
|
|
|
@ -6,9 +6,10 @@ ChromeUtils.defineModuleGetter(this, "SessionStore",
|
|||
"resource:///modules/sessionstore/SessionStore.jsm");
|
||||
ChromeUtils.defineModuleGetter(this, "TabStateFlusher",
|
||||
"resource:///modules/sessionstore/TabStateFlusher.jsm");
|
||||
ChromeUtils.defineModuleGetter(this, "E10SUtils",
|
||||
"resource://gre/modules/E10SUtils.jsm");
|
||||
|
||||
ChromeUtils.import("resource://gre/modules/sessionstore/Utils.jsm", this);
|
||||
const triggeringPrincipal_base64 = Utils.SERIALIZED_SYSTEMPRINCIPAL;
|
||||
const triggeringPrincipal_base64 = E10SUtils.SERIALIZED_SYSTEMPRINCIPAL;
|
||||
|
||||
function promiseBrowserStateRestored(state) {
|
||||
if (typeof state != "string") {
|
||||
|
|
|
@ -3,8 +3,8 @@
|
|||
/* global gBrowser SessionStore */
|
||||
"use strict";
|
||||
|
||||
const {Utils} = ChromeUtils.import("resource://gre/modules/sessionstore/Utils.jsm");
|
||||
const triggeringPrincipal_base64 = Utils.SERIALIZED_SYSTEMPRINCIPAL;
|
||||
const {E10SUtils} = ChromeUtils.import("resource://gre/modules/E10SUtils.jsm");
|
||||
const triggeringPrincipal_base64 = E10SUtils.SERIALIZED_SYSTEMPRINCIPAL;
|
||||
|
||||
let lazyTabState = {entries: [{url: "http://example.com/", triggeringPrincipal_base64, title: "Example Domain"}]};
|
||||
|
||||
|
|
|
@ -4,8 +4,8 @@ ChromeUtils.defineModuleGetter(this, "SessionStore",
|
|||
"resource:///modules/sessionstore/SessionStore.jsm");
|
||||
ChromeUtils.defineModuleGetter(this, "TabStateFlusher",
|
||||
"resource:///modules/sessionstore/TabStateFlusher.jsm");
|
||||
const {Utils} = ChromeUtils.import("resource://gre/modules/sessionstore/Utils.jsm");
|
||||
const triggeringPrincipal_base64 = Utils.SERIALIZED_SYSTEMPRINCIPAL;
|
||||
const {E10SUtils} = ChromeUtils.import("resource://gre/modules/E10SUtils.jsm");
|
||||
const triggeringPrincipal_base64 = E10SUtils.SERIALIZED_SYSTEMPRINCIPAL;
|
||||
|
||||
async function doorhangerTest(testFn) {
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
"use strict";
|
||||
|
||||
const {Utils} = ChromeUtils.import("resource://gre/modules/sessionstore/Utils.jsm");
|
||||
const triggeringPrincipal_base64 = Utils.SERIALIZED_SYSTEMPRINCIPAL;
|
||||
const {E10SUtils} = ChromeUtils.import("resource://gre/modules/E10SUtils.jsm");
|
||||
const triggeringPrincipal_base64 = E10SUtils.SERIALIZED_SYSTEMPRINCIPAL;
|
||||
|
||||
const SESSION = {
|
||||
windows: [{
|
||||
|
|
|
@ -33,10 +33,10 @@ skip-if = (os == 'win' && processor == "x86_64") # Bug 1480314
|
|||
[browser_bug1018066_resetScrollPosition.js]
|
||||
[browser_bug1020245_openPreferences_to_paneContent.js]
|
||||
[browser_bug1184989_prevent_scrolling_when_preferences_flipped.js]
|
||||
[browser_cert_export.js]
|
||||
[browser_engines.js]
|
||||
support-files =
|
||||
browser_bug1184989_prevent_scrolling_when_preferences_flipped.xul
|
||||
[browser_cert_export.js]
|
||||
[browser_engines.js]
|
||||
[browser_change_app_handler.js]
|
||||
skip-if = os != "win" # Windows-specific handler application selection dialog
|
||||
[browser_checkspelling.js]
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
const {Utils} = ChromeUtils.import("resource://gre/modules/sessionstore/Utils.jsm");
|
||||
const triggeringPrincipal_base64 = Utils.SERIALIZED_SYSTEMPRINCIPAL;
|
||||
const {E10SUtils} = ChromeUtils.import("resource://gre/modules/E10SUtils.jsm");
|
||||
const triggeringPrincipal_base64 = E10SUtils.SERIALIZED_SYSTEMPRINCIPAL;
|
||||
|
||||
add_task(async function() {
|
||||
waitForExplicitFinish();
|
||||
|
|
|
@ -212,9 +212,9 @@ ContentRestoreInternal.prototype = {
|
|||
referrerInfo = new ReferrerInfo(referrerPolicy, true, referrer);
|
||||
}
|
||||
let postData = loadArguments.postData ?
|
||||
Utils.makeInputStream(loadArguments.postData) : null;
|
||||
E10SUtils.makeInputStream(loadArguments.postData) : null;
|
||||
let triggeringPrincipal = loadArguments.triggeringPrincipal
|
||||
? Utils.deserializePrincipal(loadArguments.triggeringPrincipal)
|
||||
? E10SUtils.deserializePrincipal(loadArguments.triggeringPrincipal)
|
||||
: Services.scriptSecurityManager.createNullPrincipal({});
|
||||
|
||||
if (loadArguments.userContextId) {
|
||||
|
|
|
@ -9,8 +9,8 @@ var EXPORTED_SYMBOLS = ["SessionMigration"];
|
|||
ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm", this);
|
||||
ChromeUtils.import("resource://gre/modules/osfile.jsm", this);
|
||||
|
||||
ChromeUtils.defineModuleGetter(this, "Utils",
|
||||
"resource://gre/modules/sessionstore/Utils.jsm");
|
||||
ChromeUtils.defineModuleGetter(this, "E10SUtils",
|
||||
"resource://gre/modules/E10SUtils.jsm");
|
||||
|
||||
// An encoder to UTF-8.
|
||||
XPCOMUtils.defineLazyGetter(this, "gEncoder", function() {
|
||||
|
@ -63,7 +63,7 @@ var SessionMigrationInternal = {
|
|||
});
|
||||
let url = "about:welcomeback";
|
||||
let formdata = {id: {sessionData: state}, url};
|
||||
let entry = { url, triggeringPrincipal_base64: Utils.SERIALIZED_SYSTEMPRINCIPAL };
|
||||
let entry = { url, triggeringPrincipal_base64: E10SUtils.SERIALIZED_SYSTEMPRINCIPAL };
|
||||
return { windows: [{ tabs: [{ entries: [ entry ], formdata}]}]};
|
||||
},
|
||||
/**
|
||||
|
|
|
@ -682,14 +682,14 @@ var SessionStoreInternal = {
|
|||
// replace the crashed session with a restore-page-only session
|
||||
let url = "about:sessionrestore";
|
||||
let formdata = {id: {sessionData: state}, url};
|
||||
let entry = {url, triggeringPrincipal_base64: Utils.SERIALIZED_SYSTEMPRINCIPAL };
|
||||
let entry = {url, triggeringPrincipal_base64: E10SUtils.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;
|
||||
state.windows[0].tabs[0].entries[0].triggeringPrincipal_base64 = E10SUtils.SERIALIZED_SYSTEMPRINCIPAL;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -2,8 +2,8 @@
|
|||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
const {Utils} = ChromeUtils.import("resource://gre/modules/sessionstore/Utils.jsm");
|
||||
const triggeringPrincipal_base64 = Utils.SERIALIZED_SYSTEMPRINCIPAL;
|
||||
const {E10SUtils} = ChromeUtils.import("resource://gre/modules/E10SUtils.jsm");
|
||||
const triggeringPrincipal_base64 = E10SUtils.SERIALIZED_SYSTEMPRINCIPAL;
|
||||
|
||||
const TAB_STATE_NEEDS_RESTORE = 1;
|
||||
const TAB_STATE_RESTORING = 2;
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
"use strict";
|
||||
|
||||
const {Utils} = ChromeUtils.import("resource://gre/modules/sessionstore/Utils.jsm");
|
||||
const triggeringPrincipal_base64 = Utils.SERIALIZED_SYSTEMPRINCIPAL;
|
||||
const {E10SUtils} = ChromeUtils.import("resource://gre/modules/E10SUtils.jsm");
|
||||
const triggeringPrincipal_base64 = E10SUtils.SERIALIZED_SYSTEMPRINCIPAL;
|
||||
|
||||
const MAX_CONCURRENT_TABS = "browser.engagement.max_concurrent_tab_count";
|
||||
const TAB_EVENT_COUNT = "browser.engagement.tab_open_event_count";
|
||||
|
|
|
@ -8,9 +8,8 @@ const { Cc, Ci, Cu, Cr } = require("chrome");
|
|||
const ChromeUtils = require("ChromeUtils");
|
||||
const Services = require("Services");
|
||||
const { NetUtil } = require("resource://gre/modules/NetUtil.jsm");
|
||||
const { Utils } = require("resource://gre/modules/sessionstore/Utils.jsm");
|
||||
const Telemetry = require("devtools/client/shared/telemetry");
|
||||
const { E10SUtils } = require("resource://gre/modules/E10SUtils.jsm");
|
||||
const Telemetry = require("devtools/client/shared/telemetry");
|
||||
|
||||
const telemetry = new Telemetry();
|
||||
|
||||
|
@ -83,7 +82,7 @@ BrowserElementWebNavigation.prototype = {
|
|||
postData: postData ? readInputStreamToString(postData) : null,
|
||||
headers: headers ? readInputStreamToString(headers) : null,
|
||||
baseURI: baseURI ? baseURI.spec : null,
|
||||
triggeringPrincipal: Utils.serializePrincipal(
|
||||
triggeringPrincipal: E10SUtils.serializePrincipal(
|
||||
triggeringPrincipal ||
|
||||
Services.scriptSecurityManager.createNullPrincipal({})),
|
||||
requestTime: telemetry.msSystemNow(),
|
||||
|
|
|
@ -2,8 +2,8 @@
|
|||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
"use strict";
|
||||
|
||||
const {Utils} = ChromeUtils.import("resource://gre/modules/sessionstore/Utils.jsm");
|
||||
const triggeringPrincipal_base64 = Utils.SERIALIZED_SYSTEMPRINCIPAL;
|
||||
const {E10SUtils} = ChromeUtils.import("resource://gre/modules/E10SUtils.jsm");
|
||||
const triggeringPrincipal_base64 = E10SUtils.SERIALIZED_SYSTEMPRINCIPAL;
|
||||
|
||||
const testState = {
|
||||
windows: [{
|
||||
|
|
|
@ -108,7 +108,7 @@ XPCOMUtils.defineLazyServiceGetter(this, "FontEnumerator",
|
|||
"@mozilla.org/gfx/fontenumerator;1",
|
||||
"nsIFontEnumerator");
|
||||
|
||||
ChromeUtils.defineModuleGetter(this, "Utils", "resource://gre/modules/sessionstore/Utils.jsm");
|
||||
ChromeUtils.defineModuleGetter(this, "E10SUtils", "resource://gre/modules/E10SUtils.jsm");
|
||||
|
||||
ChromeUtils.defineModuleGetter(this, "FormLikeFactory",
|
||||
"resource://gre/modules/FormLikeFactory.jsm");
|
||||
|
@ -3841,7 +3841,7 @@ Tab.prototype = {
|
|||
// Always initialise new tabs with basic session store data to avoid
|
||||
// problems with functions that always expect it to be present
|
||||
let triggeringPrincipal_base64 = aParams.triggeringPrincipal ?
|
||||
Utils.serializePrincipal(aParams.triggeringPrincipal) : Utils.SERIALIZED_SYSTEMPRINCIPAL;
|
||||
E10SUtils.serializePrincipal(aParams.triggeringPrincipal) : E10SUtils.SERIALIZED_SYSTEMPRINCIPAL;
|
||||
this.browser.__SS_data = {
|
||||
entries: [{
|
||||
url: uri,
|
||||
|
|
|
@ -10,7 +10,7 @@ const {GeckoViewModule} = ChromeUtils.import("resource://gre/modules/GeckoViewMo
|
|||
const {XPCOMUtils} = ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
|
||||
XPCOMUtils.defineLazyModuleGetters(this, {
|
||||
Utils: "resource://gre/modules/sessionstore/Utils.jsm",
|
||||
E10SUtils: "resource://gre/modules/sessionstore/Utils.jsm",
|
||||
LoadURIDelegate: "resource://gre/modules/LoadURIDelegate.jsm",
|
||||
Services: "resource://gre/modules/Services.jsm",
|
||||
});
|
||||
|
@ -130,7 +130,7 @@ class GeckoViewNavigation extends GeckoViewModule {
|
|||
this.browser.loadURI(uri, {
|
||||
flags,
|
||||
referrerURI: referrer,
|
||||
triggeringPrincipal: Utils.deserializePrincipal(triggeringPrincipal),
|
||||
triggeringPrincipal: E10SUtils.deserializePrincipal(triggeringPrincipal),
|
||||
});
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -12,8 +12,6 @@ const {XPCOMUtils} = ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm")
|
|||
|
||||
ChromeUtils.defineModuleGetter(this, "AppConstants",
|
||||
"resource://gre/modules/AppConstants.jsm");
|
||||
ChromeUtils.defineModuleGetter(this, "Utils",
|
||||
"resource://gre/modules/sessionstore/Utils.jsm");
|
||||
ChromeUtils.defineModuleGetter(this, "E10SUtils",
|
||||
"resource://gre/modules/E10SUtils.jsm");
|
||||
|
||||
|
@ -100,14 +98,14 @@ class WebNavigationChild extends ActorChild {
|
|||
CrashReporter.annotateCrashReport("URL", annotation);
|
||||
}
|
||||
if (postData)
|
||||
postData = Utils.makeInputStream(postData);
|
||||
postData = E10SUtils.makeInputStream(postData);
|
||||
if (headers)
|
||||
headers = Utils.makeInputStream(headers);
|
||||
headers = E10SUtils.makeInputStream(headers);
|
||||
if (baseURI)
|
||||
baseURI = Services.io.newURI(baseURI);
|
||||
this._assert(triggeringPrincipal, "We need a triggering principal to continue loading", new Error().lineNumber);
|
||||
if (triggeringPrincipal)
|
||||
triggeringPrincipal = Utils.deserializePrincipal(triggeringPrincipal);
|
||||
triggeringPrincipal = E10SUtils.deserializePrincipal(triggeringPrincipal);
|
||||
this._assert(triggeringPrincipal, "Unable to deserialize passed triggering principal", new Error().lineNumber);
|
||||
if (!triggeringPrincipal) {
|
||||
triggeringPrincipal = Services.scriptSecurityManager.getSystemPrincipal({});
|
||||
|
|
|
@ -96,7 +96,7 @@ RemoteWebNavigation.prototype = {
|
|||
postData: aLoadURIOptions.postData ? Utils.serializeInputStream(aLoadURIOptions.postData) : null,
|
||||
headers: aLoadURIOptions.headers ? Utils.serializeInputStream(aLoadURIOptions.headers) : null,
|
||||
baseURI: aLoadURIOptions.baseURI ? aLoadURIOptions.baseURI.spec : null,
|
||||
triggeringPrincipal: Utils.serializePrincipal(
|
||||
triggeringPrincipal: E10SUtils.serializePrincipal(
|
||||
aLoadURIOptions.triggeringPrincipal || Services.scriptSecurityManager.createNullPrincipal({})),
|
||||
requestTime: Services.telemetry.msSystemNow(),
|
||||
});
|
||||
|
|
|
@ -23,8 +23,9 @@ XPCOMUtils.defineLazyServiceGetter(this, "serializationHelper",
|
|||
"@mozilla.org/network/serialization-helper;1",
|
||||
"nsISerializationHelper");
|
||||
|
||||
ChromeUtils.defineModuleGetter(this, "Utils",
|
||||
"resource://gre/modules/sessionstore/Utils.jsm");
|
||||
function debug(msg) {
|
||||
Cu.reportError(new Error("E10SUtils: " + msg));
|
||||
}
|
||||
|
||||
function getAboutModule(aURL) {
|
||||
// Needs to match NS_GetAboutModuleName
|
||||
|
@ -275,6 +276,73 @@ var E10SUtils = {
|
|||
currentURI);
|
||||
},
|
||||
|
||||
makeInputStream(data) {
|
||||
if (typeof data == "string") {
|
||||
let stream = Cc["@mozilla.org/io/string-input-stream;1"].
|
||||
createInstance(Ci.nsISupportsCString);
|
||||
stream.data = data;
|
||||
return stream; // XPConnect will QI this to nsIInputStream for us.
|
||||
}
|
||||
|
||||
let stream = Cc["@mozilla.org/io/string-input-stream;1"].
|
||||
createInstance(Ci.nsISupportsCString);
|
||||
stream.data = data.content;
|
||||
|
||||
if (data.headers) {
|
||||
let mimeStream = Cc["@mozilla.org/network/mime-input-stream;1"]
|
||||
.createInstance(Ci.nsIMIMEInputStream);
|
||||
|
||||
mimeStream.setData(stream);
|
||||
for (let [name, value] of data.headers) {
|
||||
mimeStream.addHeader(name, value);
|
||||
}
|
||||
return mimeStream;
|
||||
}
|
||||
|
||||
return stream; // XPConnect will QI this to nsIInputStream for us.
|
||||
},
|
||||
|
||||
/**
|
||||
* Serialize principal data.
|
||||
*
|
||||
* @param {nsIPrincipal} principal The principal to serialize.
|
||||
* @return {String} The base64 encoded principal data.
|
||||
*/
|
||||
serializePrincipal(principal) {
|
||||
let serializedPrincipal = null;
|
||||
|
||||
try {
|
||||
if (principal) {
|
||||
serializedPrincipal = serializationHelper.serializeToString(principal);
|
||||
}
|
||||
} catch (e) {
|
||||
debug(`Failed to serialize principal '${principal}' ${e}`);
|
||||
}
|
||||
|
||||
return serializedPrincipal;
|
||||
},
|
||||
|
||||
/**
|
||||
* Deserialize a base64 encoded principal (serialized with
|
||||
* serializePrincipal).
|
||||
*
|
||||
* @param {String} principal_b64 A base64 encoded serialized principal.
|
||||
* @return {nsIPrincipal} A deserialized principal.
|
||||
*/
|
||||
deserializePrincipal(principal_b64) {
|
||||
if (!principal_b64)
|
||||
return null;
|
||||
|
||||
try {
|
||||
let principal = serializationHelper.deserializeObject(principal_b64);
|
||||
principal.QueryInterface(Ci.nsIPrincipal);
|
||||
return principal;
|
||||
} catch (e) {
|
||||
debug(`Failed to deserialize principal_b64 '${principal_b64}' ${e}`);
|
||||
}
|
||||
return null;
|
||||
},
|
||||
|
||||
shouldLoadURIInBrowser(browser, uri, multiProcess = true,
|
||||
flags = Ci.nsIWebNavigation.LOAD_FLAGS_NONE) {
|
||||
let currentRemoteType = browser.remoteType;
|
||||
|
@ -394,7 +462,7 @@ var E10SUtils = {
|
|||
uri: aURI.spec,
|
||||
flags: aFlags || Ci.nsIWebNavigation.LOAD_FLAGS_NONE,
|
||||
referrer: aReferrer ? aReferrer.spec : null,
|
||||
triggeringPrincipal: Utils.serializePrincipal(aTriggeringPrincipal || Services.scriptSecurityManager.createNullPrincipal({})),
|
||||
triggeringPrincipal: this.serializePrincipal(aTriggeringPrincipal || Services.scriptSecurityManager.createNullPrincipal({})),
|
||||
reloadInFreshProcess: !!aFreshProcess,
|
||||
},
|
||||
historyIndex: sessionHistory.legacySHistory.requestedIndex,
|
||||
|
@ -449,3 +517,7 @@ var E10SUtils = {
|
|||
return deserialized;
|
||||
},
|
||||
};
|
||||
|
||||
XPCOMUtils.defineLazyGetter(E10SUtils, "SERIALIZED_SYSTEMPRINCIPAL", function() {
|
||||
return E10SUtils.serializePrincipal(Services.scriptSecurityManager.getSystemPrincipal());
|
||||
});
|
||||
|
|
|
@ -9,8 +9,6 @@ var EXPORTED_SYMBOLS = ["SessionHistory"];
|
|||
const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
|
||||
const {XPCOMUtils} = ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
|
||||
ChromeUtils.defineModuleGetter(this, "Utils",
|
||||
"resource://gre/modules/sessionstore/Utils.jsm");
|
||||
ChromeUtils.defineModuleGetter(this, "E10SUtils",
|
||||
"resource://gre/modules/E10SUtils.jsm");
|
||||
XPCOMUtils.defineLazyServiceGetter(this, "uuidGenerator",
|
||||
|
@ -119,7 +117,7 @@ var SessionHistoryInternal = {
|
|||
if (uri != "about:blank" || (body && body.hasChildNodes())) {
|
||||
data.entries.push({
|
||||
url: uri,
|
||||
triggeringPrincipal_base64: Utils.SERIALIZED_SYSTEMPRINCIPAL,
|
||||
triggeringPrincipal_base64: E10SUtils.SERIALIZED_SYSTEMPRINCIPAL,
|
||||
});
|
||||
data.index = 1;
|
||||
}
|
||||
|
@ -219,11 +217,11 @@ var SessionHistoryInternal = {
|
|||
|
||||
// Collect triggeringPrincipal data for the current history entry.
|
||||
if (shEntry.principalToInherit) {
|
||||
entry.principalToInherit_base64 = Utils.serializePrincipal(shEntry.principalToInherit);
|
||||
entry.principalToInherit_base64 = E10SUtils.serializePrincipal(shEntry.principalToInherit);
|
||||
}
|
||||
|
||||
if (shEntry.triggeringPrincipal) {
|
||||
entry.triggeringPrincipal_base64 = Utils.serializePrincipal(shEntry.triggeringPrincipal);
|
||||
entry.triggeringPrincipal_base64 = E10SUtils.serializePrincipal(shEntry.triggeringPrincipal);
|
||||
}
|
||||
|
||||
entry.docIdentifier = shEntry.BFCacheEntry.ID;
|
||||
|
@ -452,7 +450,7 @@ var SessionHistoryInternal = {
|
|||
}
|
||||
|
||||
if (entry.triggeringPrincipal_base64) {
|
||||
shEntry.triggeringPrincipal = Utils.deserializePrincipal(entry.triggeringPrincipal_base64);
|
||||
shEntry.triggeringPrincipal = E10SUtils.deserializePrincipal(entry.triggeringPrincipal_base64);
|
||||
}
|
||||
// Ensure that we have a null principal if we couldn't deserialize it.
|
||||
// This won't always work however is safe to use.
|
||||
|
@ -461,7 +459,7 @@ var SessionHistoryInternal = {
|
|||
shEntry.triggeringPrincipal = Services.scriptSecurityManager.createNullPrincipal({});
|
||||
}
|
||||
if (entry.principalToInherit_base64) {
|
||||
shEntry.principalToInherit = Utils.deserializePrincipal(entry.principalToInherit_base64);
|
||||
shEntry.principalToInherit = E10SUtils.deserializePrincipal(entry.principalToInherit_base64);
|
||||
}
|
||||
|
||||
if (entry.children) {
|
||||
|
|
|
@ -11,49 +11,13 @@ ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm", this);
|
|||
|
||||
ChromeUtils.defineModuleGetter(this, "NetUtil",
|
||||
"resource://gre/modules/NetUtil.jsm");
|
||||
XPCOMUtils.defineLazyServiceGetter(this, "serializationHelper",
|
||||
"@mozilla.org/network/serialization-helper;1",
|
||||
"nsISerializationHelper");
|
||||
XPCOMUtils.defineLazyServiceGetter(this, "eTLDService",
|
||||
"@mozilla.org/network/effective-tld-service;1",
|
||||
"nsIEffectiveTLDService");
|
||||
|
||||
XPCOMUtils.defineLazyGetter(this, "SERIALIZED_SYSTEMPRINCIPAL", function() {
|
||||
return Utils.serializePrincipal(Services.scriptSecurityManager.getSystemPrincipal());
|
||||
});
|
||||
|
||||
function debug(msg) {
|
||||
Services.console.logStringMessage("Utils: " + msg);
|
||||
}
|
||||
|
||||
var Utils = Object.freeze({
|
||||
get SERIALIZED_SYSTEMPRINCIPAL() { return SERIALIZED_SYSTEMPRINCIPAL; },
|
||||
|
||||
makeInputStream(data) {
|
||||
if (typeof data == "string") {
|
||||
let stream = Cc["@mozilla.org/io/string-input-stream;1"].
|
||||
createInstance(Ci.nsISupportsCString);
|
||||
stream.data = data;
|
||||
return stream; // XPConnect will QI this to nsIInputStream for us.
|
||||
}
|
||||
|
||||
let stream = Cc["@mozilla.org/io/string-input-stream;1"].
|
||||
createInstance(Ci.nsISupportsCString);
|
||||
stream.data = data.content;
|
||||
|
||||
if (data.headers) {
|
||||
let mimeStream = Cc["@mozilla.org/network/mime-input-stream;1"]
|
||||
.createInstance(Ci.nsIMIMEInputStream);
|
||||
|
||||
mimeStream.setData(stream);
|
||||
for (let [name, value] of data.headers) {
|
||||
mimeStream.addHeader(name, value);
|
||||
}
|
||||
return mimeStream;
|
||||
}
|
||||
|
||||
return stream; // XPConnect will QI this to nsIInputStream for us.
|
||||
},
|
||||
|
||||
serializeInputStream(aStream) {
|
||||
let data = {
|
||||
|
@ -99,47 +63,6 @@ var Utils = Object.freeze({
|
|||
return retval;
|
||||
},
|
||||
|
||||
/**
|
||||
* Serialize principal data.
|
||||
*
|
||||
* @param {nsIPrincipal} principal The principal to serialize.
|
||||
* @return {String} The base64 encoded principal data.
|
||||
*/
|
||||
serializePrincipal(principal) {
|
||||
let serializedPrincipal = null;
|
||||
|
||||
try {
|
||||
if (principal) {
|
||||
serializedPrincipal = serializationHelper.serializeToString(principal);
|
||||
}
|
||||
} catch (e) {
|
||||
debug(`Failed to serialize principal '${principal}' ${e}`);
|
||||
}
|
||||
|
||||
return serializedPrincipal;
|
||||
},
|
||||
|
||||
/**
|
||||
* Deserialize a base64 encoded principal (serialized with
|
||||
* Utils::serializePrincipal).
|
||||
*
|
||||
* @param {String} principal_b64 A base64 encoded serialized principal.
|
||||
* @return {nsIPrincipal} A deserialized principal.
|
||||
*/
|
||||
deserializePrincipal(principal_b64) {
|
||||
if (!principal_b64)
|
||||
return null;
|
||||
|
||||
try {
|
||||
let principal = serializationHelper.deserializeObject(principal_b64);
|
||||
principal.QueryInterface(Ci.nsIPrincipal);
|
||||
return principal;
|
||||
} catch (e) {
|
||||
debug(`Failed to deserialize principal_b64 '${principal_b64}' ${e}`);
|
||||
}
|
||||
return null;
|
||||
},
|
||||
|
||||
/**
|
||||
* A function that will recursively call |cb| to collect data for all
|
||||
* non-dynamic frames in the current frame/docShell tree.
|
||||
|
|
Загрузка…
Ссылка в новой задаче