From a0e824e158fe5854317e487c96daa9b6935e688d Mon Sep 17 00:00:00 2001 From: Junior Hsu Date: Wed, 18 Dec 2019 20:03:00 +0000 Subject: [PATCH] Bug 1600326 - P1 avoid wrongly COOP error for subframe, r=ttung Differential Revision: https://phabricator.services.mozilla.com/D57578 --HG-- extra : moz-landing-system : lando --- netwerk/protocol/http/nsHttpChannel.cpp | 8 ++++---- netwerk/protocol/http/nsHttpChannel.h | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/netwerk/protocol/http/nsHttpChannel.cpp b/netwerk/protocol/http/nsHttpChannel.cpp index ceabff667ac1..f90f473b623f 100644 --- a/netwerk/protocol/http/nsHttpChannel.cpp +++ b/netwerk/protocol/http/nsHttpChannel.cpp @@ -305,6 +305,7 @@ nsHttpChannel::nsHttpChannel() mOfflineCacheLastModifiedTime(0), mSuspendTotalTime(0), mRedirectType(0), + mComputedCrossOriginOpenerPolicy(nsILoadInfo::OPENER_POLICY_NULL), mCacheOpenWithPriority(false), mCacheQueueSizeWhenOpen(0), mCachedContentIsValid(false), @@ -7344,10 +7345,10 @@ nsHttpChannel::GetCrossOriginOpenerPolicy( // 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 (!mComputedCrossOriginOpenerPolicy.isSome()) { + if (!mOnStartRequestCalled) { return NS_ERROR_NOT_AVAILABLE; } - *aPolicy = mComputedCrossOriginOpenerPolicy.value(); + *aPolicy = mComputedCrossOriginOpenerPolicy; return NS_OK; } @@ -7411,7 +7412,6 @@ nsresult nsHttpChannel::ComputeCrossOriginOpenerPolicyMismatch() { if (!head) { // Not having a response head is not a hard failure at the point where // this method is called. - mComputedCrossOriginOpenerPolicy = Some(nsILoadInfo::OPENER_POLICY_NULL); return NS_OK; } @@ -7428,7 +7428,7 @@ nsresult nsHttpChannel::ComputeCrossOriginOpenerPolicyMismatch() { nsILoadInfo::CrossOriginOpenerPolicy resultPolicy = nsILoadInfo::OPENER_POLICY_NULL; Unused << ComputeCrossOriginOpenerPolicy(documentPolicy, &resultPolicy); - mComputedCrossOriginOpenerPolicy = Some(resultPolicy); + mComputedCrossOriginOpenerPolicy = resultPolicy; // If bc's popup sandboxing flag set is not empty and potentialCOOP is // non-null, then navigate bc to a network error and abort these steps. diff --git a/netwerk/protocol/http/nsHttpChannel.h b/netwerk/protocol/http/nsHttpChannel.h index 402c66d1e693..30a81b2cc95e 100644 --- a/netwerk/protocol/http/nsHttpChannel.h +++ b/netwerk/protocol/http/nsHttpChannel.h @@ -651,7 +651,7 @@ class nsHttpChannel final : public HttpBaseChannel, // Gets computed during ComputeCrossOriginOpenerPolicyMismatch so we have // the channel's policy even if we don't know policy initiator. - Maybe mComputedCrossOriginOpenerPolicy; + nsILoadInfo::CrossOriginOpenerPolicy mComputedCrossOriginOpenerPolicy; bool mCacheOpenWithPriority; uint32_t mCacheQueueSizeWhenOpen;