diff --git a/docshell/base/nsDocShell.cpp b/docshell/base/nsDocShell.cpp index afb398bee95..aa3eaeaa51d 100644 --- a/docshell/base/nsDocShell.cpp +++ b/docshell/base/nsDocShell.cpp @@ -5198,16 +5198,6 @@ nsDocShell::DisplayLoadError(nsresult aError, nsIURI* aURI, // Broken Content Detected. e.g. Content-MD5 check failure. error.AssignLiteral("corruptedContentError"); break; - case NS_ERROR_INTERCEPTION_FAILED: - case NS_ERROR_OPAQUE_INTERCEPTION_DISABLED: - case NS_ERROR_BAD_OPAQUE_INTERCEPTION_REQUEST_MODE: - case NS_ERROR_INTERCEPTED_ERROR_RESPONSE: - case NS_ERROR_INTERCEPTED_USED_RESPONSE: - // ServiceWorker intercepted request, but something went wrong. - nsContentUtils::MaybeReportInterceptionErrorToConsole(GetDocument(), - aError); - error.AssignLiteral("corruptedContentError"); - break; default: break; } @@ -7835,11 +7825,6 @@ nsDocShell::EndPageLoad(nsIWebProgress* aProgress, aStatus == NS_ERROR_UNSAFE_CONTENT_TYPE || aStatus == NS_ERROR_REMOTE_XUL || aStatus == NS_ERROR_OFFLINE || - aStatus == NS_ERROR_INTERCEPTION_FAILED || - aStatus == NS_ERROR_OPAQUE_INTERCEPTION_DISABLED || - aStatus == NS_ERROR_BAD_OPAQUE_INTERCEPTION_REQUEST_MODE || - aStatus == NS_ERROR_INTERCEPTED_ERROR_RESPONSE || - aStatus == NS_ERROR_INTERCEPTED_USED_RESPONSE || NS_ERROR_GET_MODULE(aStatus) == NS_ERROR_MODULE_SECURITY) { // Errors to be shown for any frame DisplayLoadError(aStatus, url, nullptr, aChannel); @@ -14105,7 +14090,7 @@ nsDocShell::ChannelIntercepted(nsIInterceptedChannel* aChannel) { nsRefPtr swm = ServiceWorkerManager::GetInstance(); if (!swm) { - aChannel->Cancel(NS_ERROR_INTERCEPTION_FAILED); + aChannel->Cancel(); return NS_OK; } diff --git a/dom/base/nsContentUtils.cpp b/dom/base/nsContentUtils.cpp index 3521e06a26b..4eec861d99b 100644 --- a/dom/base/nsContentUtils.cpp +++ b/dom/base/nsContentUtils.cpp @@ -3416,34 +3416,6 @@ nsContentUtils::ReportToConsole(uint32_t aErrorFlags, aLineNumber, aColumnNumber); } -/* static */ nsresult -nsContentUtils::MaybeReportInterceptionErrorToConsole(nsIDocument* aDocument, - nsresult aError) -{ - const char* messageName = nullptr; - if (aError == NS_ERROR_INTERCEPTION_FAILED) { - messageName = "InterceptionFailed"; - } else if (aError == NS_ERROR_OPAQUE_INTERCEPTION_DISABLED) { - messageName = "OpaqueInterceptionDisabled"; - } else if (aError == NS_ERROR_BAD_OPAQUE_INTERCEPTION_REQUEST_MODE) { - messageName = "BadOpaqueInterceptionRequestMode"; - } else if (aError == NS_ERROR_INTERCEPTED_ERROR_RESPONSE) { - messageName = "InterceptedErrorResponse"; - } else if (aError == NS_ERROR_INTERCEPTED_USED_RESPONSE) { - messageName = "InterceptedUsedResponse"; - } - - if (messageName) { - return ReportToConsole(nsIScriptError::warningFlag, - NS_LITERAL_CSTRING("Service Worker Interception"), - aDocument, - nsContentUtils::eDOM_PROPERTIES, - messageName); - } - - return NS_OK; -} - /* static */ nsresult nsContentUtils::ReportToConsoleNonLocalized(const nsAString& aErrorText, diff --git a/dom/base/nsContentUtils.h b/dom/base/nsContentUtils.h index 3215dcefe92..a7dd9289da7 100644 --- a/dom/base/nsContentUtils.h +++ b/dom/base/nsContentUtils.h @@ -842,9 +842,6 @@ public: uint32_t aLineNumber = 0, uint32_t aColumnNumber = 0); - static nsresult - MaybeReportInterceptionErrorToConsole(nsIDocument* aDocument, nsresult aError); - static void LogMessageToConsole(const char* aMsg, ...); /** diff --git a/dom/locales/en-US/chrome/dom/dom.properties b/dom/locales/en-US/chrome/dom/dom.properties index 3c4b63fb43d..fdbd6911d84 100644 --- a/dom/locales/en-US/chrome/dom/dom.properties +++ b/dom/locales/en-US/chrome/dom/dom.properties @@ -166,13 +166,3 @@ HittingMaxWorkersPerDomain=A ServiceWorker could not be started immediately beca PannerNodeDopplerWarning=Use of setVelocity on the PannerNode and AudioListener, and speedOfSound and dopplerFactor on the AudioListener are deprecated and those members will be removed. For more help https://developer.mozilla.org/en-US/docs/Web/API/AudioListener#Deprecated_features # LOCALIZATION NOTE: Do not translate "Worker". EmptyWorkerSourceWarning=Attempting to create a Worker from an empty source. This is probably unintentional. -# LOCALIZATION NOTE: Do not translate "ServiceWorker". -InterceptionFailed=ServiceWorker network interception failed due to an unexpected error. -# LOCALIZATION NOTE: Do not translate "ServiceWorker", "FetchEvent.respondWith()", "opaque", or "Response". -OpaqueInterceptionDisabled=A ServiceWorker passed an opaque Response to FetchEvent.respondWith() while opaque interception is disabled. -# LOCALIZATION NOTE: Do not translate "ServiceWorker", "FetchEvent.respondWith()", "FetchEvent.request.type", "same-origin", "cors", "no-cors", "opaque", "Response", or "RequestMode". -BadOpaqueInterceptionRequestMode=A ServiceWorker passed an opaque Response to FetchEvent.respondWith() while the FetchEvent.request.type was either "same-origin" or "cors". Opaque Response objects are only valid when the RequestMode is "no-cors". -# LOCALIZATION NOTE: Do not translate "ServiceWorker", "Error", "Response", "FetchEvent.respondWith()", or "fetch()". -InterceptedErrorResponse=A ServiceWorker passed an Error Response to FetchEvent.respondWith(). This typically means the ServiceWorker performed an invalid fetch() call. -# LOCALIZATION NOTE: Do not translate "ServiceWorker", "Response", "FetchEvent.respondWith()", or "Response.clone()". -InterceptedUsedResponse=A ServiceWorker passed a used Response to FetchEvent.respondWith(). The body of a Response may only be read once. Use Response.clone() to access the body multiple times. diff --git a/dom/workers/ServiceWorkerEvents.cpp b/dom/workers/ServiceWorkerEvents.cpp index 84df31ad58c..127e3c2a77d 100644 --- a/dom/workers/ServiceWorkerEvents.cpp +++ b/dom/workers/ServiceWorkerEvents.cpp @@ -79,19 +79,16 @@ namespace { class CancelChannelRunnable final : public nsRunnable { nsMainThreadPtrHandle mChannel; - const nsresult mStatus; public: - CancelChannelRunnable(nsMainThreadPtrHandle& aChannel, - nsresult aStatus) + explicit CancelChannelRunnable(nsMainThreadPtrHandle& aChannel) : mChannel(aChannel) - , mStatus(aStatus) { } NS_IMETHOD Run() { MOZ_ASSERT(NS_IsMainThread()); - nsresult rv = mChannel->Cancel(mStatus); + nsresult rv = mChannel->Cancel(); NS_ENSURE_SUCCESS(rv, rv); return NS_OK; } @@ -163,7 +160,7 @@ public: void RejectedCallback(JSContext* aCx, JS::Handle aValue) override; - void CancelRequest(nsresult aStatus); + void CancelRequest(); }; struct RespondWithClosure @@ -191,8 +188,7 @@ void RespondWithCopyComplete(void* aClosure, nsresult aStatus) data->mInternalResponse, data->mWorkerChannelInfo); } else { - event = new CancelChannelRunnable(data->mInterceptedChannel, - NS_ERROR_INTERCEPTION_FAILED); + event = new CancelChannelRunnable(data->mInterceptedChannel); } MOZ_ALWAYS_TRUE(NS_SUCCEEDED(NS_DispatchToMainThread(event))); } @@ -200,28 +196,20 @@ void RespondWithCopyComplete(void* aClosure, nsresult aStatus) class MOZ_STACK_CLASS AutoCancel { nsRefPtr mOwner; - nsresult mStatus; public: explicit AutoCancel(RespondWithHandler* aOwner) : mOwner(aOwner) - , mStatus(NS_ERROR_INTERCEPTION_FAILED) { } ~AutoCancel() { if (mOwner) { - mOwner->CancelRequest(mStatus); + mOwner->CancelRequest(); } } - void SetCancelStatus(nsresult aStatus) - { - MOZ_ASSERT(NS_FAILED(aStatus)); - mStatus = aStatus; - } - void Reset() { mOwner = nullptr; @@ -252,24 +240,17 @@ RespondWithHandler::ResolvedCallback(JSContext* aCx, JS::Handle aValu // security implications are not a complete disaster. if (response->Type() == ResponseType::Opaque && !worker->OpaqueInterceptionEnabled()) { - autoCancel.SetCancelStatus(NS_ERROR_OPAQUE_INTERCEPTION_DISABLED); return; } // Section 4.2, step 2.2 "If either response's type is "opaque" and request's // mode is not "no-cors" or response's type is error, return a network error." - if (response->Type() == ResponseType::Opaque && mRequestMode != RequestMode::No_cors) { - autoCancel.SetCancelStatus(NS_ERROR_BAD_OPAQUE_INTERCEPTION_REQUEST_MODE); - return; - } - - if (response->Type() == ResponseType::Error) { - autoCancel.SetCancelStatus(NS_ERROR_INTERCEPTED_ERROR_RESPONSE); + if (((response->Type() == ResponseType::Opaque) && (mRequestMode != RequestMode::No_cors)) || + response->Type() == ResponseType::Error) { return; } if (NS_WARN_IF(response->BodyUsed())) { - autoCancel.SetCancelStatus(NS_ERROR_INTERCEPTED_USED_RESPONSE); return; } @@ -315,14 +296,13 @@ RespondWithHandler::ResolvedCallback(JSContext* aCx, JS::Handle aValu void RespondWithHandler::RejectedCallback(JSContext* aCx, JS::Handle aValue) { - CancelRequest(NS_ERROR_INTERCEPTION_FAILED); + CancelRequest(); } void -RespondWithHandler::CancelRequest(nsresult aStatus) +RespondWithHandler::CancelRequest() { - nsCOMPtr runnable = - new CancelChannelRunnable(mInterceptedChannel, aStatus); + nsCOMPtr runnable = new CancelChannelRunnable(mInterceptedChannel); NS_DispatchToMainThread(runnable); } diff --git a/modules/libjar/InterceptedJARChannel.cpp b/modules/libjar/InterceptedJARChannel.cpp index ef2cdb7568e..85efe3666fa 100644 --- a/modules/libjar/InterceptedJARChannel.cpp +++ b/modules/libjar/InterceptedJARChannel.cpp @@ -89,15 +89,13 @@ InterceptedJARChannel::FinishSynthesizedResponse() } NS_IMETHODIMP -InterceptedJARChannel::Cancel(nsresult aStatus) +InterceptedJARChannel::Cancel() { - MOZ_ASSERT(NS_FAILED(aStatus)); - if (!mChannel) { return NS_ERROR_FAILURE; } - nsresult rv = mChannel->Cancel(aStatus); + nsresult rv = mChannel->Cancel(NS_BINDING_ABORTED); NS_ENSURE_SUCCESS(rv, rv); mResponseBody = nullptr; mChannel = nullptr; diff --git a/netwerk/base/nsINetworkInterceptController.idl b/netwerk/base/nsINetworkInterceptController.idl index a5f41b96f33..a816931ae48 100644 --- a/netwerk/base/nsINetworkInterceptController.idl +++ b/netwerk/base/nsINetworkInterceptController.idl @@ -26,7 +26,7 @@ class ChannelInfo; * which do not implement nsIChannel. */ -[scriptable, uuid(1062c96a-d73c-4ad5-beb7-6e803e414973)] +[scriptable, uuid(f2c07a6b-366d-4ef4-85ab-a77f4bcb1646)] interface nsIInterceptedChannel : nsISupports { /** @@ -59,7 +59,7 @@ interface nsIInterceptedChannel : nsISupports * @return NS_ERROR_FAILURE if the response has already been synthesized or * the original request has been instructed to continue. */ - void cancel(in nsresult status); + void cancel(); /** * The synthesized response body to be produced. diff --git a/netwerk/protocol/http/HttpChannelParent.cpp b/netwerk/protocol/http/HttpChannelParent.cpp index f1f55b3e8ea..17281bd17cc 100644 --- a/netwerk/protocol/http/HttpChannelParent.cpp +++ b/netwerk/protocol/http/HttpChannelParent.cpp @@ -98,7 +98,7 @@ HttpChannelParent::ActorDestroy(ActorDestroyReason why) // If this is an intercepted channel, we need to make sure that any resources are // cleaned up to avoid leaks. if (mInterceptedChannel) { - mInterceptedChannel->Cancel(NS_ERROR_INTERCEPTION_FAILED); + mInterceptedChannel->Cancel(); mInterceptedChannel = nullptr; } } diff --git a/netwerk/protocol/http/InterceptedChannel.cpp b/netwerk/protocol/http/InterceptedChannel.cpp index 9a7918e2d46..1933f9f1ce1 100644 --- a/netwerk/protocol/http/InterceptedChannel.cpp +++ b/netwerk/protocol/http/InterceptedChannel.cpp @@ -230,17 +230,15 @@ InterceptedChannelChrome::FinishSynthesizedResponse() } NS_IMETHODIMP -InterceptedChannelChrome::Cancel(nsresult aStatus) +InterceptedChannelChrome::Cancel() { - MOZ_ASSERT(NS_FAILED(aStatus)); - if (!mChannel) { return NS_ERROR_FAILURE; } // we need to use AsyncAbort instead of Cancel since there's no active pump // to cancel which will provide OnStart/OnStopRequest to the channel. - nsresult rv = mChannel->AsyncAbort(aStatus); + nsresult rv = mChannel->AsyncAbort(NS_BINDING_ABORTED); NS_ENSURE_SUCCESS(rv, rv); return NS_OK; } @@ -337,17 +335,15 @@ InterceptedChannelContent::FinishSynthesizedResponse() } NS_IMETHODIMP -InterceptedChannelContent::Cancel(nsresult aStatus) +InterceptedChannelContent::Cancel() { - MOZ_ASSERT(NS_FAILED(aStatus)); - if (!mChannel) { return NS_ERROR_FAILURE; } // we need to use AsyncAbort instead of Cancel since there's no active pump // to cancel which will provide OnStart/OnStopRequest to the channel. - nsresult rv = mChannel->AsyncAbort(aStatus); + nsresult rv = mChannel->AsyncAbort(NS_BINDING_ABORTED); NS_ENSURE_SUCCESS(rv, rv); mChannel = nullptr; mStreamListener = nullptr; diff --git a/netwerk/protocol/http/InterceptedChannel.h b/netwerk/protocol/http/InterceptedChannel.h index 0032e11c7c6..0131633be25 100644 --- a/netwerk/protocol/http/InterceptedChannel.h +++ b/netwerk/protocol/http/InterceptedChannel.h @@ -81,7 +81,7 @@ public: 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; - NS_IMETHOD Cancel(nsresult aStatus) override; + NS_IMETHOD Cancel() override; NS_IMETHOD SetChannelInfo(mozilla::dom::ChannelInfo* aChannelInfo) override; virtual void NotifyController() override; @@ -108,7 +108,7 @@ public: 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; - NS_IMETHOD Cancel(nsresult aStatus) override; + NS_IMETHOD Cancel() override; NS_IMETHOD SetChannelInfo(mozilla::dom::ChannelInfo* aChannelInfo) override; virtual void NotifyController() override; diff --git a/xpcom/base/ErrorList.h b/xpcom/base/ErrorList.h index 13a42de1990..22319bd5cfe 100644 --- a/xpcom/base/ErrorList.h +++ b/xpcom/base/ErrorList.h @@ -318,19 +318,6 @@ ERROR(NS_NET_STATUS_SENDING_TO, FAILURE(5)), ERROR(NS_NET_STATUS_WAITING_FOR, FAILURE(10)), ERROR(NS_NET_STATUS_RECEIVING_FROM, FAILURE(6)), - - /* nsIInterceptedChannel */ - /* Generic error for non-specific failures during service worker interception */ - ERROR(NS_ERROR_INTERCEPTION_FAILED, FAILURE(100)), - /* Service worker intercepted with an opaque response while - dom.serviceWorkers.interception.opaque.enabled pref was set to false */ - ERROR(NS_ERROR_OPAQUE_INTERCEPTION_DISABLED, FAILURE(101)), - /* Attempt to return opaque response for anything but "non-cors" request */ - ERROR(NS_ERROR_BAD_OPAQUE_INTERCEPTION_REQUEST_MODE, FAILURE(102)), - /* Service worker intercepted with an error response */ - ERROR(NS_ERROR_INTERCEPTED_ERROR_RESPONSE, FAILURE(103)), - /* Service worker intercepted with a response with bodyUsed set to true */ - ERROR(NS_ERROR_INTERCEPTED_USED_RESPONSE, FAILURE(104)), #undef MODULE