mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-14 04:03:47 +00:00
Bug 1590166 - WindowGlobalChild::Create should call GetCrossOriginOpenerPolicy instead of ComputeCrossOriginOpenerPolicy r=bzbarsky
Differential Revision: https://phabricator.services.mozilla.com/D59360 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
10a5ef8799
commit
1e2da20ce2
@ -81,8 +81,7 @@ already_AddRefed<WindowGlobalChild> WindowGlobalChild::Create(
|
||||
if (httpChan &&
|
||||
loadInfo->GetExternalContentPolicyType() ==
|
||||
nsIContentPolicy::TYPE_DOCUMENT &&
|
||||
NS_SUCCEEDED(httpChan->ComputeCrossOriginOpenerPolicy(
|
||||
nsILoadInfo::OPENER_POLICY_NULL, &policy))) {
|
||||
NS_SUCCEEDED(httpChan->GetCrossOriginOpenerPolicy(&policy))) {
|
||||
bc->SetOpenerPolicy(policy);
|
||||
}
|
||||
|
||||
|
@ -46,7 +46,7 @@ interface nsIProcessSwitchRequestor : nsISupports
|
||||
/**
|
||||
* Returns a cached CrossOriginOpenerPolicy that is computed just before we
|
||||
* determine if there is a policy mismatch.
|
||||
* @throws NS_ERROR_NOT_AVAILABLE if it has not been computed yet
|
||||
* @throws NS_ERROR_NOT_AVAILABLE if called before onStartRequest
|
||||
*/
|
||||
[must_use] readonly attribute nsILoadInfo_CrossOriginOpenerPolicy crossOriginOpenerPolicy;
|
||||
[must_use, binaryname(CachedCrossOriginOpenerPolicy)] readonly attribute nsILoadInfo_CrossOriginOpenerPolicy crossOriginOpenerPolicy;
|
||||
};
|
||||
|
@ -1238,7 +1238,7 @@ DocumentLoadListener::HasCrossOriginOpenerPolicyMismatch(bool* aMismatch) {
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
DocumentLoadListener::GetCrossOriginOpenerPolicy(
|
||||
DocumentLoadListener::GetCachedCrossOriginOpenerPolicy(
|
||||
nsILoadInfo::CrossOriginOpenerPolicy* aPolicy) {
|
||||
MOZ_ASSERT(aPolicy);
|
||||
if (!aPolicy) {
|
||||
|
@ -661,5 +661,11 @@ NS_IMETHODIMP ClassifierDummyChannel::ComputeCrossOriginOpenerPolicy(
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
ClassifierDummyChannel::GetCrossOriginOpenerPolicy(
|
||||
nsILoadInfo::CrossOriginOpenerPolicy* aPolicy) {
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
} // namespace net
|
||||
} // namespace mozilla
|
||||
|
@ -158,6 +158,7 @@ HttpBaseChannel::HttpBaseChannel()
|
||||
: mReportCollector(new ConsoleReportCollector()),
|
||||
mHttpHandler(gHttpHandler),
|
||||
mChannelCreationTime(0),
|
||||
mComputedCrossOriginOpenerPolicy(nsILoadInfo::OPENER_POLICY_NULL),
|
||||
mStartPos(UINT64_MAX),
|
||||
mTransferSize(0),
|
||||
mRequestSize(0),
|
||||
@ -4585,5 +4586,22 @@ NS_IMETHODIMP HttpBaseChannel::ComputeCrossOriginOpenerPolicy(
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
HttpBaseChannel::GetCrossOriginOpenerPolicy(
|
||||
nsILoadInfo::CrossOriginOpenerPolicy* aPolicy) {
|
||||
MOZ_ASSERT(aPolicy);
|
||||
if (!aPolicy) {
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
// If this method is called before OnStartRequest (ie. before we call
|
||||
// ComputeCrossOriginOpenerPolicy) or if we were unable to compute the
|
||||
// policy we'll throw an error.
|
||||
if (!mOnStartRequestCalled) {
|
||||
return NS_ERROR_NOT_AVAILABLE;
|
||||
}
|
||||
*aPolicy = mComputedCrossOriginOpenerPolicy;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
} // namespace net
|
||||
} // namespace mozilla
|
||||
|
@ -314,6 +314,8 @@ class HttpBaseChannel : public nsHashPropertyBag,
|
||||
NS_IMETHOD CancelByURLClassifier(nsresult aErrorCode) override;
|
||||
virtual void SetIPv4Disabled(void) override;
|
||||
virtual void SetIPv6Disabled(void) override;
|
||||
NS_IMETHOD GetCrossOriginOpenerPolicy(
|
||||
nsILoadInfo::CrossOriginOpenerPolicy* aCrossOriginOpenerPolicy) override;
|
||||
NS_IMETHOD ComputeCrossOriginOpenerPolicy(
|
||||
nsILoadInfo::CrossOriginOpenerPolicy aInitiatorPolicy,
|
||||
nsILoadInfo::CrossOriginOpenerPolicy* aOutPolicy) override;
|
||||
@ -702,6 +704,10 @@ class HttpBaseChannel : public nsHashPropertyBag,
|
||||
// so that the timing can still be queried from OnStopRequest
|
||||
TimingStruct mTransactionTimings;
|
||||
|
||||
// Gets computed during ComputeCrossOriginOpenerPolicyMismatch so we have
|
||||
// the channel's policy even if we don't know policy initiator.
|
||||
nsILoadInfo::CrossOriginOpenerPolicy mComputedCrossOriginOpenerPolicy;
|
||||
|
||||
uint64_t mStartPos;
|
||||
uint64_t mTransferSize;
|
||||
uint64_t mRequestSize;
|
||||
|
@ -383,7 +383,8 @@ mozilla::ipc::IPCResult HttpChannelChild::RecvOnStartRequest(
|
||||
const bool& aApplyConversion, const bool& aIsResolvedByTRR,
|
||||
const ResourceTimingStructArgs& aTiming,
|
||||
const bool& aAllRedirectsSameOrigin, const Maybe<uint32_t>& aMultiPartID,
|
||||
const bool& aIsLastPartOfMultiPart) {
|
||||
const bool& aIsLastPartOfMultiPart,
|
||||
const nsILoadInfo::CrossOriginOpenerPolicy& aOpenerPolicy) {
|
||||
AUTO_PROFILER_LABEL("HttpChannelChild::RecvOnStartRequest", NETWORK);
|
||||
LOG(("HttpChannelChild::RecvOnStartRequest [this=%p]\n", this));
|
||||
// mFlushedForDiversion and mDivertingToParent should NEVER be set at this
|
||||
@ -405,7 +406,8 @@ mozilla::ipc::IPCResult HttpChannelChild::RecvOnStartRequest(
|
||||
aCacheExpirationTime, aCachedCharset, aSecurityInfoSerialization,
|
||||
aSelfAddr, aPeerAddr, aCacheKey, aAltDataType, aAltDataLen,
|
||||
aDeliveringAltData, aApplyConversion, aIsResolvedByTRR, aTiming,
|
||||
aAllRedirectsSameOrigin, aMultiPartID, aIsLastPartOfMultiPart]() {
|
||||
aAllRedirectsSameOrigin, aMultiPartID, aIsLastPartOfMultiPart,
|
||||
aOpenerPolicy]() {
|
||||
self->OnStartRequest(
|
||||
aChannelStatus, aResponseHead, aUseResponseHead, aRequestHeaders,
|
||||
aLoadInfoForwarder, aIsFromCache, aIsRacing, aCacheEntryAvailable,
|
||||
@ -413,7 +415,8 @@ mozilla::ipc::IPCResult HttpChannelChild::RecvOnStartRequest(
|
||||
aCachedCharset, aSecurityInfoSerialization, aSelfAddr, aPeerAddr,
|
||||
aCacheKey, aAltDataType, aAltDataLen, aDeliveringAltData,
|
||||
aApplyConversion, aIsResolvedByTRR, aTiming,
|
||||
aAllRedirectsSameOrigin, aMultiPartID, aIsLastPartOfMultiPart);
|
||||
aAllRedirectsSameOrigin, aMultiPartID, aIsLastPartOfMultiPart,
|
||||
aOpenerPolicy);
|
||||
}));
|
||||
|
||||
{
|
||||
@ -467,7 +470,8 @@ void HttpChannelChild::OnStartRequest(
|
||||
const bool& aDeliveringAltData, const bool& aApplyConversion,
|
||||
const bool& aIsResolvedByTRR, const ResourceTimingStructArgs& aTiming,
|
||||
const bool& aAllRedirectsSameOrigin, const Maybe<uint32_t>& aMultiPartID,
|
||||
const bool& aIsLastPartOfMultiPart) {
|
||||
const bool& aIsLastPartOfMultiPart,
|
||||
const nsILoadInfo::CrossOriginOpenerPolicy& aOpenerPolicy) {
|
||||
LOG(("HttpChannelChild::OnStartRequest [this=%p]\n", this));
|
||||
|
||||
// mFlushedForDiversion and mDivertingToParent should NEVER be set at this
|
||||
@ -487,6 +491,8 @@ void HttpChannelChild::OnStartRequest(
|
||||
return;
|
||||
}
|
||||
|
||||
mComputedCrossOriginOpenerPolicy = aOpenerPolicy;
|
||||
|
||||
if (!mCanceled && NS_SUCCEEDED(mStatus)) {
|
||||
mStatus = aChannelStatus;
|
||||
}
|
||||
|
@ -145,7 +145,8 @@ class HttpChannelChild final : public PHttpChannelChild,
|
||||
const bool& aApplyConversion, const bool& aIsResolvedByTRR,
|
||||
const ResourceTimingStructArgs& aTiming,
|
||||
const bool& aAllRedirectsSameOrigin, const Maybe<uint32_t>& aMultiPartID,
|
||||
const bool& aIsLastPartOfMultiPart) override;
|
||||
const bool& aIsLastPartOfMultiPart,
|
||||
const nsILoadInfo::CrossOriginOpenerPolicy& aOpenerPolicy) override;
|
||||
mozilla::ipc::IPCResult RecvOnTransportAndData(
|
||||
const nsresult& aChannelStatus, const nsresult& aTransportStatus,
|
||||
const uint64_t& aOffset, const uint32_t& aCount,
|
||||
@ -510,7 +511,8 @@ class HttpChannelChild final : public PHttpChannelChild,
|
||||
const bool& deliveringAltData, const bool& aApplyConversion,
|
||||
const bool& aIsResolvedByTRR, const ResourceTimingStructArgs& aTiming,
|
||||
const bool& aAllRedirectsSameOrigin, const Maybe<uint32_t>& aMultiPartID,
|
||||
const bool& aIsLastPartOfMultiPart);
|
||||
const bool& aIsLastPartOfMultiPart,
|
||||
const nsILoadInfo::CrossOriginOpenerPolicy& aOpenerPolicy);
|
||||
void MaybeDivertOnData(const nsCString& data, const uint64_t& offset,
|
||||
const uint32_t& count);
|
||||
void OnTransportAndData(const nsresult& channelStatus, const nsresult& status,
|
||||
|
@ -1522,6 +1522,10 @@ HttpChannelParent::OnStartRequest(nsIRequest* aRequest) {
|
||||
bool allRedirectsSameOrigin = false;
|
||||
chan->GetAllRedirectsSameOrigin(&allRedirectsSameOrigin);
|
||||
|
||||
nsILoadInfo::CrossOriginOpenerPolicy openerPolicy =
|
||||
nsILoadInfo::OPENER_POLICY_NULL;
|
||||
chan->GetCrossOriginOpenerPolicy(&openerPolicy);
|
||||
|
||||
rv = NS_OK;
|
||||
if (mIPCClosed ||
|
||||
!SendOnStartRequest(
|
||||
@ -1533,7 +1537,7 @@ HttpChannelParent::OnStartRequest(nsIRequest* aRequest) {
|
||||
chan->GetPeerAddr(), redirectCount, cacheKey, altDataType, altDataLen,
|
||||
deliveringAltData, applyConversion, isResolvedByTRR,
|
||||
GetTimingAttributes(mChannel), allRedirectsSameOrigin, multiPartID,
|
||||
isLastPartOfMultiPart)) {
|
||||
isLastPartOfMultiPart, openerPolicy)) {
|
||||
rv = NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
requestHead->Exit();
|
||||
|
@ -21,6 +21,7 @@ using class nsHttpHeaderArray from "nsHttpHeaderArray.h";
|
||||
using mozilla::net::NetAddr from "mozilla/net/DNS.h";
|
||||
using refcounted class nsIReferrerInfo from "mozilla/dom/ReferrerInfoUtils.h";
|
||||
using nsIHttpChannel::FlashPluginState from "mozilla/net/NeckoMessageUtils.h";
|
||||
using nsILoadInfo::CrossOriginOpenerPolicy from "nsILoadInfo.h";
|
||||
|
||||
namespace mozilla {
|
||||
namespace net {
|
||||
@ -130,7 +131,8 @@ child:
|
||||
ResourceTimingStructArgs timing,
|
||||
bool allRedirectsSameOrigin,
|
||||
uint32_t? multiPartId,
|
||||
bool isLastPartOfMultiPart);
|
||||
bool isLastPartOfMultiPart,
|
||||
CrossOriginOpenerPolicy policy);
|
||||
|
||||
// Combines a single OnDataAvailable and its associated OnProgress &
|
||||
// OnStatus calls into one IPDL message
|
||||
|
@ -304,7 +304,6 @@ nsHttpChannel::nsHttpChannel()
|
||||
mOfflineCacheLastModifiedTime(0),
|
||||
mSuspendTotalTime(0),
|
||||
mRedirectType(0),
|
||||
mComputedCrossOriginOpenerPolicy(nsILoadInfo::OPENER_POLICY_NULL),
|
||||
mCacheOpenWithPriority(false),
|
||||
mCacheQueueSizeWhenOpen(0),
|
||||
mCachedContentIsValid(false),
|
||||
@ -7398,20 +7397,9 @@ nsHttpChannel::HasCrossOriginOpenerPolicyMismatch(bool* aMismatch) {
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHttpChannel::GetCrossOriginOpenerPolicy(
|
||||
nsHttpChannel::GetCachedCrossOriginOpenerPolicy(
|
||||
nsILoadInfo::CrossOriginOpenerPolicy* aPolicy) {
|
||||
MOZ_ASSERT(aPolicy);
|
||||
if (!aPolicy) {
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
// If this method is called before OnStartRequest (ie. before we call
|
||||
// ComputeCrossOriginOpenerPolicy) or if we were unable to compute the
|
||||
// policy we'll throw an error.
|
||||
if (!mOnStartRequestCalled) {
|
||||
return NS_ERROR_NOT_AVAILABLE;
|
||||
}
|
||||
*aPolicy = mComputedCrossOriginOpenerPolicy;
|
||||
return NS_OK;
|
||||
return HttpBaseChannel::GetCrossOriginOpenerPolicy(aPolicy);
|
||||
}
|
||||
|
||||
// See https://gist.github.com/annevk/6f2dd8c79c77123f39797f6bdac43f3e
|
||||
|
@ -664,10 +664,6 @@ class nsHttpChannel final : public HttpBaseChannel,
|
||||
static const uint32_t WAIT_FOR_CACHE_ENTRY = 1;
|
||||
static const uint32_t WAIT_FOR_OFFLINE_CACHE_ENTRY = 2;
|
||||
|
||||
// Gets computed during ComputeCrossOriginOpenerPolicyMismatch so we have
|
||||
// the channel's policy even if we don't know policy initiator.
|
||||
nsILoadInfo::CrossOriginOpenerPolicy mComputedCrossOriginOpenerPolicy;
|
||||
|
||||
bool mCacheOpenWithPriority;
|
||||
uint32_t mCacheQueueSizeWhenOpen;
|
||||
|
||||
|
@ -386,7 +386,15 @@ interface nsIHttpChannelInternal : nsISupports
|
||||
void setIPv6Disabled();
|
||||
|
||||
/**
|
||||
* Get the Cross-Origin-Opener-Policy of the top-level document channel.
|
||||
* Returns a cached CrossOriginOpenerPolicy that is computed just before we
|
||||
* determine if there is a policy mismatch.
|
||||
* @throws NS_ERROR_NOT_AVAILABLE if it has not been computed yet
|
||||
*/
|
||||
readonly attribute nsILoadInfo_CrossOriginOpenerPolicy crossOriginOpenerPolicy;
|
||||
|
||||
/**
|
||||
* Called during onStartRequest to compute the cross-origin-opener-policy
|
||||
* for a given channel.
|
||||
*/
|
||||
[noscript]
|
||||
nsILoadInfo_CrossOriginOpenerPolicy computeCrossOriginOpenerPolicy(
|
||||
|
Loading…
x
Reference in New Issue
Block a user