From 6401c0185c7f78b9b096ad452262409cf44dd064 Mon Sep 17 00:00:00 2001 From: Phil Ringnalda Date: Wed, 21 Oct 2015 20:21:05 -0700 Subject: [PATCH] Back out 2 changesets (bug 1173811) for test_synthesized_response.js timeouts CLOSED TREE Backed out changeset 56bc1314e660 (bug 1173811) Backed out changeset 0ad51d302ba9 (bug 1173811) --- dom/workers/ServiceWorkerEvents.cpp | 30 +-- modules/libjar/InterceptedJARChannel.cpp | 8 +- .../base/nsINetworkInterceptController.idl | 8 +- netwerk/protocol/http/HttpBaseChannel.cpp | 15 -- netwerk/protocol/http/HttpChannelChild.cpp | 189 +++++------------- netwerk/protocol/http/HttpChannelChild.h | 26 +-- netwerk/protocol/http/HttpChannelParent.cpp | 4 +- netwerk/protocol/http/InterceptedChannel.cpp | 71 ++----- netwerk/protocol/http/InterceptedChannel.h | 9 +- netwerk/protocol/http/nsHttpChannel.cpp | 41 +--- netwerk/protocol/http/nsHttpChannel.h | 6 +- .../protocol/http/nsIHttpChannelInternal.idl | 9 +- .../web-platform/mozilla/meta/MANIFEST.json | 6 - .../fetch-request-css-base-url.https.html.ini | 5 - .../worker-interception-iframe.https.html.ini | 3 - .../fetch-canvas-tainting-cache.https.html | 38 ---- .../fetch-event-redirect.https.html | 3 +- .../fetch-canvas-tainting-iframe.html | 25 +-- .../fetch-event-redirect-iframe.html | 7 - .../resources/fetch-rewrite-worker.js | 20 +- 20 files changed, 103 insertions(+), 420 deletions(-) delete mode 100644 testing/web-platform/mozilla/meta/service-workers/service-worker/fetch-request-css-base-url.https.html.ini delete mode 100644 testing/web-platform/mozilla/meta/service-workers/service-worker/resources/worker-interception-iframe.https.html.ini delete mode 100644 testing/web-platform/mozilla/tests/service-workers/service-worker/fetch-canvas-tainting-cache.https.html diff --git a/dom/workers/ServiceWorkerEvents.cpp b/dom/workers/ServiceWorkerEvents.cpp index c87ca4b6f4ec..5726d0a190ae 100644 --- a/dom/workers/ServiceWorkerEvents.cpp +++ b/dom/workers/ServiceWorkerEvents.cpp @@ -109,19 +109,16 @@ class FinishResponse final : public nsRunnable RefPtr mInternalResponse; ChannelInfo mWorkerChannelInfo; const nsCString mScriptSpec; - const nsCString mResponseURLSpec; public: FinishResponse(nsMainThreadPtrHandle& aChannel, InternalResponse* aInternalResponse, const ChannelInfo& aWorkerChannelInfo, - const nsACString& aScriptSpec, - const nsACString& aResponseURLSpec) + const nsACString& aScriptSpec) : mChannel(aChannel) , mInternalResponse(aInternalResponse) , mWorkerChannelInfo(aWorkerChannelInfo) , mScriptSpec(aScriptSpec) - , mResponseURLSpec(aResponseURLSpec) { } @@ -157,7 +154,7 @@ public: mChannel->SynthesizeHeader(entries[i].mName, entries[i].mValue); } - rv = mChannel->FinishSynthesizedResponse(mResponseURLSpec); + rv = mChannel->FinishSynthesizedResponse(); NS_WARN_IF_FALSE(NS_SUCCEEDED(rv), "Failed to finish synthesized response"); return rv; } @@ -235,18 +232,15 @@ struct RespondWithClosure RefPtr mInternalResponse; ChannelInfo mWorkerChannelInfo; const nsCString mScriptSpec; - const nsCString mResponseURLSpec; RespondWithClosure(nsMainThreadPtrHandle& aChannel, InternalResponse* aInternalResponse, const ChannelInfo& aWorkerChannelInfo, - const nsCString& aScriptSpec, - const nsACString& aResponseURLSpec) + const nsCString& aScriptSpec) : mInterceptedChannel(aChannel) , mInternalResponse(aInternalResponse) , mWorkerChannelInfo(aWorkerChannelInfo) , mScriptSpec(aScriptSpec) - , mResponseURLSpec(aResponseURLSpec) { } }; @@ -259,8 +253,7 @@ void RespondWithCopyComplete(void* aClosure, nsresult aStatus) event = new FinishResponse(data->mInterceptedChannel, data->mInternalResponse, data->mWorkerChannelInfo, - data->mScriptSpec, - data->mResponseURLSpec); + data->mScriptSpec); } else { event = new CancelChannelRunnable(data->mInterceptedChannel, NS_ERROR_INTERCEPTION_FAILED); @@ -363,22 +356,9 @@ RespondWithHandler::ResolvedCallback(JSContext* aCx, JS::Handle aValu return; } - // When an opaque response is encountered, we need the original channel's principal - // to reflect the final URL. Non-opaque responses are either same-origin or CORS-enabled - // cross-origin responses, which are treated as same-origin by consumers. - nsCString responseURL; - if (response->Type() == ResponseType::Opaque) { - ir->GetUnfilteredUrl(responseURL); - if (NS_WARN_IF(responseURL.IsEmpty())) { - autoCancel.SetCancelStatus(NS_ERROR_INTERCEPTION_FAILED); - return; - } - } - nsAutoPtr closure(new RespondWithClosure(mInterceptedChannel, ir, worker->GetChannelInfo(), - mScriptSpec, - responseURL)); + mScriptSpec)); nsCOMPtr body; ir->GetUnfilteredBody(getter_AddRefs(body)); // Errors and redirects may not have a body. diff --git a/modules/libjar/InterceptedJARChannel.cpp b/modules/libjar/InterceptedJARChannel.cpp index bea5e2186bd3..c2057849b75c 100644 --- a/modules/libjar/InterceptedJARChannel.cpp +++ b/modules/libjar/InterceptedJARChannel.cpp @@ -78,18 +78,12 @@ InterceptedJARChannel::SynthesizeHeader(const nsACString& aName, } NS_IMETHODIMP -InterceptedJARChannel::FinishSynthesizedResponse(const nsACString& aFinalURLSpec) +InterceptedJARChannel::FinishSynthesizedResponse() { if (NS_WARN_IF(!mChannel)) { return NS_ERROR_NOT_AVAILABLE; } - if (!aFinalURLSpec.IsEmpty()) { - // We don't support rewriting responses for JAR channels where the principal - // needs to be modified. - return NS_ERROR_NOT_IMPLEMENTED; - } - mChannel->OverrideWithSynthesizedResponse(mSynthesizedInput, mContentType); mResponseBody = nullptr; diff --git a/netwerk/base/nsINetworkInterceptController.idl b/netwerk/base/nsINetworkInterceptController.idl index e0942dda140d..e5eabee6cd35 100644 --- a/netwerk/base/nsINetworkInterceptController.idl +++ b/netwerk/base/nsINetworkInterceptController.idl @@ -27,7 +27,7 @@ class ChannelInfo; * which do not implement nsIChannel. */ -[scriptable, uuid(afe6aae6-a80d-405b-856e-df36c19bf3c8)] +[scriptable, uuid(6be00c37-2e85-42ee-b53c-e6508ce4cef0)] interface nsIInterceptedChannel : nsISupports { /** @@ -51,11 +51,9 @@ interface nsIInterceptedChannel : nsISupports /** * Instruct a channel that has been intercepted that a response has been * synthesized and can now be read. No further header modification is allowed - * after this point. The caller may optionally pass a spec for a URL that - * this response originates from; an empty string will cause the original - * intercepted request's URL to be used instead. + * after this point. */ - void finishSynthesizedResponse(in ACString finalURLSpec); + void finishSynthesizedResponse(); /** * Cancel the pending intercepted request. diff --git a/netwerk/protocol/http/HttpBaseChannel.cpp b/netwerk/protocol/http/HttpBaseChannel.cpp index 75f4c8f48c94..bd1a168b7e13 100644 --- a/netwerk/protocol/http/HttpBaseChannel.cpp +++ b/netwerk/protocol/http/HttpBaseChannel.cpp @@ -267,21 +267,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; mForceMainDocumentChannel = (aLoadFlags & LOAD_DOCUMENT_URI); return NS_OK; diff --git a/netwerk/protocol/http/HttpChannelChild.cpp b/netwerk/protocol/http/HttpChannelChild.cpp index 5b0350468897..9eb120bfaf28 100644 --- a/netwerk/protocol/http/HttpChannelChild.cpp +++ b/netwerk/protocol/http/HttpChannelChild.cpp @@ -184,8 +184,6 @@ HttpChannelChild::HttpChannelChild() , mFlushedForDiversion(false) , mSuspendSent(false) , mSynthesizedResponse(false) - , mShouldInterceptSubsequentRedirect(false) - , mRedirectingForSubsequentSynthesizedResponse(false) , mShouldParentIntercept(false) { LOG(("Creating HttpChannelChild @%x\n", this)); @@ -1159,51 +1157,6 @@ HttpChannelChild::RecvRedirect1Begin(const uint32_t& newChannelId, return true; } -nsresult -HttpChannelChild::SetupRedirect(nsIURI* uri, - const nsHttpResponseHead* responseHead, - nsIChannel** outChannel) -{ - LOG(("HttpChannelChild::SetupRedirect [this=%p]\n", this)); - - nsresult rv; - nsCOMPtr ioService; - rv = gHttpHandler->GetIOService(getter_AddRefs(ioService)); - NS_ENSURE_SUCCESS(rv, rv); - - nsCOMPtr newChannel; - rv = NS_NewChannelInternal(getter_AddRefs(newChannel), - uri, - mLoadInfo, - nullptr, // aLoadGroup - nullptr, // aCallbacks - nsIRequest::LOAD_NORMAL, - ioService); - NS_ENSURE_SUCCESS(rv, rv); - - // We won't get OnStartRequest, set cookies here. - mResponseHead = new nsHttpResponseHead(*responseHead); - - bool rewriteToGET = HttpBaseChannel::ShouldRewriteRedirectToGET(mResponseHead->Status(), - mRequestHead.ParsedMethod()); - - rv = SetupReplacementChannel(uri, newChannel, !rewriteToGET); - NS_ENSURE_SUCCESS(rv, rv); - - nsCOMPtr httpChannelChild = do_QueryInterface(newChannel); - if (mShouldInterceptSubsequentRedirect && httpChannelChild) { - // In the case where there was a synthesized response that caused a redirection, - // we must force the new channel to intercept the request in the parent before a - // network transaction is initiated. - httpChannelChild->ForceIntercepted(); - } - - mRedirectChannelChild = do_QueryInterface(newChannel); - newChannel.forget(outChannel); - - return NS_OK; -} - void HttpChannelChild::Redirect1Begin(const uint32_t& newChannelId, const URIParams& newUri, @@ -1213,50 +1166,68 @@ HttpChannelChild::Redirect1Begin(const uint32_t& newChannelId, { LOG(("HttpChannelChild::Redirect1Begin [this=%p]\n", this)); + nsresult rv; + nsCOMPtr ioService; + rv = gHttpHandler->GetIOService(getter_AddRefs(ioService)); + if (NS_FAILED(rv)) { + // Veto redirect. nsHttpChannel decides to cancel or continue. + OnRedirectVerifyCallback(rv); + return; + } + nsCOMPtr uri = DeserializeURI(newUri); + nsCOMPtr newChannel; + rv = NS_NewChannelInternal(getter_AddRefs(newChannel), + uri, + mLoadInfo, + nullptr, // aLoadGroup + nullptr, // aCallbacks + nsIRequest::LOAD_NORMAL, + ioService); + + if (NS_FAILED(rv)) { + // Veto redirect. nsHttpChannel decides to cancel or continue. + OnRedirectVerifyCallback(rv); + return; + } + + // We won't get OnStartRequest, set cookies here. + mResponseHead = new nsHttpResponseHead(responseHead); + if (!securityInfoSerialization.IsEmpty()) { NS_DeserializeObject(securityInfoSerialization, getter_AddRefs(mSecurityInfo)); } - nsCOMPtr newChannel; - nsresult rv = SetupRedirect(uri, - &responseHead, - getter_AddRefs(newChannel)); + bool rewriteToGET = HttpBaseChannel::ShouldRewriteRedirectToGET(mResponseHead->Status(), + mRequestHead.ParsedMethod()); - if (NS_SUCCEEDED(rv)) { - if (mRedirectChannelChild) { - mRedirectChannelChild->ConnectParent(newChannelId); - rv = gHttpHandler->AsyncOnChannelRedirect(this, - newChannel, - redirectFlags); - } else { - LOG((" redirecting to a protocol that doesn't implement" - " nsIChildChannel")); - rv = NS_ERROR_FAILURE; - } + rv = SetupReplacementChannel(uri, newChannel, !rewriteToGET); + if (NS_FAILED(rv)) { + // Veto redirect. nsHttpChannel decides to cancel or continue. + OnRedirectVerifyCallback(rv); + return; } - if (NS_FAILED(rv)) - OnRedirectVerifyCallback(rv); -} + nsCOMPtr httpChannelChild = do_QueryInterface(newChannel); + if (mSynthesizedResponse && httpChannelChild) { + // In the case where there was a synthesized response that caused a redirection, + // we must force the new channel to intercept the request in the parent before a + // network transaction is initiated. + httpChannelChild->ForceIntercepted(); + } -void -HttpChannelChild::BeginNonIPCRedirect(nsIURI* responseURI, - const nsHttpResponseHead* responseHead) -{ - LOG(("HttpChannelChild::BeginNonIPCRedirect [this=%p]\n", this)); - - nsCOMPtr newChannel; - nsresult rv = SetupRedirect(responseURI, - responseHead, - getter_AddRefs(newChannel)); - - if (NS_SUCCEEDED(rv)) { + mRedirectChannelChild = do_QueryInterface(newChannel); + if (mRedirectChannelChild) { + mRedirectChannelChild->ConnectParent(newChannelId); rv = gHttpHandler->AsyncOnChannelRedirect(this, newChannel, - nsIChannelEventSink::REDIRECT_INTERNAL); + redirectFlags); + } else { + LOG((" redirecting to a protocol that doesn't implement" + " nsIChildChannel")); + rv = NS_ERROR_FAILURE; } if (NS_FAILED(rv)) @@ -1464,34 +1435,6 @@ HttpChannelChild::CompleteRedirectSetup(nsIStreamListener *listener, // HttpChannelChild::nsIAsyncVerifyRedirectCallback //----------------------------------------------------------------------------- -class OverrideRunnable : public nsRunnable { - RefPtr mChannel; - RefPtr mNewChannel; - RefPtr mListener; - nsCOMPtr mInput; - nsAutoPtr mHead; - -public: - OverrideRunnable(HttpChannelChild* aChannel, - HttpChannelChild* aNewChannel, - InterceptStreamListener* aListener, - nsIInputStream* aInput, - nsAutoPtr& aHead) - : mChannel(aChannel) - , mNewChannel(aNewChannel) - , mListener(aListener) - , mInput(aInput) - , mHead(aHead) - { - } - - NS_IMETHOD Run() { - mChannel->Redirect3Complete(); - mNewChannel->OverrideWithSynthesizedResponse(mHead, mInput, mListener); - return NS_OK; - } -}; - NS_IMETHODIMP HttpChannelChild::OnRedirectVerifyCallback(nsresult result) { @@ -1505,21 +1448,6 @@ HttpChannelChild::OnRedirectVerifyCallback(nsresult result) newHttpChannel->SetOriginalURI(mOriginalURI); } - if (mRedirectingForSubsequentSynthesizedResponse) { - nsCOMPtr httpChannelChild = do_QueryInterface(mRedirectChannelChild); - MOZ_ASSERT(httpChannelChild); - RefPtr redirectedChannel = - static_cast(httpChannelChild.get()); - - RefPtr streamListener = - new InterceptStreamListener(redirectedChannel, mListenerContext); - - NS_DispatchToMainThread(new OverrideRunnable(this, redirectedChannel, - streamListener, mSynthesizedInput, - mResponseHead)); - return NS_OK; - } - RequestHeaderTuples emptyHeaders; RequestHeaderTuples* headerTuples = &emptyHeaders; nsLoadFlags loadFlags = 0; @@ -2457,10 +2385,8 @@ HttpChannelChild::GetResponseSynthesized(bool* aSynthesized) void HttpChannelChild::OverrideWithSynthesizedResponse(nsAutoPtr& aResponseHead, nsIInputStream* aSynthesizedInput, - InterceptStreamListener* aStreamListener) + nsIStreamListener* aStreamListener) { - mInterceptListener = aStreamListener; - // Intercepted responses should already be decoded. If its a redirect, // however, we want to respect the encoding of the final result instead. if (!WillRedirect(aResponseHead)) { @@ -2471,7 +2397,6 @@ HttpChannelChild::OverrideWithSynthesizedResponse(nsAutoPtr& mSynthesizedResponse = true; if (WillRedirect(mResponseHead)) { - mShouldInterceptSubsequentRedirect = true; // Continue with the original cross-process request nsresult rv = ContinueAsyncOpen(); NS_ENSURE_SUCCESS_VOID(rv); @@ -2519,20 +2444,6 @@ HttpChannelChild::ForceIntercepted() return NS_OK; } -NS_IMETHODIMP -HttpChannelChild::ForceIntercepted(uint64_t aInterceptionID) -{ - return NS_ERROR_NOT_IMPLEMENTED; -} - -void -HttpChannelChild::ForceIntercepted(nsIInputStream* aSynthesizedInput) -{ - mSynthesizedInput = aSynthesizedInput; - mSynthesizedResponse = true; - mRedirectingForSubsequentSynthesizedResponse = true; -} - bool HttpChannelChild::RecvIssueDeprecationWarning(const uint32_t& warning, const bool& asError) diff --git a/netwerk/protocol/http/HttpChannelChild.h b/netwerk/protocol/http/HttpChannelChild.h index 21809e186234..44b583490553 100644 --- a/netwerk/protocol/http/HttpChannelChild.h +++ b/netwerk/protocol/http/HttpChannelChild.h @@ -37,7 +37,6 @@ namespace net { class InterceptedChannelContent; class InterceptStreamListener; -class OverrideRunnable; class HttpChannelChild final : public PHttpChannelChild , public HttpBaseChannel @@ -89,7 +88,6 @@ public: NS_IMETHOD GetLocalPort(int32_t* port) override; NS_IMETHOD GetRemoteAddress(nsACString& addr) override; NS_IMETHOD GetRemotePort(int32_t* port) override; - NS_IMETHOD ForceIntercepted(uint64_t aInterceptionID) override; // nsISupportsPriority NS_IMETHOD SetPriority(int32_t value) override; // nsIClassOfService @@ -176,16 +174,12 @@ private: // asynchronously read from the pump. void OverrideWithSynthesizedResponse(nsAutoPtr& aResponseHead, nsIInputStream* aSynthesizedInput, - InterceptStreamListener* aStreamListener); - - void ForceIntercepted(nsIInputStream* aSynthesizedInput); + nsIStreamListener* aStreamListener); RequestHeaderTuples mClientSetRequestHeaders; nsCOMPtr mRedirectChannelChild; RefPtr mInterceptListener; RefPtr mSynthesizedResponsePump; - nsAutoPtr mSynthesizedResponseHead; - nsCOMPtr mSynthesizedInput; int64_t mSynthesizedStreamLength; bool mIsFromCache; @@ -220,13 +214,6 @@ private: // should be intercepted. bool mSynthesizedResponse; - // Set if a synthesized response should cause us to explictly allows intercepting - // an expected forthcoming redirect. - bool mShouldInterceptSubsequentRedirect; - // Set if a redirection is being initiated to facilitate providing a synthesized - // response to a channel using a different principal than the current one. - bool mRedirectingForSubsequentSynthesizedResponse; - // Set if the corresponding parent channel should force an interception to occur // before the network transaction is initiated. bool mShouldParentIntercept; @@ -272,16 +259,6 @@ private: void Redirect3Complete(); void DeleteSelf(); - // Create a a new channel to be used in a redirection, based on the provided - // response headers. - nsresult SetupRedirect(nsIURI* uri, - const nsHttpResponseHead* responseHead, - nsIChannel** outChannel); - - // Perform a redirection without communicating with the parent process at all. - void BeginNonIPCRedirect(nsIURI* responseURI, - const nsHttpResponseHead* responseHead); - friend class AssociateApplicationCacheEvent; friend class StartRequestEvent; friend class StopRequestEvent; @@ -297,7 +274,6 @@ private: friend class HttpAsyncAborter; friend class InterceptStreamListener; friend class InterceptedChannelContent; - friend class OverrideRunnable; }; //----------------------------------------------------------------------------- diff --git a/netwerk/protocol/http/HttpChannelParent.cpp b/netwerk/protocol/http/HttpChannelParent.cpp index ee44b7efbaea..e0fdb28a9a8c 100644 --- a/netwerk/protocol/http/HttpChannelParent.cpp +++ b/netwerk/protocol/http/HttpChannelParent.cpp @@ -203,9 +203,7 @@ public: NS_IMETHOD Run() { - // The URL passed as an argument here doesn't matter, since the child will - // receive a redirection notification as a result of this synthesized response. - mChannel->FinishSynthesizedResponse(EmptyCString()); + mChannel->FinishSynthesizedResponse(); return NS_OK; } }; diff --git a/netwerk/protocol/http/InterceptedChannel.cpp b/netwerk/protocol/http/InterceptedChannel.cpp index 7937cf7b4897..b92e969e7a99 100644 --- a/netwerk/protocol/http/InterceptedChannel.cpp +++ b/netwerk/protocol/http/InterceptedChannel.cpp @@ -179,7 +179,7 @@ InterceptedChannelChrome::SynthesizeHeader(const nsACString& aName, const nsACSt } NS_IMETHODIMP -InterceptedChannelChrome::FinishSynthesizedResponse(const nsACString& aFinalURLSpec) +InterceptedChannelChrome::FinishSynthesizedResponse() { if (!mChannel) { return NS_ERROR_NOT_AVAILABLE; @@ -208,38 +208,23 @@ InterceptedChannelChrome::FinishSynthesizedResponse(const nsACString& aFinalURLS mSynthesizedResponseHead.ref(), securityInfo); NS_ENSURE_SUCCESS(rv, rv); - nsCOMPtr originalURI; - mChannel->GetURI(getter_AddRefs(originalURI)); + nsCOMPtr uri; + mChannel->GetURI(getter_AddRefs(uri)); - nsCOMPtr responseURI; - if (!aFinalURLSpec.IsEmpty()) { - nsresult rv = NS_NewURI(getter_AddRefs(responseURI), aFinalURLSpec); + bool usingSSL = false; + uri->SchemeIs("https", &usingSSL); + + // Then we open a real cache entry to read the synthesized response from. + rv = mChannel->OpenCacheEntry(usingSSL); + NS_ENSURE_SUCCESS(rv, rv); + + mSynthesizedCacheEntry = nullptr; + + if (!mChannel->AwaitingCacheCallbacks()) { + rv = mChannel->ContinueConnect(); NS_ENSURE_SUCCESS(rv, rv); - } else { - responseURI = originalURI; } - bool equal = false; - originalURI->Equals(responseURI, &equal); - if (!equal) { - nsresult rv = - mChannel->StartRedirectChannelToURI(responseURI, nsIChannelEventSink::REDIRECT_INTERNAL); - NS_ENSURE_SUCCESS(rv, rv); - } else { - bool usingSSL = false; - responseURI->SchemeIs("https", &usingSSL); - - // Then we open a real cache entry to read the synthesized response from. - rv = mChannel->OpenCacheEntry(usingSSL); - NS_ENSURE_SUCCESS(rv, rv); - - mSynthesizedCacheEntry = nullptr; - - if (!mChannel->AwaitingCacheCallbacks()) { - rv = mChannel->ContinueConnect(); - NS_ENSURE_SUCCESS(rv, rv); - } - } mChannel = nullptr; return NS_OK; } @@ -284,7 +269,7 @@ InterceptedChannelChrome::GetInternalContentPolicyType(nsContentPolicyType* aPol InterceptedChannelContent::InterceptedChannelContent(HttpChannelChild* aChannel, nsINetworkInterceptController* aController, - InterceptStreamListener* aListener) + nsIStreamListener* aListener) : InterceptedChannelBase(aController) , mChannel(aChannel) , mStreamListener(aListener) @@ -345,7 +330,7 @@ InterceptedChannelContent::SynthesizeHeader(const nsACString& aName, const nsACS } NS_IMETHODIMP -InterceptedChannelContent::FinishSynthesizedResponse(const nsACString& aFinalURLSpec) +InterceptedChannelContent::FinishSynthesizedResponse() { if (NS_WARN_IF(!mChannel)) { return NS_ERROR_NOT_AVAILABLE; @@ -353,27 +338,9 @@ InterceptedChannelContent::FinishSynthesizedResponse(const nsACString& aFinalURL EnsureSynthesizedResponse(); - nsCOMPtr originalURI; - mChannel->GetURI(getter_AddRefs(originalURI)); - - nsCOMPtr responseURI; - if (!aFinalURLSpec.IsEmpty()) { - nsresult rv = NS_NewURI(getter_AddRefs(responseURI), aFinalURLSpec); - NS_ENSURE_SUCCESS(rv, rv); - } else { - responseURI = originalURI; - } - - bool equal = false; - originalURI->Equals(responseURI, &equal); - if (!equal) { - mChannel->ForceIntercepted(mSynthesizedInput); - mChannel->BeginNonIPCRedirect(responseURI, *mSynthesizedResponseHead.ptr()); - } else { - mChannel->OverrideWithSynthesizedResponse(mSynthesizedResponseHead.ref(), - mSynthesizedInput, - mStreamListener); - } + mChannel->OverrideWithSynthesizedResponse(mSynthesizedResponseHead.ref(), + mSynthesizedInput, + mStreamListener); mResponseBody = nullptr; mChannel = nullptr; diff --git a/netwerk/protocol/http/InterceptedChannel.h b/netwerk/protocol/http/InterceptedChannel.h index 3e134d04a79c..faeb13d9806d 100644 --- a/netwerk/protocol/http/InterceptedChannel.h +++ b/netwerk/protocol/http/InterceptedChannel.h @@ -21,7 +21,6 @@ namespace net { class nsHttpChannel; class HttpChannelChild; class nsHttpResponseHead; -class InterceptStreamListener; // An object representing a channel that has been intercepted. This avoids complicating // the actual channel implementation with the details of synthesizing responses. @@ -73,7 +72,7 @@ public: nsICacheEntry* aEntry); NS_IMETHOD ResetInterception() override; - NS_IMETHOD FinishSynthesizedResponse(const nsACString& aFinalURLSpec) override; + NS_IMETHOD FinishSynthesizedResponse() override; NS_IMETHOD GetChannel(nsIChannel** aChannel) override; NS_IMETHOD SynthesizeStatus(uint16_t aStatus, const nsACString& aReason) override; NS_IMETHOD SynthesizeHeader(const nsACString& aName, const nsACString& aValue) override; @@ -94,14 +93,14 @@ class InterceptedChannelContent : public InterceptedChannelBase // Listener for the synthesized response to fix up the notifications before they reach // the actual channel. - RefPtr mStreamListener; + nsCOMPtr mStreamListener; public: InterceptedChannelContent(HttpChannelChild* aChannel, nsINetworkInterceptController* aController, - InterceptStreamListener* aListener); + nsIStreamListener* aListener); NS_IMETHOD ResetInterception() override; - NS_IMETHOD FinishSynthesizedResponse(const nsACString& aFinalURLSpec) override; + NS_IMETHOD FinishSynthesizedResponse() override; NS_IMETHOD GetChannel(nsIChannel** aChannel) override; NS_IMETHOD SynthesizeStatus(uint16_t aStatus, const nsACString& aReason) override; NS_IMETHOD SynthesizeHeader(const nsACString& aName, const nsACString& aValue) override; diff --git a/netwerk/protocol/http/nsHttpChannel.cpp b/netwerk/protocol/http/nsHttpChannel.cpp index 5f6d3ce596d5..c21c8c19b776 100644 --- a/netwerk/protocol/http/nsHttpChannel.cpp +++ b/netwerk/protocol/http/nsHttpChannel.cpp @@ -2010,19 +2010,12 @@ nsHttpChannel::StartRedirectChannelToURI(nsIURI *upgradedURI, uint32_t flags) if (!(flags & nsIChannelEventSink::REDIRECT_STS_UPGRADE)) { // Ensure that internally-redirected channels cannot be intercepted, which would look // like two separate requests to the nsINetworkInterceptController. - if (mInterceptCache == INTERCEPTED) { - nsCOMPtr httpRedirect = do_QueryInterface(mRedirectChannel); - if (httpRedirect) { - httpRedirect->ForceIntercepted(mInterceptionID); - } - } else { - nsLoadFlags loadFlags = nsIRequest::LOAD_NORMAL; - rv = mRedirectChannel->GetLoadFlags(&loadFlags); - NS_ENSURE_SUCCESS(rv, rv); - loadFlags |= nsIChannel::LOAD_BYPASS_SERVICE_WORKER; - rv = mRedirectChannel->SetLoadFlags(loadFlags); - NS_ENSURE_SUCCESS(rv, rv); - } + nsLoadFlags loadFlags = nsIRequest::LOAD_NORMAL; + rv = mRedirectChannel->GetLoadFlags(&loadFlags); + NS_ENSURE_SUCCESS(rv, rv); + loadFlags |= nsIChannel::LOAD_BYPASS_SERVICE_WORKER; + rv = mRedirectChannel->SetLoadFlags(loadFlags); + NS_ENSURE_SUCCESS(rv, rv); } PushRedirectAsyncFunc( @@ -3000,10 +2993,11 @@ nsHttpChannel::OpenCacheEntry(bool isHttps) if (mLoadFlags & LOAD_BYPASS_LOCAL_CACHE_IF_BUSY) cacheEntryOpenFlags |= nsICacheStorage::OPEN_BYPASS_IF_BUSY; + if (mPostID) { + extension.Append(nsPrintfCString("%d", mPostID)); + } if (PossiblyIntercepted()) { extension.Append(nsPrintfCString("u%lld", mInterceptionID)); - } else if (mPostID) { - extension.Append(nsPrintfCString("%d", mPostID)); } // If this channel should be intercepted, we do not open a cache entry for this channel @@ -4990,7 +4984,7 @@ nsHttpChannel::AsyncOpen(nsIStreamListener *listener, nsISupports *context) return rv; } - if (mInterceptCache != INTERCEPTED && ShouldIntercept()) { + if (ShouldIntercept()) { mInterceptCache = MAYBE_INTERCEPT; SetCouldBeSynthesized(); } @@ -5350,21 +5344,6 @@ nsHttpChannel::SetupFallbackChannel(const char *aFallbackKey) return NS_OK; } -NS_IMETHODIMP -nsHttpChannel::ForceIntercepted(uint64_t aInterceptionID) -{ - ENSURE_CALLED_BEFORE_ASYNC_OPEN(); - - if (NS_WARN_IF(mLoadFlags & LOAD_BYPASS_SERVICE_WORKER)) { - return NS_ERROR_NOT_AVAILABLE; - } - - MarkIntercepted(); - mResponseCouldBeSynthesized = true; - mInterceptionID = aInterceptionID; - return NS_OK; -} - //----------------------------------------------------------------------------- // nsHttpChannel::nsISupportsPriority //----------------------------------------------------------------------------- diff --git a/netwerk/protocol/http/nsHttpChannel.h b/netwerk/protocol/http/nsHttpChannel.h index 978ab6bdd79d..7d6ffa4d57f8 100644 --- a/netwerk/protocol/http/nsHttpChannel.h +++ b/netwerk/protocol/http/nsHttpChannel.h @@ -134,7 +134,6 @@ public: NS_IMETHOD AsyncOpen2(nsIStreamListener *aListener) override; // nsIHttpChannelInternal NS_IMETHOD SetupFallbackChannel(const char *aFallbackKey) override; - NS_IMETHOD ForceIntercepted(uint64_t aInterceptionID) override; // nsISupportsPriority NS_IMETHOD SetPriority(int32_t value) override; // nsIClassOfService @@ -434,9 +433,8 @@ private: MAYBE_INTERCEPT, // interception in progress, but can be cancelled INTERCEPTED, // a synthesized response has been provided } mInterceptCache; - // ID of this channel for the interception purposes. Unique unless this - // channel is replacing an intercepted one via an redirection. - uint64_t mInterceptionID; + // Unique ID of this channel for the interception purposes. + const uint64_t mInterceptionID; bool PossiblyIntercepted() { return mInterceptCache != DO_NOT_INTERCEPT; diff --git a/netwerk/protocol/http/nsIHttpChannelInternal.idl b/netwerk/protocol/http/nsIHttpChannelInternal.idl index b6779a33f418..5275805ebe0e 100644 --- a/netwerk/protocol/http/nsIHttpChannelInternal.idl +++ b/netwerk/protocol/http/nsIHttpChannelInternal.idl @@ -39,7 +39,7 @@ interface nsIHttpUpgradeListener : nsISupports * using any feature exposed by this interface, be aware that this interface * will change and you will be broken. You have been warned. */ -[scriptable, uuid(9eabaac6-cc7c-4ca1-9430-65f2daaa578f)] +[scriptable, uuid(99767aaf-937d-4f2f-8990-bc79bd7c0ece)] interface nsIHttpChannelInternal : nsISupports { /** @@ -222,13 +222,6 @@ interface nsIHttpChannelInternal : nsISupports readonly attribute PRTime lastModifiedTime; - /** - * Force a channel that has not been AsyncOpen'ed to skip any check for possible - * interception and proceed immediately to open a previously-synthesized cache - * entry using the provided ID. - */ - void forceIntercepted(in uint64_t aInterceptionID); - readonly attribute boolean responseSynthesized; /** diff --git a/testing/web-platform/mozilla/meta/MANIFEST.json b/testing/web-platform/mozilla/meta/MANIFEST.json index 7d9aca4e291d..4bb9edf29d1a 100644 --- a/testing/web-platform/mozilla/meta/MANIFEST.json +++ b/testing/web-platform/mozilla/meta/MANIFEST.json @@ -106,12 +106,6 @@ "url": "/_mozilla/service-workers/service-worker/extendable-event-waituntil.https.html" } ], - "service-workers/service-worker/fetch-canvas-tainting-cache.https.html": [ - { - "path": "service-workers/service-worker/fetch-canvas-tainting-cache.https.html", - "url": "/_mozilla/service-workers/service-worker/fetch-canvas-tainting-cache.https.html" - } - ], "service-workers/service-worker/fetch-canvas-tainting.https.html": [ { "path": "service-workers/service-worker/fetch-canvas-tainting.https.html", diff --git a/testing/web-platform/mozilla/meta/service-workers/service-worker/fetch-request-css-base-url.https.html.ini b/testing/web-platform/mozilla/meta/service-workers/service-worker/fetch-request-css-base-url.https.html.ini deleted file mode 100644 index 7e1a48b1a1cf..000000000000 --- a/testing/web-platform/mozilla/meta/service-workers/service-worker/fetch-request-css-base-url.https.html.ini +++ /dev/null @@ -1,5 +0,0 @@ -[fetch-request-css-base-url.https.html] - type: testharness - bug: https://bugzilla.mozilla.org/show_bug.cgi?id=1201160 - [CSS's base URL must be the request URL even when fetched from other URL.] - expected: FAIL diff --git a/testing/web-platform/mozilla/meta/service-workers/service-worker/resources/worker-interception-iframe.https.html.ini b/testing/web-platform/mozilla/meta/service-workers/service-worker/resources/worker-interception-iframe.https.html.ini deleted file mode 100644 index 2f281012cb80..000000000000 --- a/testing/web-platform/mozilla/meta/service-workers/service-worker/resources/worker-interception-iframe.https.html.ini +++ /dev/null @@ -1,3 +0,0 @@ -[worker-interception-iframe.https.html] - type: testharness - disabled: not a test diff --git a/testing/web-platform/mozilla/tests/service-workers/service-worker/fetch-canvas-tainting-cache.https.html b/testing/web-platform/mozilla/tests/service-workers/service-worker/fetch-canvas-tainting-cache.https.html deleted file mode 100644 index fdb64e15d66b..000000000000 --- a/testing/web-platform/mozilla/tests/service-workers/service-worker/fetch-canvas-tainting-cache.https.html +++ /dev/null @@ -1,38 +0,0 @@ - -Service Worker: canvas tainting of the fetched image using cached responses - - - - - - - diff --git a/testing/web-platform/mozilla/tests/service-workers/service-worker/fetch-event-redirect.https.html b/testing/web-platform/mozilla/tests/service-workers/service-worker/fetch-event-redirect.https.html index b53a4a41bc1c..c20ce817cc6a 100644 --- a/testing/web-platform/mozilla/tests/service-workers/service-worker/fetch-event-redirect.https.html +++ b/testing/web-platform/mozilla/tests/service-workers/service-worker/fetch-event-redirect.https.html @@ -65,8 +65,7 @@ function redirect_fetch_test(t, test) { }; frame.contentWindow.postMessage({ url: url, - request_init: test.request_init, - redirect_dest: test.redirect_dest, + request_init: test.request_init }, '*', [channel.port2]); }); diff --git a/testing/web-platform/mozilla/tests/service-workers/service-worker/resources/fetch-canvas-tainting-iframe.html b/testing/web-platform/mozilla/tests/service-workers/service-worker/resources/fetch-canvas-tainting-iframe.html index 6d8c6b6ebebb..046b8fdcd62a 100644 --- a/testing/web-platform/mozilla/tests/service-workers/service-worker/resources/fetch-canvas-tainting-iframe.html +++ b/testing/web-platform/mozilla/tests/service-workers/service-worker/resources/fetch-canvas-tainting-iframe.html @@ -3,26 +3,11 @@