Backed out 5 changesets (bug 1646899) for mochitest failures on DocumentLoadListener.cpp . CLOSED TREE

Backed out changeset f41ac122a801 (bug 1646899)
Backed out changeset 86a5e0827050 (bug 1646899)
Backed out changeset d2fd0f955e24 (bug 1646899)
Backed out changeset 7a7194146fe1 (bug 1646899)
Backed out changeset 4731d76dae88 (bug 1646899)
This commit is contained in:
Narcis Beleuzu 2020-07-13 05:43:30 +03:00
Родитель 895e17157a
Коммит 8981494089
14 изменённых файлов: 511 добавлений и 848 удалений

Просмотреть файл

@ -8691,8 +8691,7 @@ nsresult nsDocShell::InternalLoad(nsDocShellLoadState* aLoadState) {
// Similar check will be performed by the ParentProcessDocumentChannel if in
// use.
if (XRE_IsE10sParentProcess() &&
!DocumentChannel::CanUseDocumentChannel(aLoadState->URI(),
aLoadState->LoadFlags()) &&
!DocumentChannel::CanUseDocumentChannel(aLoadState) &&
!CanLoadInParentProcess(aLoadState->URI())) {
return NS_ERROR_FAILURE;
}
@ -9253,26 +9252,9 @@ nsIPrincipal* nsDocShell::GetInheritedPrincipal(
if (nsCOMPtr<nsITimedChannel> timedChannel = do_QueryInterface(channel)) {
timedChannel->SetTimingEnabled(true);
nsString initiatorType;
switch (aLoadInfo->InternalContentPolicyType()) {
case nsIContentPolicy::TYPE_INTERNAL_EMBED:
initiatorType = u"embed"_ns;
break;
case nsIContentPolicy::TYPE_INTERNAL_OBJECT:
initiatorType = u"object"_ns;
break;
default: {
const auto& embedderElementType =
aBrowsingContext->GetEmbedderElementType();
if (embedderElementType) {
initiatorType = *embedderElementType;
}
break;
}
}
if (!initiatorType.IsEmpty()) {
timedChannel->SetInitiatorType(initiatorType);
auto& embedderElementType = aBrowsingContext->GetEmbedderElementType();
if (embedderElementType) {
timedChannel->SetInitiatorType(*embedderElementType);
}
}
@ -9589,11 +9571,10 @@ nsresult nsDocShell::DoURILoad(nsDocShellLoadState* aLoadState,
mBrowsingContext, Some(uriModified), Some(isXFOError));
nsCOMPtr<nsIChannel> channel;
if (DocumentChannel::CanUseDocumentChannel(aLoadState->URI(),
aLoadState->LoadFlags())) {
channel = DocumentChannel::CreateForDocument(aLoadState, loadInfo,
loadFlags, this, cacheKey,
uriModified, isXFOError);
if (DocumentChannel::CanUseDocumentChannel(aLoadState)) {
channel = DocumentChannel::CreateDocumentChannel(aLoadState, loadInfo,
loadFlags, this, cacheKey,
uriModified, isXFOError);
MOZ_ASSERT(channel);
// Disable keyword fixup when using DocumentChannel, since

Просмотреть файл

@ -48,7 +48,6 @@
#include "nsContentPolicyUtils.h"
#include "nsContentUtils.h"
#include "nsDocShellCID.h"
#include "nsDocShellLoadState.h"
#include "nsGkAtoms.h"
#include "nsThreadUtils.h"
#include "nsNetUtil.h"
@ -89,7 +88,6 @@
#include "mozilla/dom/HTMLObjectElement.h"
#include "mozilla/dom/UserActivation.h"
#include "mozilla/dom/nsCSPContext.h"
#include "mozilla/net/DocumentChannel.h"
#include "mozilla/net/UrlClassifierFeatureFactory.h"
#include "mozilla/LoadInfo.h"
#include "mozilla/PresShell.h"
@ -2269,28 +2267,38 @@ nsresult nsObjectLoadingContent::OpenChannel() {
RefPtr<ObjectInterfaceRequestorShim> shim =
new ObjectInterfaceRequestorShim(this);
bool inheritAttrs = nsContentUtils::ChannelShouldInheritPrincipal(
thisContent->NodePrincipal(), // aLoadState->PrincipalToInherit()
mURI, // aLoadState->URI()
true, // aInheritForAboutBlank
false); // aForceInherit
bool inherit = nsContentUtils::ChannelShouldInheritPrincipal(
thisContent->NodePrincipal(), mURI,
true, // aInheritForAboutBlank
false); // aForceInherit
nsSecurityFlags securityFlags =
nsILoadInfo::SEC_ALLOW_CROSS_ORIGIN_DATA_IS_NULL;
bool isURIUniqueOrigin =
StaticPrefs::security_data_uri_unique_opaque_origin() &&
SchemeIsData(mURI);
bool inheritPrincipal = inheritAttrs && !isURIUniqueOrigin;
mURI->SchemeIs("data");
nsSecurityFlags securityFlags =
nsILoadInfo::SEC_ALLOW_CROSS_ORIGIN_DATA_IS_NULL;
if (inheritPrincipal) {
if (inherit && !isURIUniqueOrigin) {
securityFlags |= nsILoadInfo::SEC_FORCE_INHERIT_PRINCIPAL;
}
nsContentPolicyType contentPolicyType = GetContentPolicyType();
nsLoadFlags loadFlags = nsIChannel::LOAD_CALL_CONTENT_SNIFFERS |
nsIChannel::LOAD_BYPASS_SERVICE_WORKER |
nsIRequest::LOAD_HTML_OBJECT_DATA;
uint32_t sandboxFlags = doc->GetSandboxFlags();
rv = NS_NewChannel(getter_AddRefs(chan), mURI, thisContent, securityFlags,
contentPolicyType,
nullptr, // aPerformanceStorage
group, // aLoadGroup
shim, // aCallbacks
nsIChannel::LOAD_CALL_CONTENT_SNIFFERS |
nsIChannel::LOAD_BYPASS_SERVICE_WORKER |
nsIRequest::LOAD_HTML_OBJECT_DATA,
nullptr, // aIoService
doc->GetSandboxFlags());
NS_ENSURE_SUCCESS(rv, rv);
if (inherit) {
nsCOMPtr<nsILoadInfo> loadinfo = chan->LoadInfo();
loadinfo->SetPrincipalToInherit(thisContent->NodePrincipal());
}
// For object loads we store the CSP that potentially needs to
// be inherited, e.g. in case we are loading an opaque origin
@ -2299,80 +2307,14 @@ nsresult nsObjectLoadingContent::OpenChannel() {
// (do not share the same reference) otherwise a Meta CSP of an
// opaque origin will incorrectly be propagated to the embedding
// document.
RefPtr<nsCSPContext> cspToInherit;
if (nsCOMPtr<nsIContentSecurityPolicy> csp = doc->GetCsp()) {
cspToInherit = new nsCSPContext();
nsCOMPtr<nsIContentSecurityPolicy> csp = doc->GetCsp();
if (csp) {
RefPtr<nsCSPContext> cspToInherit = new nsCSPContext();
cspToInherit->InitFromOther(static_cast<nsCSPContext*>(csp.get()));
nsCOMPtr<nsILoadInfo> loadinfo = chan->LoadInfo();
static_cast<LoadInfo*>(loadinfo.get())->SetCSPToInherit(cspToInherit);
}
// --- Create LoadInfo
RefPtr<LoadInfo> loadInfo = new LoadInfo(
/*aLoadingPrincipal = aLoadingContext->NodePrincipal() */ nullptr,
/*aTriggeringPrincipal = aLoadingPrincipal */ nullptr,
/*aLoadingContext = */ thisContent,
/*aSecurityFlags = */ securityFlags,
/*aContentPolicyType = */ contentPolicyType,
/*aLoadingClientInfo = */ Nothing(),
/*aController = */ Nothing(),
/*aSandboxFlags = */ sandboxFlags);
if (inheritAttrs) {
loadInfo->SetPrincipalToInherit(thisContent->NodePrincipal());
}
if (cspToInherit) {
loadInfo->SetCSPToInherit(cspToInherit);
}
if (DocumentChannel::CanUseDocumentChannel(
mURI, nsIWebNavigation::LOAD_FLAGS_NONE)) {
// --- Create LoadState
RefPtr<nsDocShellLoadState> loadState = new nsDocShellLoadState(mURI);
loadState->SetPrincipalToInherit(thisContent->NodePrincipal());
loadState->SetTriggeringPrincipal(loadInfo->TriggeringPrincipal());
if (cspToInherit) {
loadState->SetCsp(cspToInherit);
}
// TODO(djg): This was httpChan->SetReferrerInfoWithoutClone(referrerInfo);
// Is the ...WithoutClone(...) important?
auto referrerInfo = MakeRefPtr<ReferrerInfo>(*doc);
loadState->SetReferrerInfo(referrerInfo);
chan =
DocumentChannel::CreateForObject(loadState, loadInfo, loadFlags, shim);
MOZ_ASSERT(chan);
// NS_NewChannel sets the group on the channel. CreateDocumentChannel does
// not.
chan->SetLoadGroup(group);
} else {
rv = NS_NewChannelInternal(getter_AddRefs(chan), // outChannel
mURI, // aUri
loadInfo, // aLoadInfo
nullptr, // aPerformanceStorage
group, // aLoadGroup
shim, // aCallbacks
loadFlags, // aLoadFlags
nullptr); // aIoService
NS_ENSURE_SUCCESS(rv, rv);
if (inheritAttrs) {
nsCOMPtr<nsILoadInfo> loadinfo = chan->LoadInfo();
loadinfo->SetPrincipalToInherit(thisContent->NodePrincipal());
}
// For object loads we store the CSP that potentially needs to
// be inherited, e.g. in case we are loading an opaque origin
// like a data: URI. The actual inheritance check happens within
// Document::InitCSP(). Please create an actual copy of the CSP
// (do not share the same reference) otherwise a Meta CSP of an
// opaque origin will incorrectly be propagated to the embedding
// document.
if (cspToInherit) {
nsCOMPtr<nsILoadInfo> loadinfo = chan->LoadInfo();
static_cast<LoadInfo*>(loadinfo.get())->SetCSPToInherit(cspToInherit);
}
};
// Referrer
nsCOMPtr<nsIHttpChannel> httpChan(do_QueryInterface(chan));
if (httpChan) {

Просмотреть файл

@ -5,14 +5,14 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=375314
-->
<head>
<title>Test for Bug 375314</title>
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=375314">Mozilla Bug 375314</a>
<p id="display"></p>
<div id="content" style="display: none">
</div>
<pre id="test">
<script class="testbody" type="text/javascript">
@ -114,14 +114,6 @@ function requestSubdocument() {
content.appendChild(frame);
}
function requestObject() {
var content = $("content");
var object = document.createElement("embed");
object.setAttribute("src", testURL);
content.appendChild(object);
}
add_task(async function() {
let chromeScript = SpecialPowers.loadChromeScript(createChromeScript);
await chromeScript.promiseOneMessage("setupComplete");
@ -133,12 +125,9 @@ add_task(async function() {
requestSubdocument();
result = await chromeScript.promiseOneMessage("loadBlocked");
is(result.policyType, SpecialPowers.Ci.nsIContentPolicy.TYPE_SUBDOCUMENT, "Content policies triggered for TYPE_SUBDOCUMENT");
requestObject();
result = await chromeScript.promiseOneMessage("loadBlocked");
is(result.policyType, SpecialPowers.Ci.nsIContentPolicy.TYPE_OBJECT, "Content policies triggered for TYPE_OBJECT");
chromeScript.sendAsyncMessage("shutdown");
chromeScript.destroy();
});

Просмотреть файл

@ -59,6 +59,7 @@ var policy = {
},
shouldProcess(contentLocation, loadInfo, mimeTypeGuess) {
return Ci.nsIContentPolicy.ACCEPT;
}
}
@ -74,7 +75,7 @@ var categoryManager = Cc["@mozilla.org/categorymanager;1"].getService(Ci.nsICate
categoryManager.addCategoryEntry("content-policy", policyName, policyName, false, true);
// Try creating different request types
var tests = ["SCRIPT", "IMAGE", "STYLESHEET", "XMLHTTPREQUEST"];
var tests = ["SCRIPT", "IMAGE", "STYLESHEET", "OBJECT", "XMLHTTPREQUEST"];
var curTest = -1;
var div;
@ -156,3 +157,4 @@ function request_xmlhttprequest() {
</pre>
</body>
</html>

Просмотреть файл

@ -69,34 +69,6 @@ static nsContentPolicyType InternalContentPolicyTypeForFrame(
: nsIContentPolicy::TYPE_INTERNAL_FRAME;
}
/* static */ already_AddRefed<LoadInfo> LoadInfo::CreateForDocument(
dom::CanonicalBrowsingContext* aBrowsingContext,
nsIPrincipal* aTriggeringPrincipal,
const OriginAttributes& aOriginAttributes, uint64_t aOuterWindowID,
nsSecurityFlags aSecurityFlags, uint32_t aSandboxFlags) {
return MakeAndAddRef<LoadInfo>(aBrowsingContext, aTriggeringPrincipal,
aOriginAttributes, aOuterWindowID,
aSecurityFlags, aSandboxFlags);
}
/* static */ already_AddRefed<LoadInfo> LoadInfo::CreateForFrame(
dom::CanonicalBrowsingContext* aBrowsingContext,
nsIPrincipal* aTriggeringPrincipal, uint64_t aFrameOuterWindowID,
nsSecurityFlags aSecurityFlags, uint32_t aSandboxFlags) {
return MakeAndAddRef<LoadInfo>(aBrowsingContext, aTriggeringPrincipal,
aFrameOuterWindowID, aSecurityFlags,
aSandboxFlags);
}
/* static */ already_AddRefed<LoadInfo> LoadInfo::CreateForNonDocument(
dom::WindowGlobalParent* aParentWGP, nsIPrincipal* aTriggeringPrincipal,
uint64_t aFrameOuterWindowID, nsContentPolicyType aContentPolicyType,
nsSecurityFlags aSecurityFlags, uint32_t aSandboxFlags) {
return MakeAndAddRef<LoadInfo>(aParentWGP, aTriggeringPrincipal,
aFrameOuterWindowID, aContentPolicyType,
aSecurityFlags, aSandboxFlags);
}
LoadInfo::LoadInfo(
nsIPrincipal* aLoadingPrincipal, nsIPrincipal* aTriggeringPrincipal,
nsINode* aLoadingContext, nsSecurityFlags aSecurityFlags,
@ -108,12 +80,54 @@ LoadInfo::LoadInfo(
: aLoadingPrincipal),
mTriggeringPrincipal(aTriggeringPrincipal ? aTriggeringPrincipal
: mLoadingPrincipal.get()),
mPrincipalToInherit(nullptr),
mClientInfo(aLoadingClientInfo),
mController(aController),
mLoadingContext(do_GetWeakReference(aLoadingContext)),
mContextForTopLevelLoad(nullptr),
mSecurityFlags(aSecurityFlags),
mSandboxFlags(aSandboxFlags),
mInternalContentPolicyType(aContentPolicyType) {
mInternalContentPolicyType(aContentPolicyType),
mTainting(LoadTainting::Basic),
mBlockAllMixedContent(false),
mUpgradeInsecureRequests(false),
mBrowserUpgradeInsecureRequests(false),
mBrowserWouldUpgradeInsecureRequests(false),
mForceAllowDataURI(false),
mAllowInsecureRedirectToDataURI(false),
mBypassCORSChecks(false),
mSkipContentPolicyCheckForWebRequest(false),
mOriginalFrameSrcLoad(false),
mForceInheritPrincipalDropped(false),
mInnerWindowID(0),
mOuterWindowID(0),
mParentOuterWindowID(0),
mTopOuterWindowID(0),
mFrameOuterWindowID(0),
mBrowsingContextID(0),
mFrameBrowsingContextID(0),
mInitialSecurityCheckDone(false),
mIsThirdPartyContext(false),
mIsThirdPartyContextToTopWindow(true),
mIsFormSubmission(false),
mSendCSPViolationEvents(true),
mRequestBlockingReason(BLOCKING_REASON_NONE),
mForcePreflight(false),
mIsPreflight(false),
mLoadTriggeredFromExternal(false),
mServiceWorkerTaintingSynthesized(false),
mDocumentHasUserInteracted(false),
mDocumentHasLoaded(false),
mAllowListFutureDocumentsCreatedFromThisRedirectChain(false),
mSkipContentSniffing(false),
mHttpsOnlyStatus(nsILoadInfo::HTTPS_ONLY_UNINITIALIZED),
mHasValidUserGestureActivation(false),
mAllowDeprecatedSystemRequests(false),
mIsInDevToolsContext(false),
mParserCreatedScript(false),
mHasStoragePermission(false),
mIsFromProcessingFrameAttributes(false),
mLoadingEmbedderPolicy(nsILoadInfo::EMBEDDER_POLICY_NULL) {
MOZ_ASSERT(mLoadingPrincipal);
MOZ_ASSERT(mTriggeringPrincipal);
@ -351,11 +365,53 @@ LoadInfo::LoadInfo(nsPIDOMWindowOuter* aOuterWindow,
nsIPrincipal* aTriggeringPrincipal,
nsISupports* aContextForTopLevelLoad,
nsSecurityFlags aSecurityFlags, uint32_t aSandboxFlags)
: mTriggeringPrincipal(aTriggeringPrincipal),
: mLoadingPrincipal(nullptr),
mTriggeringPrincipal(aTriggeringPrincipal),
mPrincipalToInherit(nullptr),
mContextForTopLevelLoad(do_GetWeakReference(aContextForTopLevelLoad)),
mSecurityFlags(aSecurityFlags),
mSandboxFlags(aSandboxFlags),
mInternalContentPolicyType(nsIContentPolicy::TYPE_DOCUMENT) {
mInternalContentPolicyType(nsIContentPolicy::TYPE_DOCUMENT),
mTainting(LoadTainting::Basic),
mBlockAllMixedContent(false),
mUpgradeInsecureRequests(false),
mBrowserUpgradeInsecureRequests(false),
mBrowserWouldUpgradeInsecureRequests(false),
mForceAllowDataURI(false),
mAllowInsecureRedirectToDataURI(false),
mBypassCORSChecks(false),
mSkipContentPolicyCheckForWebRequest(false),
mOriginalFrameSrcLoad(false),
mForceInheritPrincipalDropped(false),
mInnerWindowID(0),
mOuterWindowID(0),
mParentOuterWindowID(0),
mTopOuterWindowID(0),
mFrameOuterWindowID(0),
mBrowsingContextID(0),
mFrameBrowsingContextID(0),
mInitialSecurityCheckDone(false),
mIsThirdPartyContext(false), // NB: TYPE_DOCUMENT implies !third-party.
mIsThirdPartyContextToTopWindow(true),
mIsFormSubmission(false),
mSendCSPViolationEvents(true),
mRequestBlockingReason(BLOCKING_REASON_NONE),
mForcePreflight(false),
mIsPreflight(false),
mLoadTriggeredFromExternal(false),
mServiceWorkerTaintingSynthesized(false),
mDocumentHasUserInteracted(false),
mDocumentHasLoaded(false),
mAllowListFutureDocumentsCreatedFromThisRedirectChain(false),
mSkipContentSniffing(false),
mHttpsOnlyStatus(nsILoadInfo::HTTPS_ONLY_UNINITIALIZED),
mHasValidUserGestureActivation(false),
mAllowDeprecatedSystemRequests(false),
mIsInDevToolsContext(false),
mParserCreatedScript(false),
mHasStoragePermission(false),
mIsFromProcessingFrameAttributes(false),
mLoadingEmbedderPolicy(nsILoadInfo::EMBEDDER_POLICY_NULL) {
// Top-level loads are never third-party
// Grab the information we can out of the window.
MOZ_ASSERT(aOuterWindow);
@ -413,10 +469,53 @@ LoadInfo::LoadInfo(dom::CanonicalBrowsingContext* aBrowsingContext,
const OriginAttributes& aOriginAttributes,
uint64_t aOuterWindowID, nsSecurityFlags aSecurityFlags,
uint32_t aSandboxFlags)
: mTriggeringPrincipal(aTriggeringPrincipal),
: mLoadingPrincipal(nullptr),
mTriggeringPrincipal(aTriggeringPrincipal),
mPrincipalToInherit(nullptr),
mContextForTopLevelLoad(nullptr),
mSecurityFlags(aSecurityFlags),
mSandboxFlags(aSandboxFlags),
mInternalContentPolicyType(nsIContentPolicy::TYPE_DOCUMENT) {
mInternalContentPolicyType(nsIContentPolicy::TYPE_DOCUMENT),
mTainting(LoadTainting::Basic),
mBlockAllMixedContent(false),
mUpgradeInsecureRequests(false),
mBrowserUpgradeInsecureRequests(false),
mBrowserWouldUpgradeInsecureRequests(false),
mForceAllowDataURI(false),
mAllowInsecureRedirectToDataURI(false),
mBypassCORSChecks(false),
mSkipContentPolicyCheckForWebRequest(false),
mOriginalFrameSrcLoad(false),
mForceInheritPrincipalDropped(false),
mInnerWindowID(0),
mOuterWindowID(0),
mParentOuterWindowID(0),
mTopOuterWindowID(0),
mFrameOuterWindowID(0),
mBrowsingContextID(0),
mFrameBrowsingContextID(0),
mInitialSecurityCheckDone(false),
mIsThirdPartyContext(false), // NB: TYPE_DOCUMENT implies !third-party.
mIsThirdPartyContextToTopWindow(true),
mIsFormSubmission(false),
mSendCSPViolationEvents(true),
mRequestBlockingReason(BLOCKING_REASON_NONE),
mForcePreflight(false),
mIsPreflight(false),
mLoadTriggeredFromExternal(false),
mServiceWorkerTaintingSynthesized(false),
mDocumentHasUserInteracted(false),
mDocumentHasLoaded(false),
mAllowListFutureDocumentsCreatedFromThisRedirectChain(false),
mSkipContentSniffing(false),
mHttpsOnlyStatus(nsILoadInfo::HTTPS_ONLY_UNINITIALIZED),
mHasValidUserGestureActivation(false),
mAllowDeprecatedSystemRequests(false),
mIsInDevToolsContext(false),
mParserCreatedScript(false),
mHasStoragePermission(false),
mIsFromProcessingFrameAttributes(false),
mLoadingEmbedderPolicy(nsILoadInfo::EMBEDDER_POLICY_NULL) {
// Top-level loads are never third-party
// Grab the information we can out of the window.
MOZ_ASSERT(aBrowsingContext);
@ -456,11 +555,55 @@ LoadInfo::LoadInfo(dom::WindowGlobalParent* aParentWGP,
uint64_t aFrameOuterWindowID,
nsContentPolicyType aContentPolicyType,
nsSecurityFlags aSecurityFlags, uint32_t aSandboxFlags)
: mTriggeringPrincipal(aTriggeringPrincipal),
: mLoadingPrincipal(nullptr),
mTriggeringPrincipal(aTriggeringPrincipal),
mPrincipalToInherit(nullptr),
mClientInfo(Maybe<mozilla::dom::ClientInfo>()),
mController(Maybe<mozilla::dom::ServiceWorkerDescriptor>()),
mLoadingContext(nullptr),
mContextForTopLevelLoad(nullptr),
mSecurityFlags(aSecurityFlags),
mSandboxFlags(aSandboxFlags),
mInternalContentPolicyType(aContentPolicyType),
mFrameOuterWindowID(aFrameOuterWindowID) {
mTainting(LoadTainting::Basic),
mBlockAllMixedContent(false),
mUpgradeInsecureRequests(false),
mBrowserUpgradeInsecureRequests(false),
mBrowserWouldUpgradeInsecureRequests(false),
mForceAllowDataURI(false),
mAllowInsecureRedirectToDataURI(false),
mBypassCORSChecks(false),
mSkipContentPolicyCheckForWebRequest(false),
mOriginalFrameSrcLoad(false),
mForceInheritPrincipalDropped(false),
mInnerWindowID(0),
mOuterWindowID(0),
mParentOuterWindowID(0),
mTopOuterWindowID(0),
mFrameOuterWindowID(aFrameOuterWindowID),
mBrowsingContextID(0),
mFrameBrowsingContextID(0),
mInitialSecurityCheckDone(false),
mIsThirdPartyContext(false),
mIsThirdPartyContextToTopWindow(true),
mIsFormSubmission(false),
mSendCSPViolationEvents(true),
mRequestBlockingReason(BLOCKING_REASON_NONE),
mForcePreflight(false),
mIsPreflight(false),
mLoadTriggeredFromExternal(false),
mServiceWorkerTaintingSynthesized(false),
mDocumentHasUserInteracted(false),
mDocumentHasLoaded(false),
mAllowListFutureDocumentsCreatedFromThisRedirectChain(false),
mSkipContentSniffing(false),
mHttpsOnlyStatus(nsILoadInfo::HTTPS_ONLY_UNINITIALIZED),
mAllowDeprecatedSystemRequests(false),
mIsInDevToolsContext(false),
mParserCreatedScript(false),
mHasStoragePermission(false),
mIsFromProcessingFrameAttributes(false),
mLoadingEmbedderPolicy(nsILoadInfo::EMBEDDER_POLICY_NULL) {
CanonicalBrowsingContext* parentBC = aParentWGP->BrowsingContext();
MOZ_ASSERT(parentBC);
ComputeAncestors(parentBC, mAncestorPrincipals, mAncestorBrowsingContextIDs);
@ -572,7 +715,6 @@ LoadInfo::LoadInfo(dom::WindowGlobalParent* aParentWGP,
}
}
// Used for TYPE_FRAME or TYPE_IFRAME load.
LoadInfo::LoadInfo(dom::CanonicalBrowsingContext* aBrowsingContext,
nsIPrincipal* aTriggeringPrincipal,
uint64_t aFrameOuterWindowID, nsSecurityFlags aSecurityFlags,
@ -1825,12 +1967,13 @@ PerformanceStorage* LoadInfo::GetPerformanceStorage() {
return mPerformanceStorage;
}
auto* innerWindow = nsGlobalWindowInner::GetInnerWindowWithId(mInnerWindowID);
if (!innerWindow) {
RefPtr<dom::Document> loadingDocument;
GetLoadingDocument(getter_AddRefs(loadingDocument));
if (!loadingDocument) {
return nullptr;
}
if (!TriggeringPrincipal()->Equals(innerWindow->GetPrincipal())) {
if (!TriggeringPrincipal()->Equals(loadingDocument->NodePrincipal())) {
return nullptr;
}
@ -1842,6 +1985,11 @@ PerformanceStorage* LoadInfo::GetPerformanceStorage() {
return nullptr;
}
nsCOMPtr<nsPIDOMWindowInner> innerWindow = loadingDocument->GetInnerWindow();
if (!innerWindow) {
return nullptr;
}
mozilla::dom::Performance* performance = innerWindow->GetPerformance();
if (!performance) {
return nullptr;

Просмотреть файл

@ -53,32 +53,11 @@ typedef nsTArray<nsCOMPtr<nsIRedirectHistoryEntry>> RedirectHistoryArray;
* Class that provides an nsILoadInfo implementation.
*/
class LoadInfo final : public nsILoadInfo {
template <typename T, typename... Args>
friend already_AddRefed<T> mozilla::MakeAndAddRef(Args&&... aArgs);
public:
NS_DECL_ISUPPORTS
NS_DECL_NSILOADINFO
// Used for TYPE_DOCUMENT load.
static already_AddRefed<LoadInfo> CreateForDocument(
dom::CanonicalBrowsingContext* aBrowsingContext,
nsIPrincipal* aTriggeringPrincipal,
const OriginAttributes& aOriginAttributes, uint64_t aOuterWindowID,
nsSecurityFlags aSecurityFlags, uint32_t aSandboxFlags);
// Used for TYPE_FRAME or TYPE_IFRAME load.
static already_AddRefed<LoadInfo> CreateForFrame(
dom::CanonicalBrowsingContext* aBrowsingContext,
nsIPrincipal* aTriggeringPrincipal, uint64_t aFrameOuterWindowID,
nsSecurityFlags aSecurityFlags, uint32_t aSandboxFlags);
// Use for non-{TYPE_DOCUMENT|TYPE_FRAME|TYPE_IFRAME} load.
static already_AddRefed<LoadInfo> CreateForNonDocument(
dom::WindowGlobalParent* aParentWGP, nsIPrincipal* aTriggeringPrincipal,
uint64_t aFrameOuterWindowID, nsContentPolicyType aContentPolicyType,
nsSecurityFlags aSecurityFlags, uint32_t aSandboxFlags);
// Used for TYPE_SUBDOCUMENT load.
// aLoadingPrincipal MUST NOT BE NULL.
LoadInfo(nsIPrincipal* aLoadingPrincipal, nsIPrincipal* aTriggeringPrincipal,
nsINode* aLoadingContext, nsSecurityFlags aSecurityFlags,
@ -88,6 +67,10 @@ class LoadInfo final : public nsILoadInfo {
const Maybe<mozilla::dom::ServiceWorkerDescriptor>& aController =
Maybe<mozilla::dom::ServiceWorkerDescriptor>(),
uint32_t aSandboxFlags = 0);
// Used for TYPE_SUBDOCUMENT load.
LoadInfo(dom::CanonicalBrowsingContext* aBrowsingContext,
nsIPrincipal* aTriggeringPrincipal, uint64_t aFrameOuterWindowID,
nsSecurityFlags aSecurityFlags, uint32_t aSandboxFlags);
// Constructor used for TYPE_DOCUMENT loads which have a different
// loadingContext than other loads. This ContextForTopLevelLoad is
@ -95,29 +78,17 @@ class LoadInfo final : public nsILoadInfo {
LoadInfo(nsPIDOMWindowOuter* aOuterWindow, nsIPrincipal* aTriggeringPrincipal,
nsISupports* aContextForTopLevelLoad, nsSecurityFlags aSecurityFlags,
uint32_t aSandboxFlags);
private:
// Use factory function CreateForDocument
// Used for TYPE_DOCUMENT load.
LoadInfo(dom::CanonicalBrowsingContext* aBrowsingContext,
nsIPrincipal* aTriggeringPrincipal,
const OriginAttributes& aOriginAttributes, uint64_t aOuterWindowID,
nsSecurityFlags aSecurityFlags, uint32_t aSandboxFlags);
// Use factory function CreateForFrame
// Used for TYPE_FRAME or TYPE_IFRAME load.
LoadInfo(dom::CanonicalBrowsingContext* aBrowsingContext,
nsIPrincipal* aTriggeringPrincipal, uint64_t aFrameOuterWindowID,
nsSecurityFlags aSecurityFlags, uint32_t aSandboxFlags);
// Used for loads initiated by DocumentLoadListener that are not TYPE_DOCUMENT
// | TYPE_FRAME | TYPE_FRAME.
// Used for loads initiated by DocumentLoadListener.
LoadInfo(dom::WindowGlobalParent* aParentWGP,
nsIPrincipal* aTriggeringPrincipal, uint64_t aFrameOuterWindowID,
nsContentPolicyType aContentPolicyType,
nsSecurityFlags aSecurityFlags, uint32_t aSandboxFlags);
public:
// Compute a list of ancestor principals and BrowsingContext IDs.
// See methods AncestorPrincipals and AncestorBrowsingContextIDs
// in nsILoadInfo.idl for details.
@ -139,12 +110,6 @@ class LoadInfo final : public nsILoadInfo {
// when a separate request is made with the same security properties.
already_AddRefed<nsILoadInfo> CloneForNewRequest() const;
// The `nsContentPolicyType GetExternalContentPolicyType()` version in the
// base class is hidden by the implementation of
// `GetExternalContentPolicyType(nsContentPolicyType* aResult)` in
// LoadInfo.cpp. Explicit mark it visible.
using nsILoadInfo::GetExternalContentPolicyType;
void SetIsPreflight();
void SetUpgradeInsecureRequests(bool aValue);
void SetBrowserUpgradeInsecureRequests();
@ -281,65 +246,62 @@ class LoadInfo final : public nsILoadInfo {
nsSecurityFlags mSecurityFlags;
uint32_t mSandboxFlags;
nsContentPolicyType mInternalContentPolicyType;
LoadTainting mTainting = LoadTainting::Basic;
bool mBlockAllMixedContent = false;
bool mUpgradeInsecureRequests = false;
bool mBrowserUpgradeInsecureRequests = false;
bool mBrowserWouldUpgradeInsecureRequests = false;
bool mForceAllowDataURI = false;
bool mAllowInsecureRedirectToDataURI = false;
bool mBypassCORSChecks = false;
bool mSkipContentPolicyCheckForWebRequest = false;
bool mOriginalFrameSrcLoad = false;
bool mForceInheritPrincipalDropped = false;
uint64_t mInnerWindowID = 0;
uint64_t mOuterWindowID = 0;
uint64_t mParentOuterWindowID = 0;
uint64_t mTopOuterWindowID = 0;
uint64_t mFrameOuterWindowID = 0;
uint64_t mBrowsingContextID = 0;
uint64_t mFrameBrowsingContextID = 0;
bool mInitialSecurityCheckDone = false;
// NB: TYPE_DOCUMENT implies !third-party.
bool mIsThirdPartyContext = false;
bool mIsThirdPartyContextToTopWindow = true;
bool mIsFormSubmission = false;
bool mSendCSPViolationEvents = true;
LoadTainting mTainting;
bool mBlockAllMixedContent;
bool mUpgradeInsecureRequests;
bool mBrowserUpgradeInsecureRequests;
bool mBrowserWouldUpgradeInsecureRequests;
bool mForceAllowDataURI;
bool mAllowInsecureRedirectToDataURI;
bool mBypassCORSChecks;
bool mSkipContentPolicyCheckForWebRequest;
bool mOriginalFrameSrcLoad;
bool mForceInheritPrincipalDropped;
uint64_t mInnerWindowID;
uint64_t mOuterWindowID;
uint64_t mParentOuterWindowID;
uint64_t mTopOuterWindowID;
uint64_t mFrameOuterWindowID;
uint64_t mBrowsingContextID;
uint64_t mFrameBrowsingContextID;
bool mInitialSecurityCheckDone;
bool mIsThirdPartyContext;
bool mIsThirdPartyContextToTopWindow;
bool mIsFormSubmission;
bool mSendCSPViolationEvents;
OriginAttributes mOriginAttributes;
RedirectHistoryArray mRedirectChainIncludingInternalRedirects;
RedirectHistoryArray mRedirectChain;
nsTArray<nsCOMPtr<nsIPrincipal>> mAncestorPrincipals;
nsTArray<uint64_t> mAncestorBrowsingContextIDs;
nsTArray<nsCString> mCorsUnsafeHeaders;
uint32_t mRequestBlockingReason = BLOCKING_REASON_NONE;
bool mForcePreflight = false;
bool mIsPreflight = false;
bool mLoadTriggeredFromExternal = false;
bool mServiceWorkerTaintingSynthesized = false;
bool mDocumentHasUserInteracted = false;
bool mDocumentHasLoaded = false;
bool mAllowListFutureDocumentsCreatedFromThisRedirectChain = false;
uint32_t mRequestBlockingReason;
bool mForcePreflight;
bool mIsPreflight;
bool mLoadTriggeredFromExternal;
bool mServiceWorkerTaintingSynthesized;
bool mDocumentHasUserInteracted;
bool mDocumentHasLoaded;
bool mAllowListFutureDocumentsCreatedFromThisRedirectChain;
nsString mCspNonce;
bool mSkipContentSniffing = false;
uint32_t mHttpsOnlyStatus = nsILoadInfo::HTTPS_ONLY_UNINITIALIZED;
bool mHasValidUserGestureActivation = false;
bool mAllowDeprecatedSystemRequests = false;
bool mIsInDevToolsContext = false;
bool mParserCreatedScript = false;
bool mHasStoragePermission = false;
bool mSkipContentSniffing;
uint32_t mHttpsOnlyStatus;
bool mHasValidUserGestureActivation;
bool mAllowDeprecatedSystemRequests;
bool mIsInDevToolsContext;
bool mParserCreatedScript;
bool mHasStoragePermission;
// Is true if this load was triggered by processing the attributes of the
// browsing context container.
// See nsILoadInfo.isFromProcessingFrameAttributes
bool mIsFromProcessingFrameAttributes = false;
bool mIsFromProcessingFrameAttributes;
// The cross origin embedder policy that the loading need to respect.
// If the value is nsILoadInfo::EMBEDDER_POLICY_REQUIRE_CORP, CORP checking
// must be performed for the loading.
// See https://wicg.github.io/cross-origin-embedder-policy/#corp-check.
nsILoadInfo::CrossOriginEmbedderPolicy mLoadingEmbedderPolicy =
nsILoadInfo::EMBEDDER_POLICY_NULL;
nsILoadInfo::CrossOriginEmbedderPolicy mLoadingEmbedderPolicy;
};
} // namespace net

Просмотреть файл

@ -97,22 +97,16 @@ void DocumentChannel::ShutdownListeners(nsresult aStatusCode) {
mIsPending = false;
listener = mListener; // it might have changed!
nsCOMPtr<nsILoadGroup> loadGroup = mLoadGroup;
if (listener) {
listener->OnStopRequest(this, aStatusCode);
}
mListener = nullptr;
mLoadGroup = nullptr;
mCallbacks = nullptr;
NS_DispatchToMainThread(NS_NewRunnableFunction(
"DocumentChannel::ShutdownListeners", [=, self = RefPtr{this}] {
if (listener) {
listener->OnStopRequest(self, aStatusCode);
}
if (loadGroup) {
loadGroup->RemoveRequest(self, nullptr, aStatusCode);
}
}));
if (mLoadGroup) {
mLoadGroup->RemoveRequest(this, nullptr, aStatusCode);
mLoadGroup = nullptr;
}
DeleteIPDL();
}
@ -160,7 +154,9 @@ static bool URIUsesDocChannel(nsIURI* aURI) {
!spec.EqualsLiteral("about:crashcontent");
}
bool DocumentChannel::CanUseDocumentChannel(nsIURI* aURI, uint32_t aLoadFlags) {
bool DocumentChannel::CanUseDocumentChannel(nsDocShellLoadState* aLoadState) {
MOZ_ASSERT(aLoadState);
if (XRE_IsParentProcess() &&
!StaticPrefs::browser_tabs_documentchannel_ppdc()) {
return false;
@ -172,12 +168,12 @@ bool DocumentChannel::CanUseDocumentChannel(nsIURI* aURI, uint32_t aLoadFlags) {
// outer document (and must load in the same process), which breaks if we
// serialize to the parent process.
return StaticPrefs::browser_tabs_documentchannel() &&
!(aLoadFlags & nsDocShell::INTERNAL_LOAD_FLAGS_IS_SRCDOC) &&
URIUsesDocChannel(aURI);
!aLoadState->HasLoadFlags(nsDocShell::INTERNAL_LOAD_FLAGS_IS_SRCDOC) &&
URIUsesDocChannel(aLoadState->URI());
}
/* static */
already_AddRefed<DocumentChannel> DocumentChannel::CreateForDocument(
already_AddRefed<DocumentChannel> DocumentChannel::CreateDocumentChannel(
nsDocShellLoadState* aLoadState, class LoadInfo* aLoadInfo,
nsLoadFlags aLoadFlags, nsIInterfaceRequestor* aNotificationCallbacks,
uint32_t aCacheKey, bool aUriModified, bool aIsXFOError) {
@ -194,14 +190,6 @@ already_AddRefed<DocumentChannel> DocumentChannel::CreateForDocument(
return channel.forget();
}
/* static */
already_AddRefed<DocumentChannel> DocumentChannel::CreateForObject(
nsDocShellLoadState* aLoadState, class LoadInfo* aLoadInfo,
nsLoadFlags aLoadFlags, nsIInterfaceRequestor* aNotificationCallbacks) {
return CreateForDocument(aLoadState, aLoadInfo, aLoadFlags,
aNotificationCallbacks, 0, false, false);
}
//-----------------------------------------------------------------------------
// DocumentChannel::nsITraceableChannel
//-----------------------------------------------------------------------------
@ -304,17 +292,9 @@ DocumentChannel::SetTRRMode(nsIRequest::TRRMode aTRRMode) {
}
NS_IMETHODIMP DocumentChannel::SetLoadFlags(nsLoadFlags aLoadFlags) {
auto contentPolicy = mLoadInfo->GetExternalContentPolicyType();
// Setting load flags for TYPE_OBJECT is permissible before channel to parent
// is opened.
if (contentPolicy != nsIContentPolicy::TYPE_OBJECT || mWasOpened) {
MOZ_CRASH("DocumentChannel::SetLoadFlags: Don't set flags after creation");
NS_ERROR(
"DocumentChannel::SetLoadFlags: "
"Don't set flags after creation");
} else {
mLoadFlags = aLoadFlags;
}
NS_ERROR(
"DocumentChannel::SetLoadFlags: "
"Don't set flags after creation");
return NS_OK;
}
@ -454,23 +434,6 @@ DocumentChannel::SetChannelId(uint64_t aChannelId) {
return NS_OK;
}
//-----------------------------------------------------------------------------
// Helpers
//-----------------------------------------------------------------------------
uint64_t InnerWindowIDForExtantDoc(nsDocShell* docShell) {
if (!docShell) {
return 0;
}
Document* doc = docShell->GetExtantDocument();
if (!doc) {
return 0;
}
return doc->InnerWindowID();
}
} // namespace net
} // namespace mozilla

Просмотреть файл

@ -15,8 +15,6 @@
#include "nsIChildChannel.h"
#include "nsITraceableChannel.h"
class nsDocShell;
#define DOCUMENT_CHANNEL_IID \
{ \
0x6977bc44, 0xb1db, 0x41b7, { \
@ -27,8 +25,6 @@ class nsDocShell;
namespace mozilla {
namespace net {
uint64_t InnerWindowIDForExtantDoc(nsDocShell* docShell);
/**
* DocumentChannel is a protocol agnostic placeholder nsIChannel implementation
* that we use so that nsDocShell knows about a connecting load. It transfers
@ -63,15 +59,12 @@ class DocumentChannel : public nsIIdentChannel, public nsITraceableChannel {
* a ParentProcessDocumentChannel if called from the parent process.
* This operation is infallible.
*/
static already_AddRefed<DocumentChannel> CreateForDocument(
static already_AddRefed<DocumentChannel> CreateDocumentChannel(
nsDocShellLoadState* aLoadState, class LoadInfo* aLoadInfo,
nsLoadFlags aLoadFlags, nsIInterfaceRequestor* aNotificationCallbacks,
uint32_t aCacheKey, bool aUriModified, bool aIsXFOError);
static already_AddRefed<DocumentChannel> CreateForObject(
nsDocShellLoadState* aLoadState, class LoadInfo* aLoadInfo,
nsLoadFlags aLoadFlags, nsIInterfaceRequestor* aNotificationCallbacks);
static bool CanUseDocumentChannel(nsIURI* aURI, uint32_t aLoadFlags);
static bool CanUseDocumentChannel(nsDocShellLoadState* aLoadState);
protected:
DocumentChannel(nsDocShellLoadState* aLoadState, class LoadInfo* aLoadInfo,

Просмотреть файл

@ -73,16 +73,8 @@ DocumentChannelChild::AsyncOpen(nsIStreamListener* aListener) {
gHttpHandler->OnOpeningDocumentRequest(this);
RefPtr<nsDocShell> docShell = GetDocShell();
if (!docShell) {
return NS_ERROR_FAILURE;
}
// `loadingContext` is the BC that is initiating the resource load.
// For normal subdocument loads, the BC is the one that the subdoc will load
// into. For <object>/<embed> it's the embedder doc's BC.
RefPtr<BrowsingContext> loadingContext = docShell->GetBrowsingContext();
if (!loadingContext || loadingContext->IsDiscarded()) {
if (!GetDocShell() || !GetDocShell()->GetBrowsingContext() ||
GetDocShell()->GetBrowsingContext()->IsDiscarded()) {
return NS_ERROR_FAILURE;
}
@ -92,6 +84,9 @@ DocumentChannelChild::AsyncOpen(nsIStreamListener* aListener) {
args.cacheKey() = mCacheKey;
args.channelId() = mChannelId;
args.asyncOpenTime() = mAsyncOpenTime;
args.outerWindowId() = GetDocShell()->GetOuterWindowID();
args.uriModified() = mUriModified;
args.isXFOError() = mIsXFOError;
Maybe<IPCClientInfo> ipcClientInfo;
if (mInitialClientInfo.isSome()) {
@ -104,44 +99,15 @@ DocumentChannelChild::AsyncOpen(nsIStreamListener* aListener) {
}
args.hasValidTransientUserAction() =
loadingContext->HasValidTransientUserGestureActivation();
GetDocShell()
->GetBrowsingContext()
->HasValidTransientUserGestureActivation();
switch (mLoadInfo->GetExternalContentPolicyType()) {
case nsIContentPolicy::TYPE_DOCUMENT:
case nsIContentPolicy::TYPE_SUBDOCUMENT: {
DocumentCreationArgs docArgs;
docArgs.outerWindowId() = docShell->GetOuterWindowID();
docArgs.uriModified() = mUriModified;
docArgs.isXFOError() = mIsXFOError;
GetDocShell()->GetBrowsingContext()->SetCurrentLoadIdentifier(
Some(mLoadState->GetLoadIdentifier()));
args.elementCreationArgs() = docArgs;
break;
}
case nsIContentPolicy::TYPE_OBJECT: {
ObjectCreationArgs objectArgs;
objectArgs.embedderInnerWindowId() = InnerWindowIDForExtantDoc(docShell);
objectArgs.loadFlags() = mLoadFlags;
objectArgs.contentPolicyType() = mLoadInfo->InternalContentPolicyType();
objectArgs.isUrgentStart() = UserActivation::IsHandlingUserInput();
args.elementCreationArgs() = objectArgs;
break;
}
}
switch (mLoadInfo->GetExternalContentPolicyType()) {
case nsIContentPolicy::TYPE_DOCUMENT:
case nsIContentPolicy::TYPE_SUBDOCUMENT:
loadingContext->SetCurrentLoadIdentifier(
Some(mLoadState->GetLoadIdentifier()));
break;
default:
break;
}
gNeckoChild->SendPDocumentChannelConstructor(this, loadingContext, args);
gNeckoChild->SendPDocumentChannelConstructor(
this, GetDocShell()->GetBrowsingContext(), args);
mIsPending = true;
mWasOpened = true;

Просмотреть файл

@ -11,7 +11,6 @@
#include "mozilla/dom/CanonicalBrowsingContext.h"
#include "mozilla/dom/ClientInfo.h"
#include "mozilla/dom/ContentParent.h"
#include "nsDocShellLoadState.h"
extern mozilla::LazyLogModule gDocumentChannelLog;
#define LOG(fmt) MOZ_LOG(gDocumentChannelLog, mozilla::LogLevel::Verbose, fmt)
@ -52,30 +51,12 @@ bool DocumentChannelParent::Init(dom::CanonicalBrowsingContext* aContext,
}
nsresult rv = NS_ERROR_UNEXPECTED;
if (aArgs.elementCreationArgs().type() ==
DocumentChannelElementCreationArgs::TDocumentCreationArgs) {
const DocumentCreationArgs& docArgs = aArgs.elementCreationArgs();
promise = mDocumentLoadListener->OpenDocument(
loadState, aArgs.cacheKey(), Some(aArgs.channelId()),
aArgs.asyncOpenTime(), aArgs.timing().refOr(nullptr),
std::move(clientInfo), docArgs.outerWindowId(),
aArgs.hasValidTransientUserAction(), Some(docArgs.uriModified()),
Some(docArgs.isXFOError()), IProtocol::OtherPid(), &rv);
} else {
const ObjectCreationArgs& objectArgs = aArgs.elementCreationArgs();
promise = mDocumentLoadListener->OpenObject(
loadState, aArgs.cacheKey(), Some(aArgs.channelId()),
aArgs.asyncOpenTime(), aArgs.timing().refOr(nullptr),
std::move(clientInfo), objectArgs.embedderInnerWindowId(),
objectArgs.loadFlags(), objectArgs.contentPolicyType(),
aArgs.hasValidTransientUserAction(), objectArgs.isUrgentStart(),
IProtocol::OtherPid(), &rv);
}
promise = mDocumentLoadListener->Open(
loadState, aArgs.cacheKey(), Some(aArgs.channelId()),
aArgs.asyncOpenTime(), aArgs.timing().refOr(nullptr),
std::move(clientInfo), aArgs.outerWindowId(),
aArgs.hasValidTransientUserAction(), Some(aArgs.uriModified()),
Some(aArgs.isXFOError()), IProtocol::OtherPid(), &rv);
if (NS_FAILED(rv)) {
MOZ_ASSERT(!promise);
return SendFailedAsyncOpen(rv);

Просмотреть файл

@ -42,13 +42,10 @@
#include "nsIViewSourceChannel.h"
#include "nsImportModule.h"
#include "nsMimeTypes.h"
#include "nsQueryObject.h"
#include "nsRedirectHistoryEntry.h"
#include "nsSandboxFlags.h"
#include "nsStringStream.h"
#include "nsURILoader.h"
#include "nsWebNavigationInfo.h"
#include "mozilla/dom/BrowserParent.h"
#include "mozilla/dom/Element.h"
#include "mozilla/dom/nsHTTPSOnlyUtils.h"
#include "mozilla/dom/RemoteWebProgress.h"
@ -79,94 +76,6 @@ static void SetNeedToAddURIVisit(nsIChannel* aChannel,
aNeedToAddURIVisit);
}
static auto SecurityFlagsForLoadInfo(nsDocShellLoadState* aLoadState)
-> nsSecurityFlags {
// TODO: Block copied from nsDocShell::DoURILoad, refactor out somewhere
nsSecurityFlags securityFlags =
nsILoadInfo::SEC_ALLOW_CROSS_ORIGIN_DATA_IS_NULL;
if (aLoadState->LoadType() == LOAD_ERROR_PAGE) {
securityFlags |= nsILoadInfo::SEC_LOAD_ERROR_PAGE;
}
if (aLoadState->PrincipalToInherit()) {
bool isSrcdoc =
aLoadState->HasLoadFlags(nsDocShell::INTERNAL_LOAD_FLAGS_IS_SRCDOC);
bool inheritAttrs = nsContentUtils::ChannelShouldInheritPrincipal(
aLoadState->PrincipalToInherit(), aLoadState->URI(),
true, // aInheritForAboutBlank
isSrcdoc);
bool isURIUniqueOrigin =
StaticPrefs::security_data_uri_unique_opaque_origin() &&
SchemeIsData(aLoadState->URI());
if (inheritAttrs && !isURIUniqueOrigin) {
securityFlags |= nsILoadInfo::SEC_FORCE_INHERIT_PRINCIPAL;
}
}
return securityFlags;
}
// Construct a LoadInfo object to use when creating the internal channel for a
// Document/SubDocument load.
static auto CreateDocumentLoadInfo(CanonicalBrowsingContext* aBrowsingContext,
nsDocShellLoadState* aLoadState,
uint64_t aOuterWindowId)
-> already_AddRefed<LoadInfo> {
uint32_t sandboxFlags = aBrowsingContext->GetSandboxFlags();
RefPtr<LoadInfo> loadInfo;
auto securityFlags = SecurityFlagsForLoadInfo(aLoadState);
if (aBrowsingContext->GetParent()) {
loadInfo = LoadInfo::CreateForFrame(
aBrowsingContext, aLoadState->TriggeringPrincipal(), aOuterWindowId,
securityFlags, sandboxFlags);
} else {
OriginAttributes attrs;
aBrowsingContext->GetOriginAttributes(attrs);
loadInfo = LoadInfo::CreateForDocument(
aBrowsingContext, aLoadState->TriggeringPrincipal(), attrs,
aOuterWindowId, securityFlags, sandboxFlags);
}
loadInfo->SetHasValidUserGestureActivation(
aLoadState->HasValidUserGestureActivation());
return loadInfo.forget();
}
// Construct a LoadInfo object to use when creating the internal channel for an
// Object/Embed load.
static auto CreateObjectLoadInfo(nsDocShellLoadState* aLoadState,
uint64_t aInnerWindowId,
nsContentPolicyType aContentPolicyType,
uint32_t aSandboxFlags)
-> already_AddRefed<LoadInfo> {
RefPtr<WindowGlobalParent> wgp =
WindowGlobalParent::GetByInnerWindowId(aInnerWindowId);
MOZ_RELEASE_ASSERT(wgp);
auto securityFlags = SecurityFlagsForLoadInfo(aLoadState);
RefPtr<LoadInfo> loadInfo = LoadInfo::CreateForNonDocument(
wgp, wgp->DocumentPrincipal(), 0, aContentPolicyType, securityFlags,
aSandboxFlags);
loadInfo->SetHasValidUserGestureActivation(
aLoadState->HasValidUserGestureActivation());
return loadInfo.forget();
}
static auto WebProgressForBrowsingContext(
CanonicalBrowsingContext* aBrowsingContext)
-> already_AddRefed<BrowsingContextWebProgress> {
return RefPtr<BrowsingContextWebProgress>(aBrowsingContext->GetWebProgress())
.forget();
}
/**
* An extension to nsDocumentOpenInfo that we run in the parent process, so
* that we can make the decision to retarget to content handlers or the external
@ -185,12 +94,10 @@ class ParentProcessDocumentOpenInfo final : public nsDocumentOpenInfo,
public:
ParentProcessDocumentOpenInfo(ParentChannelListener* aListener,
uint32_t aFlags,
mozilla::dom::BrowsingContext* aBrowsingContext,
nsContentPolicyType aExternalContentPolicyType)
mozilla::dom::BrowsingContext* aBrowsingContext)
: nsDocumentOpenInfo(aFlags, false),
mBrowsingContext(aBrowsingContext),
mListener(aListener),
mExternalContentPolicyType(aExternalContentPolicyType) {
mListener(aListener) {
LOG(("ParentProcessDocumentOpenInfo ctor [this=%p]", this));
}
@ -262,13 +169,12 @@ class ParentProcessDocumentOpenInfo final : public nsDocumentOpenInfo,
nsDocumentOpenInfo* Clone() override {
mCloned = true;
return new ParentProcessDocumentOpenInfo(
mListener, mFlags, mBrowsingContext, mExternalContentPolicyType);
return new ParentProcessDocumentOpenInfo(mListener, mFlags,
mBrowsingContext);
}
nsresult OnDocumentStartRequest(nsIRequest* request) {
LOG(("ParentProcessDocumentOpenInfo OnDocumentStartRequest [this=%p]",
this));
NS_IMETHOD OnStartRequest(nsIRequest* request) override {
LOG(("ParentProcessDocumentOpenInfo OnStartRequest [this=%p]", this));
nsresult rv = nsDocumentOpenInfo::OnStartRequest(request);
@ -307,32 +213,6 @@ class ParentProcessDocumentOpenInfo final : public nsDocumentOpenInfo,
return rv;
}
nsresult OnObjectStartRequest(nsIRequest* request) {
LOG(("ParentProcessDocumentOpenInfo OnObjectStartRequest [this=%p]", this));
// Just redirect to the nsObjectLoadingContent in the content process.
m_targetStreamListener = mListener;
return m_targetStreamListener->OnStartRequest(request);
}
NS_IMETHOD OnStartRequest(nsIRequest* request) override {
LOG(("ParentProcessDocumentOpenInfo OnStartRequest [this=%p]", this));
switch (mExternalContentPolicyType) {
case nsIContentPolicy::TYPE_DOCUMENT:
case nsIContentPolicy::TYPE_SUBDOCUMENT:
return OnDocumentStartRequest(request);
break;
case nsIContentPolicy::TYPE_OBJECT:
return OnObjectStartRequest(request);
break;
default:
MOZ_CRASH("Unexpect external content policy type.");
return NS_BINDING_FAILED;
}
}
NS_IMETHOD OnAfterLastPart(nsresult aStatus) override {
mListener->OnAfterLastPart(aStatus);
return NS_OK;
@ -356,7 +236,6 @@ class ParentProcessDocumentOpenInfo final : public nsDocumentOpenInfo,
RefPtr<mozilla::dom::BrowsingContext> mBrowsingContext;
RefPtr<ParentChannelListener> mListener;
nsContentPolicyType mExternalContentPolicyType;
/**
* Set to true if we got cloned to create a chained listener.
@ -388,11 +267,10 @@ NS_INTERFACE_MAP_BEGIN(DocumentLoadListener)
NS_INTERFACE_MAP_END
DocumentLoadListener::DocumentLoadListener(
CanonicalBrowsingContext* aLoadingBrowsingContext) {
CanonicalBrowsingContext* aBrowsingContext) {
LOG(("DocumentLoadListener ctor [this=%p]", this));
mParentChannelListener =
new ParentChannelListener(this, aLoadingBrowsingContext,
aLoadingBrowsingContext->UsePrivateBrowsing());
mParentChannelListener = new ParentChannelListener(
this, aBrowsingContext, aBrowsingContext->UsePrivateBrowsing());
}
DocumentLoadListener::~DocumentLoadListener() {
@ -426,7 +304,7 @@ void DocumentLoadListener::AddURIVisit(nsIChannel* aChannel,
}
RefPtr<CanonicalBrowsingContext> browsingContext =
GetDocumentBrowsingContext();
mParentChannelListener->GetBrowsingContext();
nsCOMPtr<nsIWidget> widget =
browsingContext->GetParentProcessWidgetContaining();
@ -435,49 +313,95 @@ void DocumentLoadListener::AddURIVisit(nsIChannel* aChannel,
mLoadStateLoadType);
}
CanonicalBrowsingContext* DocumentLoadListener::GetLoadingBrowsingContext()
const {
return mParentChannelListener ? mParentChannelListener->GetBrowsingContext()
: nullptr;
}
already_AddRefed<LoadInfo> DocumentLoadListener::CreateLoadInfo(
CanonicalBrowsingContext* aBrowsingContext, nsDocShellLoadState* aLoadState,
uint64_t aOuterWindowId) {
// TODO: Block copied from nsDocShell::DoURILoad, refactor out somewhere
bool inheritPrincipal = false;
CanonicalBrowsingContext* DocumentLoadListener::GetDocumentBrowsingContext()
const {
if (mExternalContentPolicyType == nsIContentPolicy::TYPE_OBJECT) {
return nullptr;
if (aLoadState->PrincipalToInherit()) {
bool isSrcdoc =
aLoadState->HasLoadFlags(nsDocShell::INTERNAL_LOAD_FLAGS_IS_SRCDOC);
bool inheritAttrs = nsContentUtils::ChannelShouldInheritPrincipal(
aLoadState->PrincipalToInherit(), aLoadState->URI(),
true, // aInheritForAboutBlank
isSrcdoc);
bool isURIUniqueOrigin =
StaticPrefs::security_data_uri_unique_opaque_origin() &&
SchemeIsData(aLoadState->URI());
inheritPrincipal = inheritAttrs && !isURIUniqueOrigin;
}
return GetLoadingBrowsingContext();
nsSecurityFlags securityFlags =
nsILoadInfo::SEC_ALLOW_CROSS_ORIGIN_DATA_IS_NULL;
uint32_t sandboxFlags = aBrowsingContext->GetSandboxFlags();
if (aLoadState->LoadType() == LOAD_ERROR_PAGE) {
securityFlags |= nsILoadInfo::SEC_LOAD_ERROR_PAGE;
}
if (inheritPrincipal) {
securityFlags |= nsILoadInfo::SEC_FORCE_INHERIT_PRINCIPAL;
}
RefPtr<LoadInfo> loadInfo;
if (aBrowsingContext->GetParent()) {
// Build LoadInfo for TYPE_SUBDOCUMENT
loadInfo = new LoadInfo(aBrowsingContext, aLoadState->TriggeringPrincipal(),
aOuterWindowId, securityFlags, sandboxFlags);
} else {
// Build LoadInfo for TYPE_DOCUMENT
OriginAttributes attrs;
aBrowsingContext->GetOriginAttributes(attrs);
loadInfo = new LoadInfo(aBrowsingContext, aLoadState->TriggeringPrincipal(),
attrs, aOuterWindowId, securityFlags, sandboxFlags);
}
loadInfo->SetHasValidUserGestureActivation(
aLoadState->HasValidUserGestureActivation());
return loadInfo.forget();
}
CanonicalBrowsingContext* DocumentLoadListener::GetTopBrowsingContext() const {
auto* loadingContext = GetLoadingBrowsingContext();
return loadingContext ? loadingContext->Top() : nullptr;
CanonicalBrowsingContext* DocumentLoadListener::GetBrowsingContext() const {
if (!mParentChannelListener) {
return nullptr;
}
return mParentChannelListener->GetBrowsingContext();
}
auto DocumentLoadListener::Open(nsDocShellLoadState* aLoadState,
LoadInfo* aLoadInfo, nsLoadFlags aLoadFlags,
uint32_t aCacheKey,
const Maybe<uint64_t>& aChannelId,
const TimeStamp& aAsyncOpenTime,
nsDOMNavigationTiming* aTiming,
Maybe<ClientInfo>&& aInfo, bool aHasGesture,
bool aUrgentStart, base::ProcessId aPid,
nsresult* aRv) -> RefPtr<OpenPromise> {
auto* loadingContext = GetLoadingBrowsingContext();
MOZ_DIAGNOSTIC_ASSERT_IF(loadingContext->GetParent(),
loadingContext->GetParentWindowContext());
auto DocumentLoadListener::Open(
nsDocShellLoadState* aLoadState, uint32_t aCacheKey,
const Maybe<uint64_t>& aChannelId, const TimeStamp& aAsyncOpenTime,
nsDOMNavigationTiming* aTiming, Maybe<ClientInfo>&& aInfo,
uint64_t aOuterWindowId, bool aHasGesture, Maybe<bool> aUriModified,
Maybe<bool> aIsXFOError, base::ProcessId aPid, nsresult* aRv)
-> RefPtr<OpenPromise> {
LOG(("DocumentLoadListener Open [this=%p, uri=%s]", this,
aLoadState->URI()->GetSpecOrDefault().get()));
RefPtr<CanonicalBrowsingContext> browsingContext =
mParentChannelListener->GetBrowsingContext();
OriginAttributes attrs;
loadingContext->GetOriginAttributes(attrs);
browsingContext->GetOriginAttributes(attrs);
mLoadIdentifier = aLoadState->GetLoadIdentifier();
mExternalContentPolicyType = aLoadInfo->GetExternalContentPolicyType();
MOZ_DIAGNOSTIC_ASSERT_IF(browsingContext->GetParent(),
browsingContext->GetParentWindowContext());
// If this is a top-level load, then rebuild the LoadInfo from scratch,
// since the goal is to be able to initiate loads in the parent, where the
// content process won't have provided us with an existing one.
RefPtr<LoadInfo> loadInfo =
CreateLoadInfo(browsingContext, aLoadState, aOuterWindowId);
nsLoadFlags loadFlags = aLoadState->CalculateChannelLoadFlags(
browsingContext, std::move(aUriModified), std::move(aIsXFOError));
if (!nsDocShell::CreateAndConfigureRealChannelForLoadState(
loadingContext, aLoadState, aLoadInfo, mParentChannelListener,
nullptr, attrs, aLoadFlags, aCacheKey, *aRv,
browsingContext, aLoadState, loadInfo, mParentChannelListener,
nullptr, attrs, loadFlags, aCacheKey, *aRv,
getter_AddRefs(mChannel))) {
LOG(("DocumentLoadListener::Open failed to create channel [this=%p]",
this));
@ -485,20 +409,19 @@ auto DocumentLoadListener::Open(nsDocShellLoadState* aLoadState,
return nullptr;
}
nsCOMPtr<nsIURI> uriBeingLoaded;
Unused << NS_WARN_IF(
NS_FAILED(mChannel->GetURI(getter_AddRefs(uriBeingLoaded))));
nsCOMPtr<nsIURI> uriBeingLoaded =
AntiTrackingUtils::MaybeGetDocumentURIBeingLoaded(mChannel);
RefPtr<HttpBaseChannel> httpBaseChannel = do_QueryObject(mChannel, aRv);
if (uriBeingLoaded && httpBaseChannel) {
if (httpBaseChannel) {
nsCOMPtr<nsIURI> topWindowURI;
if (loadingContext->IsTop()) {
if (browsingContext->IsTop()) {
// If this is for the top level loading, the top window URI should be the
// URI which we are loading.
topWindowURI = uriBeingLoaded;
} else if (RefPtr<WindowGlobalParent> topWindow = AntiTrackingUtils::
GetTopWindowExcludingExtensionAccessibleContentFrames(
loadingContext, uriBeingLoaded)) {
browsingContext, uriBeingLoaded)) {
nsCOMPtr<nsIPrincipal> topWindowPrincipal =
topWindow->DocumentPrincipal();
if (topWindowPrincipal && !topWindowPrincipal->GetIsNullPrincipal()) {
@ -526,12 +449,7 @@ auto DocumentLoadListener::Open(nsDocShellLoadState* aLoadState,
if (nsCOMPtr<nsIHttpChannel> httpChannel = do_QueryInterface(mChannel)) {
Unused << httpChannel->SetRequestContextID(
loadingContext->GetRequestContextId());
nsCOMPtr<nsIClassOfService> cos(do_QueryInterface(httpChannel));
if (cos && aUrgentStart) {
cos->AddClassFlags(nsIClassOfService::UrgentStart);
}
browsingContext->GetRequestContextId());
}
// nsViewSourceChannel normally replaces the nsIRequest passed to
@ -547,8 +465,7 @@ auto DocumentLoadListener::Open(nsDocShellLoadState* aLoadState,
// across any serviceworker related data between channels as needed.
AddClientChannelHelperInParent(mChannel, std::move(aInfo));
auto* documentContext = GetDocumentBrowsingContext();
if (documentContext && !documentContext->StartDocumentLoad(this)) {
if (!browsingContext->StartDocumentLoad(this)) {
LOG(("DocumentLoadListener::Open failed StartDocumentLoad [this=%p]",
this));
*aRv = NS_BINDING_ABORTED;
@ -561,30 +478,29 @@ auto DocumentLoadListener::Open(nsDocShellLoadState* aLoadState,
// NOTE: The only case not handled here to mirror Content process is
// redirecting to re-use the channel.
MOZ_ASSERT(!aLoadState->GetPendingRedirectedChannel());
uint32_t openFlags =
nsDocShell::ComputeURILoaderFlags(loadingContext, aLoadState->LoadType());
uint32_t openFlags = nsDocShell::ComputeURILoaderFlags(
browsingContext, aLoadState->LoadType());
RefPtr<ParentProcessDocumentOpenInfo> openInfo =
new ParentProcessDocumentOpenInfo(mParentChannelListener, openFlags,
loadingContext,
mExternalContentPolicyType);
browsingContext);
openInfo->Prepare();
#ifdef ANDROID
RefPtr<MozPromise<bool, bool, false>> promise;
if (documentContext && aLoadState->LoadType() != LOAD_ERROR_PAGE &&
if (aLoadState->LoadType() != LOAD_ERROR_PAGE &&
!(aLoadState->HasLoadFlags(
nsDocShell::INTERNAL_LOAD_FLAGS_BYPASS_LOAD_URI_DELEGATE)) &&
!(aLoadState->LoadType() & LOAD_HISTORY)) {
nsCOMPtr<nsIWidget> widget =
documentContext->GetParentProcessWidgetContaining();
browsingContext->GetParentProcessWidgetContaining();
RefPtr<nsWindow> window = nsWindow::From(widget);
if (window) {
promise = window->OnLoadRequest(
aLoadState->URI(), nsIBrowserDOMWindow::OPEN_CURRENTWINDOW,
aLoadState->LoadFlags(), aLoadState->TriggeringPrincipal(),
aHasGesture, documentContext->IsTopContent());
aHasGesture, browsingContext->IsTopContent());
}
}
@ -615,9 +531,7 @@ auto DocumentLoadListener::Open(nsDocShellLoadState* aLoadState,
LOG(("DocumentLoadListener::Open failed AsyncOpen [this=%p rv=%" PRIx32
"]",
this, static_cast<uint32_t>(*aRv)));
if (documentContext) {
documentContext->EndDocumentLoad(false);
}
browsingContext->EndDocumentLoad(false);
mParentChannelListener = nullptr;
return nullptr;
}
@ -632,9 +546,9 @@ auto DocumentLoadListener::Open(nsDocShellLoadState* aLoadState,
mBaseURI = aLoadState->BaseURI();
mOriginalUriString = aLoadState->GetOriginalURIString();
if (StaticPrefs::fission_sessionHistoryInParent() &&
documentContext->GetSessionHistory()) {
browsingContext->GetSessionHistory()) {
mSessionHistoryInfo =
documentContext->CreateSessionHistoryEntryForLoad(aLoadState, mChannel);
browsingContext->CreateSessionHistoryEntryForLoad(aLoadState, mChannel);
}
*aRv = NS_OK;
@ -645,72 +559,14 @@ auto DocumentLoadListener::Open(nsDocShellLoadState* aLoadState,
return mOpenPromise;
}
auto DocumentLoadListener::OpenDocument(
nsDocShellLoadState* aLoadState, uint32_t aCacheKey,
const Maybe<uint64_t>& aChannelId, const TimeStamp& aAsyncOpenTime,
nsDOMNavigationTiming* aTiming, Maybe<dom::ClientInfo>&& aInfo,
uint64_t aOuterWindowId, bool aHasGesture, Maybe<bool> aUriModified,
Maybe<bool> aIsXFOError, base::ProcessId aPid, nsresult* aRv)
-> RefPtr<OpenPromise> {
LOG(("DocumentLoadListener [%p] OpenDocument [uri=%s]", this,
aLoadState->URI()->GetSpecOrDefault().get()));
RefPtr<CanonicalBrowsingContext> browsingContext =
GetDocumentBrowsingContext();
// If this is a top-level load, then rebuild the LoadInfo from scratch,
// since the goal is to be able to initiate loads in the parent, where the
// content process won't have provided us with an existing one.
RefPtr<LoadInfo> loadInfo =
CreateDocumentLoadInfo(browsingContext, aLoadState, aOuterWindowId);
MOZ_ASSERT_IF(!browsingContext->GetParent(),
loadInfo->GetExternalContentPolicyType() ==
nsIContentPolicy::TYPE_DOCUMENT);
MOZ_ASSERT_IF(browsingContext->GetParent(),
loadInfo->GetExternalContentPolicyType() ==
nsIContentPolicy::TYPE_SUBDOCUMENT);
nsLoadFlags loadFlags = aLoadState->CalculateChannelLoadFlags(
browsingContext, std::move(aUriModified), std::move(aIsXFOError));
return Open(aLoadState, loadInfo, loadFlags, aCacheKey, aChannelId,
aAsyncOpenTime, aTiming, std::move(aInfo), aHasGesture, false,
aPid, aRv);
}
auto DocumentLoadListener::OpenObject(
nsDocShellLoadState* aLoadState, uint32_t aCacheKey,
const Maybe<uint64_t>& aChannelId, const TimeStamp& aAsyncOpenTime,
nsDOMNavigationTiming* aTiming, Maybe<dom::ClientInfo>&& aInfo,
uint64_t aInnerWindowId, nsLoadFlags aLoadFlags,
nsContentPolicyType aContentPolicyType, bool aHasGesture, bool aUrgentStart,
base::ProcessId aPid, nsresult* aRv) -> RefPtr<OpenPromise> {
LOG(("DocumentLoadListener [%p] OpenObject [uri=%s]", this,
aLoadState->URI()->GetSpecOrDefault().get()));
auto sandboxFlags = GetLoadingBrowsingContext()->GetSandboxFlags();
RefPtr<LoadInfo> loadInfo = CreateObjectLoadInfo(
aLoadState, aInnerWindowId, aContentPolicyType, sandboxFlags);
MOZ_ASSERT(loadInfo->GetExternalContentPolicyType() ==
nsIContentPolicy::TYPE_OBJECT);
return Open(aLoadState, loadInfo, aLoadFlags, aCacheKey, aChannelId,
aAsyncOpenTime, aTiming, std::move(aInfo), aHasGesture,
aUrgentStart, aPid, aRv);
}
auto DocumentLoadListener::OpenInParent(nsDocShellLoadState* aLoadState,
uint64_t aOuterWindowId,
bool aSupportsRedirectToRealChannel)
-> RefPtr<OpenPromise> {
// We currently only support passing nullptr for aLoadInfo for
// top level browsing contexts.
auto* browsingContext = GetDocumentBrowsingContext();
if (!browsingContext->IsTopContent() ||
!browsingContext->GetContentParent()) {
if (!GetBrowsingContext()->IsTopContent() ||
!GetBrowsingContext()->GetContentParent()) {
LOG(("DocumentLoadListener::OpenInParent failed because of subdoc"));
return nullptr;
}
@ -749,7 +605,7 @@ auto DocumentLoadListener::OpenInParent(nsDocShellLoadState* aLoadState,
RefPtr<nsDOMNavigationTiming> timing = new nsDOMNavigationTiming(nullptr);
timing->NotifyNavigationStart(
browsingContext->GetIsActive()
GetBrowsingContext()->GetIsActive()
? nsDOMNavigationTiming::DocShellState::eActive
: nsDOMNavigationTiming::DocShellState::eInactive);
@ -767,44 +623,27 @@ auto DocumentLoadListener::OpenInParent(nsDocShellLoadState* aLoadState,
mSupportsRedirectToRealChannel = aSupportsRedirectToRealChannel;
// This is a top-level load, so rebuild the LoadInfo from scratch,
// since in the parent the
// content process won't have provided us with an existing one.
RefPtr<LoadInfo> loadInfo =
CreateDocumentLoadInfo(browsingContext, aLoadState, aOuterWindowId);
MOZ_ASSERT_IF(!browsingContext->GetParent(),
loadInfo->GetExternalContentPolicyType() ==
nsIContentPolicy::TYPE_DOCUMENT);
MOZ_ASSERT_IF(browsingContext->GetParent(),
loadInfo->GetExternalContentPolicyType() ==
nsIContentPolicy::TYPE_SUBDOCUMENT);
nsLoadFlags loadFlags = loadState->CalculateChannelLoadFlags(
browsingContext, Nothing(), Nothing());
nsresult rv;
return Open(loadState, loadInfo, loadFlags, cacheKey, channelId,
TimeStamp::Now(), timing, std::move(initialClientInfo), false,
false, browsingContext->GetContentParent()->OtherPid(), &rv);
return Open(loadState, cacheKey, channelId, TimeStamp::Now(), timing,
std::move(initialClientInfo), aOuterWindowId, false, Nothing(),
Nothing(), GetBrowsingContext()->GetContentParent()->OtherPid(),
&rv);
}
void DocumentLoadListener::FireStateChange(uint32_t aStateFlags,
nsresult aStatus) {
nsCOMPtr<nsIChannel> request = GetChannel();
static void FireStateChange(DocumentLoadListener* aLoad, uint32_t aStateFlags,
nsresult aStatus) {
nsCOMPtr<nsIChannel> request = aLoad->GetChannel();
nsCOMPtr<nsIWebProgress> webProgress =
new RemoteWebProgress(GetLoadType(), true, true);
new RemoteWebProgress(aLoad->GetLoadType(), true, true);
RefPtr<BrowsingContextWebProgress> loadingWebProgress =
WebProgressForBrowsingContext(GetLoadingBrowsingContext());
if (loadingWebProgress) {
NS_DispatchToMainThread(
NS_NewRunnableFunction("DocumentLoadListener::FireStateChange", [=]() {
loadingWebProgress->OnStateChange(webProgress, request, aStateFlags,
aStatus);
}));
}
RefPtr<CanonicalBrowsingContext> ctx = aLoad->GetBrowsingContext();
NS_DispatchToMainThread(
NS_NewRunnableFunction("DocumentLoadListener::FireStateChange", [=]() {
if (ctx && ctx->GetWebProgress()) {
ctx->GetWebProgress()->OnStateChange(webProgress, request,
aStateFlags, aStatus);
}
}));
}
static void SetNavigating(CanonicalBrowsingContext* aBrowsingContext,
@ -850,19 +689,21 @@ static void SetNavigating(CanonicalBrowsingContext* aBrowsingContext,
// finished (and failed), and we should fire a state change to notify
// observers. Normally the docshell would fire this, and it would get
// filtered out by BrowserParent if needed.
load->FireStateChange(nsIWebProgressListener::STATE_STOP |
nsIWebProgressListener::STATE_IS_WINDOW |
nsIWebProgressListener::STATE_IS_NETWORK,
rejectValue.mStatus);
FireStateChange(load,
nsIWebProgressListener::STATE_STOP |
nsIWebProgressListener::STATE_IS_WINDOW |
nsIWebProgressListener::STATE_IS_NETWORK,
rejectValue.mStatus);
}
});
load->FireStateChange(nsIWebProgressListener::STATE_START |
nsIWebProgressListener::STATE_IS_DOCUMENT |
nsIWebProgressListener::STATE_IS_REQUEST |
nsIWebProgressListener::STATE_IS_WINDOW |
nsIWebProgressListener::STATE_IS_NETWORK,
NS_OK);
FireStateChange(load,
nsIWebProgressListener::STATE_START |
nsIWebProgressListener::STATE_IS_DOCUMENT |
nsIWebProgressListener::STATE_IS_REQUEST |
nsIWebProgressListener::STATE_IS_WINDOW |
nsIWebProgressListener::STATE_IS_NETWORK,
NS_OK);
SetNavigating(aBrowsingContext, false);
return true;
}
@ -950,7 +791,7 @@ void DocumentLoadListener::Disconnect() {
httpChannelImpl->SetWarningReporter(nullptr);
}
if (auto* ctx = GetDocumentBrowsingContext()) {
if (auto* ctx = GetBrowsingContext()) {
ctx->EndDocumentLoad(mDoingProcessSwitch);
}
}
@ -1044,7 +885,7 @@ void DocumentLoadListener::FinishReplacementChannelSetup(nsresult aResult) {
this, int(aResult)));
auto endDocumentLoad = MakeScopeExit([&]() {
if (auto* ctx = GetDocumentBrowsingContext()) {
if (auto* ctx = GetBrowsingContext()) {
ctx->EndDocumentLoad(false);
}
});
@ -1225,7 +1066,7 @@ bool DocumentLoadListener::ResumeSuspendedChannel(
mChannel->Resume();
if (auto* ctx = GetDocumentBrowsingContext()) {
if (auto* ctx = GetBrowsingContext()) {
ctx->EndDocumentLoad(mDoingProcessSwitch);
}
@ -1452,12 +1293,6 @@ bool DocumentLoadListener::MaybeTriggerProcessSwitch(
LOG(("DocumentLoadListener MaybeTriggerProcessSwitch [this=%p]", this));
// Don't switch process for <object>/<embed> loads.
if (mExternalContentPolicyType == nsIContentPolicy::TYPE_OBJECT) {
LOG(("Process Switch Abort: non-document load"));
return false;
}
// Get the BrowsingContext which will be switching processes.
RefPtr<CanonicalBrowsingContext> browsingContext =
mParentChannelListener->GetBrowsingContext();
@ -1713,24 +1548,14 @@ DocumentLoadListener::RedirectToRealChannel(
"aRedirectFlags=%" PRIx32 ", aLoadFlags=%" PRIx32,
this, aRedirectFlags, aLoadFlags));
switch (mExternalContentPolicyType) {
case nsIContentPolicy::TYPE_DOCUMENT:
case nsIContentPolicy::TYPE_SUBDOCUMENT: {
// TODO(djg): Add the last URI visit to history if success. Is there a
// better place to handle this? Need access to the updated aLoadFlags.
nsresult status = NS_OK;
mChannel->GetStatus(&status);
bool updateGHistory =
nsDocShell::ShouldUpdateGlobalHistory(mLoadStateLoadType);
if (NS_SUCCEEDED(status) && updateGHistory &&
!net::ChannelIsPost(mChannel)) {
AddURIVisit(mChannel, aLoadFlags);
}
break;
}
default:
break;
// TODO(djg): Add the last URI visit to history if success. Is there a better
// place to handle this? Need access to the updated aLoadFlags.
nsresult status = NS_OK;
mChannel->GetStatus(&status);
bool updateGHistory =
nsDocShell::ShouldUpdateGlobalHistory(mLoadStateLoadType);
if (NS_SUCCEEDED(status) && updateGHistory && !net::ChannelIsPost(mChannel)) {
AddURIVisit(mChannel, aLoadFlags);
}
// Register the new channel and obtain id for it
@ -1876,9 +1701,7 @@ void DocumentLoadListener::TriggerRedirectToRealChannel(
MOZ_ALWAYS_SUCCEEDS(mChannel->GetLoadFlags(&newLoadFlags));
// We're pulling our flags from the inner channel, which may not have this
// flag set on it. This is the case when loading a 'view-source' channel.
if (mExternalContentPolicyType != nsIContentPolicy::TYPE_OBJECT) {
newLoadFlags |= nsIChannel::LOAD_DOCUMENT_URI;
}
newLoadFlags |= nsIChannel::LOAD_DOCUMENT_URI;
if (!aDestinationProcess) {
newLoadFlags |= nsIChannel::LOAD_REPLACE;
}
@ -1917,8 +1740,7 @@ void DocumentLoadListener::TriggerRedirectToRealChannel(
}
void DocumentLoadListener::MaybeReportBlockedByURLClassifier(nsresult aStatus) {
auto* browsingContext = GetDocumentBrowsingContext();
if (!browsingContext || browsingContext->IsTop() ||
if (!GetBrowsingContext() || GetBrowsingContext()->IsTop() ||
!StaticPrefs::privacy_trackingprotection_testing_report_blocked_node()) {
return;
}
@ -1927,10 +1749,10 @@ void DocumentLoadListener::MaybeReportBlockedByURLClassifier(nsresult aStatus) {
return;
}
RefPtr<WindowGlobalParent> parent = browsingContext->GetParentWindowContext();
RefPtr<WindowGlobalParent> parent =
GetBrowsingContext()->GetParentWindowContext();
if (parent) {
Unused << parent->SendAddBlockedFrameNodeByClassifier(
GetLoadingBrowsingContext());
Unused << parent->SendAddBlockedFrameNodeByClassifier(GetBrowsingContext());
}
}
@ -1944,17 +1766,15 @@ bool DocumentLoadListener::DocShellWillDisplayContent(nsresult aStatus) {
// succeed with fixup, so we don't need to check for it
// here.
auto* loadingContext = GetLoadingBrowsingContext();
bool isInitialDocument = true;
if (WindowGlobalParent* currentWindow =
loadingContext->GetCurrentWindowGlobal()) {
GetBrowsingContext()->GetCurrentWindowGlobal()) {
isInitialDocument = currentWindow->IsInitialDocument();
}
nsresult rv = nsDocShell::FilterStatusForErrorPage(
aStatus, mChannel, mLoadStateLoadType, loadingContext->IsTop(),
loadingContext->GetUseErrorPages(), isInitialDocument, nullptr);
aStatus, mChannel, mLoadStateLoadType, GetBrowsingContext()->IsTop(),
GetBrowsingContext()->GetUseErrorPages(), isInitialDocument, nullptr);
// If filtering returned a failure code, then an error page will
// be display for that code, so return true;
@ -1962,17 +1782,14 @@ bool DocumentLoadListener::DocShellWillDisplayContent(nsresult aStatus) {
}
bool DocumentLoadListener::MaybeHandleLoadErrorWithURIFixup(nsresult aStatus) {
auto* bc = GetDocumentBrowsingContext();
if (!bc) {
return false;
}
nsCOMPtr<nsIInputStream> newPostData;
nsCOMPtr<nsIURI> newURI = nsDocShell::AttemptURIFixup(
mChannel, aStatus, mOriginalUriString, mLoadStateLoadType, bc->IsTop(),
mChannel, aStatus, mOriginalUriString, mLoadStateLoadType,
GetBrowsingContext()->IsTop(),
mLoadStateLoadFlags &
nsDocShell::INTERNAL_LOAD_FLAGS_ALLOW_THIRD_PARTY_FIXUP,
bc->UsePrivateBrowsing(), true, getter_AddRefs(newPostData));
GetBrowsingContext()->UsePrivateBrowsing(), true,
getter_AddRefs(newPostData));
if (!newURI) {
return false;
}
@ -1993,7 +1810,7 @@ bool DocumentLoadListener::MaybeHandleLoadErrorWithURIFixup(nsresult aStatus) {
loadState->SetPostDataStream(newPostData);
bc->LoadURI(loadState, false);
GetBrowsingContext()->LoadURI(loadState, false);
return true;
}
@ -2015,8 +1832,7 @@ DocumentLoadListener::OnStartRequest(nsIRequest* aRequest) {
// might cancel the channel.
nsContentSecurityUtils::PerformCSPFrameAncestorAndXFOCheck(mChannel);
auto* loadingContext = GetLoadingBrowsingContext();
if (!loadingContext || loadingContext->IsDiscarded()) {
if (!GetBrowsingContext() || GetBrowsingContext()->IsDiscarded()) {
DisconnectListeners(NS_ERROR_UNEXPECTED, NS_ERROR_UNEXPECTED);
return NS_ERROR_UNEXPECTED;
}
@ -2075,10 +1891,10 @@ DocumentLoadListener::OnStartRequest(nsIRequest* aRequest) {
// If we're not going to process switch, then we must have an existing
// window global, right?
MOZ_ASSERT(loadingContext->GetCurrentWindowGlobal());
MOZ_ASSERT(GetBrowsingContext()->GetCurrentWindowGlobal());
RefPtr<BrowserParent> browserParent =
loadingContext->GetCurrentWindowGlobal()->GetBrowserParent();
GetBrowsingContext()->GetCurrentWindowGlobal()->GetBrowserParent();
// This load has already started, so we want to suspend the start progress
// events from the docshell from reaching the parent.
@ -2090,13 +1906,14 @@ DocumentLoadListener::OnStartRequest(nsIRequest* aRequest) {
// Use the current process ID to run the 'process switch' path and connect
// the channel into the current process.
TriggerRedirectToRealChannel(Some(loadingContext->OwnerProcessId()));
TriggerRedirectToRealChannel(
Some(GetBrowsingContext()->OwnerProcessId()));
} else {
TriggerRedirectToRealChannel(Nothing());
}
// If we're not switching, then check if we're currently remote.
if (auto* bc = GetDocumentBrowsingContext(); bc && bc->GetContentParent()) {
if (GetBrowsingContext() && GetBrowsingContext()->GetContentParent()) {
willBeRemote = true;
}
}
@ -2187,7 +2004,7 @@ DocumentLoadListener::OnAfterLastPart(nsresult aStatus) {
NS_IMETHODIMP
DocumentLoadListener::GetInterface(const nsIID& aIID, void** result) {
RefPtr<CanonicalBrowsingContext> browsingContext =
GetDocumentBrowsingContext();
mParentChannelListener->GetBrowsingContext();
if (aIID.Equals(NS_GET_IID(nsILoadContext)) && browsingContext) {
browsingContext.forget(result);
return NS_OK;
@ -2261,8 +2078,7 @@ DocumentLoadListener::Delete() {
NS_IMETHODIMP
DocumentLoadListener::GetRemoteType(nsACString& aRemoteType) {
RefPtr<CanonicalBrowsingContext> browsingContext =
GetDocumentBrowsingContext();
RefPtr<CanonicalBrowsingContext> browsingContext = GetBrowsingContext();
if (!browsingContext) {
return NS_ERROR_UNEXPECTED;
}
@ -2342,7 +2158,7 @@ DocumentLoadListener::AsyncOnChannelRedirect(
return NS_OK;
}
if (GetDocumentBrowsingContext() && !net::ChannelIsPost(aOldChannel)) {
if (!net::ChannelIsPost(aOldChannel)) {
AddURIVisit(aOldChannel, 0);
nsCOMPtr<nsIURI> oldURI;
@ -2389,8 +2205,7 @@ DocumentLoadListener::AsyncOnChannelRedirect(
AntiTrackingUtils::MaybeGetDocumentURIBeingLoaded(mChannel);
RefPtr<MozPromise<bool, bool, false>> promise;
nsCOMPtr<nsIWidget> widget =
bc ? bc->GetParentProcessWidgetContaining() : nullptr;
nsCOMPtr<nsIWidget> widget = bc->GetParentProcessWidgetContaining();
RefPtr<nsWindow> window = nsWindow::From(widget);
if (window) {
@ -2466,17 +2281,16 @@ NS_IMETHODIMP DocumentLoadListener::OnStatus(nsIRequest* aRequest,
nsCOMPtr<nsIWebProgress> webProgress =
new RemoteWebProgress(mLoadStateLoadType, true, true);
RefPtr<BrowsingContextWebProgress> topWebProgress =
WebProgressForBrowsingContext(GetTopBrowsingContext());
RefPtr<CanonicalBrowsingContext> ctx = GetBrowsingContext();
const nsString message(aStatusArg);
if (topWebProgress) {
NS_DispatchToMainThread(
NS_NewRunnableFunction("DocumentLoadListener::OnStatus", [=]() {
topWebProgress->OnStatusChange(webProgress, channel, aStatus,
message.get());
}));
}
NS_DispatchToMainThread(
NS_NewRunnableFunction("DocumentLoadListener::FireStateChange", [=]() {
if (ctx && ctx->Top()->GetWebProgress()) {
ctx->Top()->GetWebProgress()->OnStatusChange(webProgress, channel,
aStatus, message.get());
}
}));
return NS_OK;
}

Просмотреть файл

@ -94,10 +94,8 @@ class DocumentLoadListener : public nsIInterfaceRequestor,
public nsIMultiPartChannelListener,
public nsIProgressEventSink {
public:
// See the comment on GetLoadingBrowsingContext for explanation of
// aLoadingBrowsingContext.
explicit DocumentLoadListener(
dom::CanonicalBrowsingContext* aLoadingBrowsingContext);
dom::CanonicalBrowsingContext* aBrowsingContext);
struct OpenPromiseSucceededType {
nsTArray<ipc::Endpoint<extensions::PStreamFilterParent>>
@ -119,7 +117,6 @@ class DocumentLoadListener : public nsIInterfaceRequestor,
true /* isExclusive */>
OpenPromise;
private:
// Creates the channel, and then calls AsyncOpen on it.
// The DocumentLoadListener will require additional process from the consumer
// in order to complete the redirect to the end channel. This is done by
@ -128,30 +125,14 @@ class DocumentLoadListener : public nsIInterfaceRequestor,
// Once that promise is resolved; the consumer no longer needs to hold a
// reference to the DocumentLoadListener nor will the consumer required to be
// used again.
RefPtr<OpenPromise> Open(nsDocShellLoadState* aLoadState, LoadInfo* aLoadInfo,
nsLoadFlags aLoadFlags, uint32_t aCacheKey,
RefPtr<OpenPromise> Open(nsDocShellLoadState* aLoadState, uint32_t aCacheKey,
const Maybe<uint64_t>& aChannelId,
const TimeStamp& aAsyncOpenTime,
nsDOMNavigationTiming* aTiming,
Maybe<dom::ClientInfo>&& aInfo, bool aHasGesture,
bool aUrgentStart, base::ProcessId aPid,
nsresult* aRv);
public:
RefPtr<OpenPromise> OpenDocument(
nsDocShellLoadState* aLoadState, uint32_t aCacheKey,
const Maybe<uint64_t>& aChannelId, const TimeStamp& aAsyncOpenTime,
nsDOMNavigationTiming* aTiming, Maybe<dom::ClientInfo>&& aInfo,
uint64_t aOuterWindowId, bool aHasGesture, Maybe<bool> aUriModified,
Maybe<bool> aIsXFOError, base::ProcessId aPid, nsresult* aRv);
RefPtr<OpenPromise> OpenObject(
nsDocShellLoadState* aLoadState, uint32_t aCacheKey,
const Maybe<uint64_t>& aChannelId, const TimeStamp& aAsyncOpenTime,
nsDOMNavigationTiming* aTiming, Maybe<dom::ClientInfo>&& aInfo,
uint64_t aInnerWindowId, nsLoadFlags aLoadFlags,
nsContentPolicyType aContentPolicyType, bool aHasGesture,
bool aUrgentStart, base::ProcessId aPid, nsresult* aRv);
Maybe<dom::ClientInfo>&& aInfo,
uint64_t aOuterWindowId, bool aHasGesture,
Maybe<bool> aUriModified, Maybe<bool> aIsXFOError,
base::ProcessId aPid, nsresult* aRv);
// Creates a DocumentLoadListener entirely in the parent process and opens it,
// and never needs a DocumentChannel to connect to an existing docshell.
@ -256,6 +237,8 @@ class DocumentLoadListener : public nsIInterfaceRequestor,
dom::ContentParent* aParent) const;
uint64_t GetLoadIdentifier() const { return mLoadIdentifier; }
dom::CanonicalBrowsingContext* GetBrowsingContext() const;
uint32_t GetLoadType() const { return mLoadStateLoadType; }
protected:
@ -315,18 +298,7 @@ class DocumentLoadListener : public nsIInterfaceRequestor,
// Construct a LoadInfo object to use for the internal channel.
already_AddRefed<LoadInfo> CreateLoadInfo(
dom::CanonicalBrowsingContext* aBrowsingContext,
nsDocShellLoadState* aLoadState, uint64_t aOuterWindowId,
uint64_t aInnerWindowId, nsContentPolicyType aContentPolicyType);
// Return the Browsing Context that is performing the load.
// For document loads, the BC is the one that the (sub)doc
// will load into. For <object>/<embed>, it's the embedder document's BC.
dom::CanonicalBrowsingContext* GetLoadingBrowsingContext() const;
// Return the Browsing Context that document is being loaded into. For
// non-document loads, this will return nullptr.
dom::CanonicalBrowsingContext* GetDocumentBrowsingContext() const;
dom::CanonicalBrowsingContext* GetTopBrowsingContext() const;
nsDocShellLoadState* aLoadState, uint64_t aOuterWindowId);
void AddURIVisit(nsIChannel* aChannel, uint32_t aLoadFlags);
bool HasCrossOriginOpenerPolicyMismatch() const;
@ -342,8 +314,6 @@ class DocumentLoadListener : public nsIInterfaceRequestor,
// Returns false if the docshell will ignore the load entirely.
bool DocShellWillDisplayContent(nsresult aStatus);
void FireStateChange(uint32_t aStateFlags, nsresult aStatus);
// Returns true if this is a failed load, where we have successfully
// created a fixed URI to attempt loading instead.
// If successful, this calls DisconnectListeners to completely finish
@ -471,8 +441,6 @@ class DocumentLoadListener : public nsIInterfaceRequestor,
mozilla::UniquePtr<mozilla::dom::SessionHistoryInfo> mSessionHistoryInfo;
nsContentPolicyType mExternalContentPolicyType;
// Flags from nsDocShellLoadState::LoadFlags/Type that we want to make
// available to the new docshell if we switch processes.
uint32_t mLoadStateLoadFlags = 0;

Просмотреть файл

@ -437,33 +437,18 @@ struct CookieStruct
uint8_t schemeMap;
};
struct DocumentCreationArgs {
uint64_t outerWindowId;
bool uriModified;
bool isXFOError;
};
struct ObjectCreationArgs {
uint64_t embedderInnerWindowId;
uint32_t loadFlags;
uint8_t contentPolicyType;
bool isUrgentStart;
};
union DocumentChannelElementCreationArgs {
DocumentCreationArgs;
ObjectCreationArgs;
};
struct DocumentChannelCreationArgs {
DocShellLoadStateInit loadState;
TimeStamp asyncOpenTime;
uint64_t channelId;
uint32_t cacheKey;
bool pluginsAllowed;
nsDOMNavigationTiming? timing;
IPCClientInfo? initialClientInfo;
uint64_t outerWindowId;
bool hasValidTransientUserAction;
DocumentChannelElementCreationArgs elementCreationArgs;
bool uriModified;
bool isXFOError;
};
struct RedirectToRealChannelArgs {

Просмотреть файл

@ -129,10 +129,8 @@ ParentProcessDocumentChannel::OnRedirectVerifyCallback(nsresult aResult) {
NS_IMETHODIMP ParentProcessDocumentChannel::AsyncOpen(
nsIStreamListener* aListener) {
LOG(("ParentProcessDocumentChannel AsyncOpen [this=%p]", this));
auto docShell = RefPtr<nsDocShell>(GetDocShell());
MOZ_ASSERT(docShell);
mDocumentLoadListener = MakeRefPtr<DocumentLoadListener>(
docShell->GetBrowsingContext()->Canonical());
mDocumentLoadListener = new DocumentLoadListener(
GetDocShell()->GetBrowsingContext()->Canonical());
LOG(("Created PPDocumentChannel with listener=%p",
mDocumentLoadListener.get()));
@ -146,47 +144,18 @@ NS_IMETHODIMP ParentProcessDocumentChannel::AsyncOpen(
gHttpHandler->OnOpeningDocumentRequest(this);
switch (mLoadInfo->GetExternalContentPolicyType()) {
case nsIContentPolicy::TYPE_DOCUMENT:
case nsIContentPolicy::TYPE_SUBDOCUMENT:
GetDocShell()->GetBrowsingContext()->SetCurrentLoadIdentifier(
Some(mLoadState->GetLoadIdentifier()));
break;
default:
break;
}
GetDocShell()->GetBrowsingContext()->SetCurrentLoadIdentifier(
Some(mLoadState->GetLoadIdentifier()));
nsresult rv = NS_OK;
Maybe<dom::ClientInfo> initialClientInfo = mInitialClientInfo;
const bool hasValidTransientUserGestureActivation =
docShell->GetBrowsingContext()->HasValidTransientUserGestureActivation();
RefPtr<DocumentLoadListener::OpenPromise> promise;
switch (mLoadInfo->GetExternalContentPolicyType()) {
case nsIContentPolicy::TYPE_DOCUMENT:
case nsIContentPolicy::TYPE_SUBDOCUMENT:
promise = mDocumentLoadListener->OpenDocument(
mLoadState, mCacheKey, Some(mChannelId), mAsyncOpenTime, mTiming,
std::move(initialClientInfo), docShell->GetOuterWindowID(),
hasValidTransientUserGestureActivation, Some(mUriModified),
Some(mIsXFOError), 0 /* ProcessId */, &rv);
break;
case nsIContentPolicy::TYPE_OBJECT:
promise = mDocumentLoadListener->OpenObject(
mLoadState, mCacheKey, Some(mChannelId), mAsyncOpenTime, mTiming,
std::move(initialClientInfo), InnerWindowIDForExtantDoc(docShell),
mLoadFlags, mLoadInfo->InternalContentPolicyType(),
hasValidTransientUserGestureActivation,
UserActivation::IsHandlingUserInput(), 0 /* ProcessId */, &rv);
break;
default:
MOZ_CRASH("Unhandled content policy type.");
}
auto promise = mDocumentLoadListener->Open(
mLoadState, mCacheKey, Some(mChannelId), mAsyncOpenTime, mTiming,
std::move(initialClientInfo), GetDocShell()->GetOuterWindowID(),
GetDocShell()
->GetBrowsingContext()
->HasValidTransientUserGestureActivation(),
Some(mUriModified), Some(mIsXFOError), 0 /* ProcessId */, &rv);
if (NS_FAILED(rv)) {
MOZ_ASSERT(!promise);
mDocumentLoadListener = nullptr;