Bug 1468209 Remove nsIHttpChannelInternal.responseSynthesized and use nsILoadInfo.serviceWorkerTaintingSynthesized instead. r=valentin

This commit is contained in:
Ben Kelly 2018-06-12 07:02:01 -07:00
parent fad2f6fec0
commit f4e69fbdb7
10 changed files with 7 additions and 67 deletions

View File

@ -2603,13 +2603,8 @@ WarnIfSandboxIneffective(nsIDocShell* aDocShell,
bool
nsIDocument::IsSynthesized() {
nsCOMPtr<nsIHttpChannelInternal> internalChan = do_QueryInterface(mChannel);
bool synthesized = false;
if (internalChan) {
DebugOnly<nsresult> rv = internalChan->GetResponseSynthesized(&synthesized);
MOZ_ASSERT(NS_SUCCEEDED(rv), "GetResponseSynthesized shouldn't fail.");
}
return synthesized;
nsCOMPtr<nsILoadInfo> loadInfo = mChannel ? mChannel->GetLoadInfo() : nullptr;
return loadInfo && loadInfo->GetServiceWorkerTaintingSynthesized();
}
bool

View File

@ -472,21 +472,6 @@ HttpBaseChannel::GetLoadFlags(nsLoadFlags *aLoadFlags)
NS_IMETHODIMP
HttpBaseChannel::SetLoadFlags(nsLoadFlags aLoadFlags)
{
bool synthesized = false;
nsresult rv = GetResponseSynthesized(&synthesized);
NS_ENSURE_SUCCESS(rv, rv);
// If this channel is marked as awaiting a synthesized response,
// modifying certain load flags can interfere with the implementation
// of the network interception logic. This takes care of a couple
// known cases that attempt to mark channels as anonymous due
// to cross-origin redirects; since the response is entirely synthesized
// this is an unnecessary precaution.
// This should be removed when bug 1201683 is fixed.
if (synthesized && aLoadFlags != mLoadFlags) {
aLoadFlags &= ~LOAD_ANONYMOUS;
}
mLoadFlags = aLoadFlags;
return NS_OK;
}

View File

@ -3638,14 +3638,6 @@ HttpChannelChild::ResetInterception()
}
}
NS_IMETHODIMP
HttpChannelChild::GetResponseSynthesized(bool* aSynthesized)
{
NS_ENSURE_ARG_POINTER(aSynthesized);
*aSynthesized = mSynthesizedResponse;
return NS_OK;
}
void
HttpChannelChild::TrySendDeletingChannel()
{

View File

@ -182,8 +182,6 @@ protected:
virtual void DoAsyncAbort(nsresult aStatus) override;
NS_IMETHOD GetResponseSynthesized(bool* aSynthesized) override;
nsresult
AsyncCall(void (HttpChannelChild::*funcPtr)(),
nsRunnableMethod<HttpChannelChild> **retval = nullptr) override;

View File

@ -607,13 +607,6 @@ InterceptedHttpChannel::SetupFallbackChannel(const char* aFallbackKey)
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
InterceptedHttpChannel::GetResponseSynthesized(bool* aResponseSynthesized)
{
*aResponseSynthesized = mResponseHead || mBodyReader;
return NS_OK;
}
NS_IMETHODIMP
InterceptedHttpChannel::SetPriority(int32_t aPriority)
{

View File

@ -173,9 +173,6 @@ public:
NS_IMETHOD
SetupFallbackChannel(const char * aFallbackKey) override;
NS_IMETHOD
GetResponseSynthesized(bool *aResponseSynthesized) override;
NS_IMETHOD
SetPriority(int32_t aPriority) override;

View File

@ -566,11 +566,8 @@ nsCORSListenerProxy::CheckRequestApproved(nsIRequest* aRequest)
return NS_ERROR_DOM_BAD_URI;
}
nsCOMPtr<nsIHttpChannelInternal> internal = do_QueryInterface(aRequest);
NS_ENSURE_STATE(internal);
bool responseSynthesized = false;
if (NS_SUCCEEDED(internal->GetResponseSynthesized(&responseSynthesized)) &&
responseSynthesized) {
nsCOMPtr<nsILoadInfo> loadInfo = http->GetLoadInfo();
if (loadInfo && loadInfo->GetServiceWorkerTaintingSynthesized()) {
// For synthesized responses, we don't need to perform any checks.
// Note: This would be unsafe if we ever changed our behavior to allow
// service workers to intercept CORS preflights.
@ -1270,15 +1267,9 @@ nsCORSPreflightListener::OnStartRequest(nsIRequest *aRequest,
{
#ifdef DEBUG
{
nsCOMPtr<nsIHttpChannelInternal> internal = do_QueryInterface(aRequest);
bool responseSynthesized = false;
if (internal &&
NS_SUCCEEDED(internal->GetResponseSynthesized(&responseSynthesized))) {
// For synthesized responses, we don't need to perform any checks.
// This would be unsafe if we ever changed our behavior to allow
// service workers to intercept CORS preflights.
MOZ_ASSERT(!responseSynthesized);
}
nsCOMPtr<nsIChannel> channel = do_QueryInterface(aRequest);
nsCOMPtr<nsILoadInfo> loadInfo = channel ? channel->GetLoadInfo() : nullptr;
MOZ_ASSERT(!loadInfo || !loadInfo->GetServiceWorkerTaintingSynthesized());
}
#endif

View File

@ -8469,14 +8469,6 @@ nsHttpChannel::SetNotificationCallbacks(nsIInterfaceRequestor *aCallbacks)
return rv;
}
NS_IMETHODIMP
nsHttpChannel::GetResponseSynthesized(bool* aSynthesized)
{
NS_ENSURE_ARG_POINTER(aSynthesized);
*aSynthesized = false;
return NS_OK;
}
bool
nsHttpChannel::AwaitingCacheCallbacks()
{

View File

@ -257,7 +257,6 @@ public: /* internal necko use only */
uint32_t mKeep : 2;
};
NS_IMETHOD GetResponseSynthesized(bool* aSynthesized) override;
bool AwaitingCacheCallbacks();
void SetCouldBeSynthesized();

View File

@ -231,8 +231,6 @@ interface nsIHttpChannelInternal : nsISupports
[must_use] readonly attribute PRTime lastModifiedTime;
[must_use] readonly attribute boolean responseSynthesized;
/**
* Set by nsCORSListenerProxy if credentials should be included in
* cross-origin requests. false indicates "same-origin", users should still