Backed out 6 changesets (bug 1618445) for leaks at mozilla::dom::Console::CreateInstance

Backed out changeset 0a996e80d92a (bug 1618445)
Backed out changeset 4281c434f737 (bug 1618445)
Backed out changeset 846b67024a9a (bug 1618445)
Backed out changeset 439d0b9ba0fc (bug 1618445)
Backed out changeset 79ae5f86d927 (bug 1618445)
Backed out changeset c09a442d8ddf (bug 1618445)
This commit is contained in:
Narcis Beleuzu 2020-03-17 11:14:12 +02:00
parent e23b161122
commit 87ef7e0ec7
2 changed files with 58 additions and 96 deletions

View File

@ -216,6 +216,12 @@ XPCOMUtils.defineLazyModuleGetters(this, {
* Debug mode is controlled by preference browser.sessionstore.debug * Debug mode is controlled by preference browser.sessionstore.debug
*/ */
var gDebuggingEnabled = false; var gDebuggingEnabled = false;
function debug(aMsg) {
if (gDebuggingEnabled) {
aMsg = ("SessionStore: " + aMsg).replace(/\S{80}/g, "$&\n");
Services.console.logStringMessage(aMsg);
}
}
/** /**
* A global value to tell that fingerprinting resistance is enabled or not. * A global value to tell that fingerprinting resistance is enabled or not.
@ -564,8 +570,6 @@ var SessionStoreInternal = {
// number of tabs currently restoring // number of tabs currently restoring
_tabsRestoringCount: 0, _tabsRestoringCount: 0,
_log: null,
// When starting Firefox with a single private window, this is the place // When starting Firefox with a single private window, this is the place
// where we keep the session we actually wanted to restore in case the user // where we keep the session we actually wanted to restore in case the user
// decides to later open a non-private window as well. // decides to later open a non-private window as well.
@ -775,7 +779,7 @@ var SessionStoreInternal = {
}); });
} }
} catch (ex) { } catch (ex) {
this._log.error("The session file is invalid: " + ex); debug("The session file is invalid: " + ex);
} }
} }
@ -801,11 +805,6 @@ var SessionStoreInternal = {
gDebuggingEnabled = this._prefBranch.getBoolPref("sessionstore.debug"); gDebuggingEnabled = this._prefBranch.getBoolPref("sessionstore.debug");
}); });
this._log = console.createInstance({
prefix: "SessionStore",
maxLogLevel: gDebuggingEnabled ? "Debug" : "Warn",
});
this._max_tabs_undo = this._prefBranch.getIntPref( this._max_tabs_undo = this._prefBranch.getIntPref(
"sessionstore.max_tabs_undo" "sessionstore.max_tabs_undo"
); );
@ -2534,8 +2533,8 @@ var SessionStoreInternal = {
aSwitchId, aSwitchId,
aReplaceBrowsingContext aReplaceBrowsingContext
) { ) {
E10SUtils.log().info( debug(
`performing switch from ${aBrowser.remoteType} to ${aRemoteType}` `[process-switch]: performing switch from ${aBrowser.remoteType} to ${aRemoteType}`
); );
// Don't try to switch tabs before delayed startup is completed. // Don't try to switch tabs before delayed startup is completed.
@ -2569,7 +2568,7 @@ var SessionStoreInternal = {
// Tell our caller to redirect the load into this newly created process. // Tell our caller to redirect the load into this newly created process.
let remoteTab = aBrowser.frameLoader.remoteTab; let remoteTab = aBrowser.frameLoader.remoteTab;
E10SUtils.log().debug(`new tabID: ${remoteTab.tabId}`); debug(`[process-switch]: new tabID: ${remoteTab.tabId}`);
return remoteTab.contentProcessId; return remoteTab.contentProcessId;
}, },
@ -2615,7 +2614,7 @@ var SessionStoreInternal = {
try { try {
switchRequestor = aRequestor.QueryInterface(Ci.nsIProcessSwitchRequestor); switchRequestor = aRequestor.QueryInterface(Ci.nsIProcessSwitchRequestor);
} catch (e) { } catch (e) {
E10SUtils.log().warn(`object not compatible with process switching `); debug(`[process-switch]: object not compatible with process switching `);
return; return;
} }
@ -2631,21 +2630,21 @@ var SessionStoreInternal = {
Ci.nsIContentPolicy.TYPE_DOCUMENT; Ci.nsIContentPolicy.TYPE_DOCUMENT;
if (!browsingContext) { if (!browsingContext) {
E10SUtils.log().debug(`no BrowsingContext - ignoring`); debug(`[process-switch]: no BrowsingContext - ignoring`);
return; return;
} }
// Determine if remote subframes should be used for this load. // Determine if remote subframes should be used for this load.
let topBC = browsingContext.top; let topBC = browsingContext.top;
if (!topBC.embedderElement) { if (!topBC.embedderElement) {
E10SUtils.log().debug(`no embedder for top - ignoring`); debug(`[process-switch]: no embedder for top - ignoring`);
return; return;
} }
let topDocShell = topBC.embedderElement.ownerGlobal.docShell; let topDocShell = topBC.embedderElement.ownerGlobal.docShell;
let { useRemoteSubframes } = topDocShell.QueryInterface(Ci.nsILoadContext); let { useRemoteSubframes } = topDocShell.QueryInterface(Ci.nsILoadContext);
if (!useRemoteSubframes && isSubframe) { if (!useRemoteSubframes && isSubframe) {
E10SUtils.log().debug(`remote subframes disabled - ignoring`); debug(`[process-switch]: remote subframes disabled - ignoring`);
return; return;
} }
@ -2661,22 +2660,22 @@ var SessionStoreInternal = {
if (browsingContext.embedderElement) { if (browsingContext.embedderElement) {
let tabbrowser = browsingContext.embedderElement.getTabBrowser(); let tabbrowser = browsingContext.embedderElement.getTabBrowser();
if (!tabbrowser) { if (!tabbrowser) {
E10SUtils.log().debug( debug(
`cannot find tabbrowser for loading tab - ignoring` `[process-switch]: cannot find tabbrowser for loading tab - ignoring`
); );
return; return;
} }
let tab = tabbrowser.getTabForBrowser(browsingContext.embedderElement); let tab = tabbrowser.getTabForBrowser(browsingContext.embedderElement);
if (!tab) { if (!tab) {
E10SUtils.log().debug( debug(
`not a normal tab, so cannot swap processes - ignoring` `[process-switch]: not a normal tab, so cannot swap processes - ignoring`
); );
return; return;
} }
} else if (!browsingContext.parent) { } else if (!browsingContext.parent) {
E10SUtils.log().debug( debug(
`no parent or in-process embedder element - ignoring` `[process-switch] no parent or in-process embedder element - ignoring`
); );
return; return;
} }
@ -2684,7 +2683,7 @@ var SessionStoreInternal = {
// Get the current remote type for the BrowsingContext. // Get the current remote type for the BrowsingContext.
let currentRemoteType = browsingContext.currentRemoteType; let currentRemoteType = browsingContext.currentRemoteType;
if (currentRemoteType == E10SUtils.NOT_REMOTE) { if (currentRemoteType == E10SUtils.NOT_REMOTE) {
E10SUtils.log().debug(`currently not remote - ignoring`); debug(`[process-switch]: currently not remote - ignoring`);
return; return;
} }
@ -2713,8 +2712,8 @@ var SessionStoreInternal = {
// to a default remoteType // to a default remoteType
preferredRemoteType = E10SUtils.DEFAULT_REMOTE_TYPE; preferredRemoteType = E10SUtils.DEFAULT_REMOTE_TYPE;
} }
E10SUtils.log().info( debug(
`currentRemoteType (${currentRemoteType}) preferredRemoteType: ${preferredRemoteType}` `[process-switch]: currentRemoteType (${currentRemoteType}) preferredRemoteType: ${preferredRemoteType}`
); );
let remoteType = E10SUtils.getRemoteTypeForPrincipal( let remoteType = E10SUtils.getRemoteTypeForPrincipal(
@ -2726,12 +2725,12 @@ var SessionStoreInternal = {
isSubframe isSubframe
); );
E10SUtils.log().debug( debug(
`${currentRemoteType}, ${remoteType}, ${isCOOPSwitch}` `[process-switch]: ${currentRemoteType}, ${remoteType}, ${isCOOPSwitch}`
); );
if (currentRemoteType == remoteType && !isCOOPSwitch) { if (currentRemoteType == remoteType && !isCOOPSwitch) {
E10SUtils.log().debug(`type (${remoteType}) is compatible - ignoring`); debug(`[process-switch]: type (${remoteType}) is compatible - ignoring`);
return; return;
} }
@ -2739,7 +2738,7 @@ var SessionStoreInternal = {
remoteType == E10SUtils.NOT_REMOTE || remoteType == E10SUtils.NOT_REMOTE ||
currentRemoteType == E10SUtils.NOT_REMOTE currentRemoteType == E10SUtils.NOT_REMOTE
) { ) {
E10SUtils.log().debug(`non-remote source/target - ignoring`); debug(`[process-switch]: non-remote source/target - ignoring`);
return; return;
} }
@ -4359,7 +4358,7 @@ var SessionStoreInternal = {
root = typeof aState == "string" ? JSON.parse(aState) : aState; root = typeof aState == "string" ? JSON.parse(aState) : aState;
} catch (ex) { } catch (ex) {
// invalid state object - don't restore anything // invalid state object - don't restore anything
this._log.error(ex); debug(ex);
this._sendRestoreCompletedNotifications(); this._sendRestoreCompletedNotifications();
return; return;
} }

View File

@ -80,6 +80,10 @@ XPCOMUtils.defineLazyServiceGetter(
"nsIExternalProtocolService" "nsIExternalProtocolService"
); );
function debug(msg) {
Cu.reportError(new Error("E10SUtils: " + msg));
}
function getAboutModule(aURL) { function getAboutModule(aURL) {
// Needs to match NS_GetAboutModuleName // Needs to match NS_GetAboutModuleName
let moduleName = aURL.pathQueryRef.replace(/[#?].*/, "").toLowerCase(); let moduleName = aURL.pathQueryRef.replace(/[#?].*/, "").toLowerCase();
@ -256,7 +260,6 @@ function validatedWebRemoteType(
!documentChannel && !documentChannel &&
aPreferredRemoteType == FILE_REMOTE_TYPE aPreferredRemoteType == FILE_REMOTE_TYPE
) { ) {
E10SUtils.log().debug("checking allowLinkedWebInFileUriProcess");
// If aCurrentUri is passed then we should only allow FILE_REMOTE_TYPE // If aCurrentUri is passed then we should only allow FILE_REMOTE_TYPE
// when it is same origin as target or the current URI is already a // when it is same origin as target or the current URI is already a
// file:// URI. // file:// URI.
@ -266,15 +269,12 @@ function validatedWebRemoteType(
// todo: if you intend to update CheckSameOriginURI to log the error to the // todo: if you intend to update CheckSameOriginURI to log the error to the
// console you also need to update the 'aFromPrivateWindow' argument. // console you also need to update the 'aFromPrivateWindow' argument.
sm.checkSameOriginURI(aCurrentUri, aTargetUri, false, false); sm.checkSameOriginURI(aCurrentUri, aTargetUri, false, false);
E10SUtils.log().debug("Next URL is same origin");
return FILE_REMOTE_TYPE; return FILE_REMOTE_TYPE;
} catch (e) { } catch (e) {
E10SUtils.log().debug("Leaving same origin");
return WEB_REMOTE_TYPE; return WEB_REMOTE_TYPE;
} }
} }
E10SUtils.log().debug("No aCurrentUri");
return FILE_REMOTE_TYPE; return FILE_REMOTE_TYPE;
} }
@ -299,24 +299,6 @@ var E10SUtils = {
return documentChannel; return documentChannel;
}, },
_log: null,
_uriStr: function uriStr(aUri) {
return aUri ? aUri.spec : "undefined";
},
log: function log() {
if (!this._log) {
this._log = console.createInstance({
prefix: "ProcessSwitch",
maxLogLevel: "Error", // Change to debug the process switching code
});
this._log.debug("Setup logger");
}
return this._log;
},
/** /**
* Serialize csp data. * Serialize csp data.
* *
@ -331,7 +313,7 @@ var E10SUtils = {
serializedCSP = serializationHelper.serializeToString(csp); serializedCSP = serializationHelper.serializeToString(csp);
} }
} catch (e) { } catch (e) {
this.log().error(`Failed to serialize csp '${csp}' ${e}`); debug(`Failed to serialize csp '${csp}' ${e}`);
} }
return serializedCSP; return serializedCSP;
}, },
@ -353,7 +335,7 @@ var E10SUtils = {
csp.QueryInterface(Ci.nsIContentSecurityPolicy); csp.QueryInterface(Ci.nsIContentSecurityPolicy);
return csp; return csp;
} catch (e) { } catch (e) {
this.log().error(`Failed to deserialize csp_b64 '${csp_b64}' ${e}`); debug(`Failed to deserialize csp_b64 '${csp_b64}' ${e}`);
} }
return null; return null;
}, },
@ -541,20 +523,13 @@ var E10SUtils = {
); );
} }
var log = this.log(); return validatedWebRemoteType(
log.debug("validatedWebRemoteType()");
log.debug(` aPreferredRemoteType: ${aPreferredRemoteType}`);
log.debug(` aTargetUri: ${this._uriStr(aURI)}`);
log.debug(` aCurrentUri: ${this._uriStr(aCurrentUri)}`);
var remoteType = validatedWebRemoteType(
aPreferredRemoteType, aPreferredRemoteType,
aURI, aURI,
aCurrentUri, aCurrentUri,
aResultPrincipal, aResultPrincipal,
aRemoteSubframes aRemoteSubframes
); );
log.debug(` validatedWebRemoteType() returning: ${remoteType}`);
return remoteType;
} }
}, },
@ -652,7 +627,7 @@ var E10SUtils = {
); );
} }
} catch (e) { } catch (e) {
this.log().error(`Failed to serialize principal '${principal}' ${e}`); debug(`Failed to serialize principal '${principal}' ${e}`);
} }
return serializedPrincipal; return serializedPrincipal;
@ -668,7 +643,7 @@ var E10SUtils = {
deserializePrincipal(principal_b64, fallbackPrincipalCallback = null) { deserializePrincipal(principal_b64, fallbackPrincipalCallback = null) {
if (!principal_b64) { if (!principal_b64) {
if (!fallbackPrincipalCallback) { if (!fallbackPrincipalCallback) {
this.log().warn( debug(
"No principal passed to deserializePrincipal and no fallbackPrincipalCallback" "No principal passed to deserializePrincipal and no fallbackPrincipalCallback"
); );
return null; return null;
@ -692,12 +667,10 @@ var E10SUtils = {
principal.QueryInterface(Ci.nsIPrincipal); principal.QueryInterface(Ci.nsIPrincipal);
return principal; return principal;
} catch (e) { } catch (e) {
this.log().error( debug(`Failed to deserialize principal_b64 '${principal_b64}' ${e}`);
`Failed to deserialize principal_b64 '${principal_b64}' ${e}`
);
} }
if (!fallbackPrincipalCallback) { if (!fallbackPrincipalCallback) {
this.log().warn( debug(
"No principal passed to deserializePrincipal and no fallbackPrincipalCallback" "No principal passed to deserializePrincipal and no fallbackPrincipalCallback"
); );
return null; return null;
@ -776,21 +749,19 @@ var E10SUtils = {
shouldLoadURIInThisProcess(aURI, aRemoteSubframes) { shouldLoadURIInThisProcess(aURI, aRemoteSubframes) {
let remoteType = Services.appinfo.remoteType; let remoteType = Services.appinfo.remoteType;
let wantRemoteType = this.getRemoteTypeForURIObject( return (
aURI, remoteType ==
/* remote */ true, this.getRemoteTypeForURIObject(
aRemoteSubframes, aURI,
remoteType /* remote */ true,
aRemoteSubframes,
remoteType
)
); );
this.log().info(
`shouldLoadURIInThisProcess: have ${remoteType} want ${wantRemoteType}`
);
return remoteType == wantRemoteType;
}, },
shouldLoadURI(aDocShell, aURI, aHasPostData) { shouldLoadURI(aDocShell, aURI, aHasPostData) {
let { useRemoteSubframes } = aDocShell; let { useRemoteSubframes } = aDocShell;
this.log().debug(`shouldLoadURI(${this._uriStr(aURI)})`);
// Inner frames should always load in the current process // Inner frames should always load in the current process
// XXX(nika): Handle shouldLoadURI-triggered process switches for remote // XXX(nika): Handle shouldLoadURI-triggered process switches for remote
@ -842,38 +813,32 @@ var E10SUtils = {
!aDocShell.awaitingLargeAlloc && !aDocShell.awaitingLargeAlloc &&
isOnlyToplevelBrowsingContext isOnlyToplevelBrowsingContext
) { ) {
this.log().info(
"returning false to throw away large allocation process\n"
);
return false; return false;
} }
// Allow history load if loaded in this process before. // Allow history load if loaded in this process before.
let requestedIndex = sessionHistory.legacySHistory.requestedIndex; let requestedIndex = sessionHistory.legacySHistory.requestedIndex;
if (requestedIndex >= 0) { if (requestedIndex >= 0) {
this.log().debug("Checking history case\n");
if ( if (
sessionHistory.legacySHistory.getEntryAtIndex(requestedIndex) sessionHistory.legacySHistory.getEntryAtIndex(requestedIndex)
.loadedInThisProcess .loadedInThisProcess
) { ) {
this.log().info("History entry loaded in this process");
return true; return true;
} }
// If not originally loaded in this process allow it if the URI would // If not originally loaded in this process allow it if the URI would
// normally be allowed to load in this process by default. // normally be allowed to load in this process by default.
let remoteType = Services.appinfo.remoteType; let remoteType = Services.appinfo.remoteType;
let wantRemoteType = this.getRemoteTypeForURIObject( return (
aURI, remoteType ==
true, this.getRemoteTypeForURIObject(
useRemoteSubframes, aURI,
remoteType, true,
webNav.currentURI useRemoteSubframes,
remoteType,
webNav.currentURI
)
); );
this.log().debug(
`Checking remote type, got: ${remoteType} want: ${wantRemoteType}\n`
);
return remoteType == wantRemoteType;
} }
// If the URI can be loaded in the current process then continue // If the URI can be loaded in the current process then continue
@ -934,9 +899,7 @@ var E10SUtils = {
try { try {
serialized = serializationHelper.serializeToString(referrerInfo); serialized = serializationHelper.serializeToString(referrerInfo);
} catch (e) { } catch (e) {
this.log().error( debug(`Failed to serialize referrerInfo '${referrerInfo}' ${e}`);
`Failed to serialize referrerInfo '${referrerInfo}' ${e}`
);
} }
} }
return serialized; return serialized;
@ -954,7 +917,7 @@ var E10SUtils = {
deserialized = serializationHelper.deserializeObject(referrerInfo_b64); deserialized = serializationHelper.deserializeObject(referrerInfo_b64);
deserialized.QueryInterface(Ci.nsIReferrerInfo); deserialized.QueryInterface(Ci.nsIReferrerInfo);
} catch (e) { } catch (e) {
this.log().error( debug(
`Failed to deserialize referrerInfo_b64 '${referrerInfo_b64}' ${e}` `Failed to deserialize referrerInfo_b64 '${referrerInfo_b64}' ${e}`
); );
} }