WebKit Bugzilla
Attachment 341923 Details for
Bug 186156
: Update Fetch code to provide more useful exception messages
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-186156-20180604152627.patch (text/plain), 39.68 KB, created by
Chris Dumez
on 2018-06-04 15:26:27 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Chris Dumez
Created:
2018-06-04 15:26:27 PDT
Size:
39.68 KB
patch
obsolete
>Subversion Revision: 232471 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index 92b4957be8f6e0cc07b9899dada78676a1605c59..2399fd484ca48b704d7a5ab5c85fd0fba1ffb9b5 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,34 @@ >+2018-06-04 Chris Dumez <cdumez@apple.com> >+ >+ Update Fetch code to provide more useful exception messages >+ https://bugs.webkit.org/show_bug.cgi?id=186156 >+ >+ Reviewed by Youenn Fablet. >+ >+ Provide more useful error messages in our Loading / Fetch code. >+ >+ * Modules/fetch/FetchBodyOwner.cpp: >+ (WebCore::FetchBodyOwner::arrayBuffer): >+ (WebCore::FetchBodyOwner::blob): >+ (WebCore::FetchBodyOwner::consumeOnceLoadingFinished): >+ (WebCore::FetchBodyOwner::formData): >+ (WebCore::FetchBodyOwner::json): >+ (WebCore::FetchBodyOwner::text): >+ * Modules/fetch/FetchHeaders.cpp: >+ (WebCore::canWriteHeader): >+ (WebCore::FetchHeaders::get const): >+ (WebCore::FetchHeaders::has const): >+ * Modules/fetch/FetchRequest.cpp: >+ (WebCore::FetchRequest::setBody): >+ (WebCore::FetchRequest::clone): >+ * Modules/fetch/FetchResponse.cpp: >+ (WebCore::FetchResponse::redirect): >+ (WebCore::FetchResponse::clone): >+ * workers/service/context/ServiceWorkerFetch.cpp: >+ (WebCore::ServiceWorkerFetch::processResponse): >+ (WebCore::ServiceWorkerFetch::dispatchFetchEvent): >+ * workers/service/context/ServiceWorkerFetch.h: >+ > 2018-06-04 Youenn Fablet <youenn@apple.com> > > [WK1] Add an option to restrict communication to localhost sockets >diff --git a/Source/WebKit/ChangeLog b/Source/WebKit/ChangeLog >index 9aff6c73dab5d3ffc9765174f511970345630ac1..cbb5d42b4369b5991538ad478792a0515266a7ae 100644 >--- a/Source/WebKit/ChangeLog >+++ b/Source/WebKit/ChangeLog >@@ -1,3 +1,29 @@ >+2018-06-04 Chris Dumez <cdumez@apple.com> >+ >+ Update Fetch code to provide more useful exception messages >+ https://bugs.webkit.org/show_bug.cgi?id=186156 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Provide more useful error messages in our Loading / Fetch code. >+ >+ * StorageProcess/ServiceWorker/WebSWServerConnection.cpp: >+ (WebKit::WebSWServerConnection::didFailFetch): >+ * StorageProcess/ServiceWorker/WebSWServerConnection.h: >+ * StorageProcess/StorageProcess.cpp: >+ (WebKit::StorageProcess::didFailFetch): >+ * StorageProcess/StorageProcess.h: >+ * StorageProcess/StorageProcess.messages.in: >+ * WebProcess/Storage/ServiceWorkerClientFetch.cpp: >+ (WebKit::ServiceWorkerClientFetch::didFail): >+ (WebKit::ServiceWorkerClientFetch::continueLoadingAfterCheckingResponse): >+ * WebProcess/Storage/ServiceWorkerClientFetch.h: >+ * WebProcess/Storage/ServiceWorkerClientFetch.messages.in: >+ * WebProcess/Storage/WebServiceWorkerFetchTaskClient.cpp: >+ (WebKit::WebServiceWorkerFetchTaskClient::didReceiveFormDataAndFinish): >+ (WebKit::WebServiceWorkerFetchTaskClient::didFail): >+ * WebProcess/Storage/WebServiceWorkerFetchTaskClient.h: >+ > 2018-06-04 Jeremy Jones <jeremyj@apple.com> > > Disable keyboard in fullscreen ios. >diff --git a/Source/WebCore/Modules/fetch/FetchBodyOwner.cpp b/Source/WebCore/Modules/fetch/FetchBodyOwner.cpp >index 5bba140aeb3767c2826a72c847d7eb180eafafba..dc16155e117bb820b029923bd2807ba984dc77af 100644 >--- a/Source/WebCore/Modules/fetch/FetchBodyOwner.cpp >+++ b/Source/WebCore/Modules/fetch/FetchBodyOwner.cpp >@@ -98,7 +98,7 @@ void FetchBodyOwner::arrayBuffer(Ref<DeferredPromise>&& promise) > return; > } > if (isDisturbedOrLocked()) { >- promise->reject(TypeError); >+ promise->reject(Exception { TypeError, ASCIILiteral("Body is disturbed or locked") }); > return; > } > m_isDisturbed = true; >@@ -112,7 +112,7 @@ void FetchBodyOwner::blob(Ref<DeferredPromise>&& promise) > return; > } > if (isDisturbedOrLocked()) { >- promise->reject(TypeError); >+ promise->reject(Exception { TypeError, ASCIILiteral("Body is disturbed or locked") }); > return; > } > m_isDisturbed = true; >@@ -146,7 +146,7 @@ void FetchBodyOwner::updateContentType() > void FetchBodyOwner::consumeOnceLoadingFinished(FetchBodyConsumer::Type type, Ref<DeferredPromise>&& promise) > { > if (isDisturbedOrLocked()) { >- promise->reject(TypeError); >+ promise->reject(Exception { TypeError, ASCIILiteral("Body is disturbed or locked") }); > return; > } > m_isDisturbed = true; >@@ -160,7 +160,7 @@ void FetchBodyOwner::formData(Ref<DeferredPromise>&& promise) > return; > } > if (isDisturbedOrLocked()) { >- promise->reject(TypeError); >+ promise->reject(Exception { TypeError, ASCIILiteral("Body is disturbed or locked") }); > return; > } > m_isDisturbed = true; >@@ -174,7 +174,7 @@ void FetchBodyOwner::json(Ref<DeferredPromise>&& promise) > return; > } > if (isDisturbedOrLocked()) { >- promise->reject(TypeError); >+ promise->reject(Exception { TypeError, ASCIILiteral("Body is disturbed or locked") }); > return; > } > m_isDisturbed = true; >@@ -188,7 +188,7 @@ void FetchBodyOwner::text(Ref<DeferredPromise>&& promise) > return; > } > if (isDisturbedOrLocked()) { >- promise->reject(TypeError); >+ promise->reject(Exception { TypeError, ASCIILiteral("Body is disturbed or locked") }); > return; > } > m_isDisturbed = true; >diff --git a/Source/WebCore/Modules/fetch/FetchHeaders.cpp b/Source/WebCore/Modules/fetch/FetchHeaders.cpp >index c40cdd09a2f31984968076e60288382591f25564..d772fd0a3b591cb1d897d3e4fa2099d947b35906 100644 >--- a/Source/WebCore/Modules/fetch/FetchHeaders.cpp >+++ b/Source/WebCore/Modules/fetch/FetchHeaders.cpp >@@ -35,10 +35,12 @@ namespace WebCore { > > static ExceptionOr<bool> canWriteHeader(const String& name, const String& value, FetchHeaders::Guard guard) > { >- if (!isValidHTTPToken(name) || !isValidHTTPHeaderValue(value)) >- return Exception { TypeError }; >+ if (!isValidHTTPToken(name)) >+ return Exception { TypeError, makeString("Invalid header name: '", name, "'") }; >+ if (!isValidHTTPHeaderValue(value)) >+ return Exception { TypeError, makeString("Header '", name, "' has invalid value: '", value, "'") }; > if (guard == FetchHeaders::Guard::Immutable) >- return Exception { TypeError }; >+ return Exception { TypeError, ASCIILiteral("Headers object's guard is 'immutable'") }; > if (guard == FetchHeaders::Guard::Request && isForbiddenHeaderName(name)) > return false; > if (guard == FetchHeaders::Guard::RequestNoCors && !isSimpleHeader(name, value)) >@@ -146,14 +148,14 @@ ExceptionOr<void> FetchHeaders::remove(const String& name) > ExceptionOr<String> FetchHeaders::get(const String& name) const > { > if (!isValidHTTPToken(name)) >- return Exception { TypeError }; >+ return Exception { TypeError, makeString("Invalid header name: '", name, "'") }; > return m_headers.get(name); > } > > ExceptionOr<bool> FetchHeaders::has(const String& name) const > { > if (!isValidHTTPToken(name)) >- return Exception { TypeError }; >+ return Exception { TypeError, makeString("Invalid header name: '", name, "'") }; > return m_headers.contains(name); > } > >diff --git a/Source/WebCore/Modules/fetch/FetchRequest.cpp b/Source/WebCore/Modules/fetch/FetchRequest.cpp >index b3b7cde911ef718bca15a4b4e194cf2fd9c88565..8af9965acb5ccd08b8a45d473db415a3ca26a729 100644 >--- a/Source/WebCore/Modules/fetch/FetchRequest.cpp >+++ b/Source/WebCore/Modules/fetch/FetchRequest.cpp >@@ -217,7 +217,7 @@ ExceptionOr<void> FetchRequest::initializeWith(FetchRequest& input, Init&& init) > ExceptionOr<void> FetchRequest::setBody(FetchBody::Init&& body) > { > if (!methodCanHaveBody(m_request)) >- return Exception { TypeError }; >+ return Exception { TypeError, makeString("Request has method '", m_request.httpMethod(), "' and cannot have a body") }; > > ASSERT(scriptExecutionContext()); > extractBody(*scriptExecutionContext(), WTFMove(body)); >@@ -231,7 +231,7 @@ ExceptionOr<void> FetchRequest::setBody(FetchRequest& request) > { > if (!request.isBodyNull()) { > if (!methodCanHaveBody(m_request)) >- return Exception { TypeError }; >+ return Exception { TypeError, makeString("Request has method '", m_request.httpMethod(), "' and cannot have a body") }; > // FIXME: If body has a readable stream, we should pipe it to this new body stream. > m_body = WTFMove(request.m_body); > request.setDisturbed(); >@@ -291,7 +291,7 @@ ResourceRequest FetchRequest::resourceRequest() const > ExceptionOr<Ref<FetchRequest>> FetchRequest::clone(ScriptExecutionContext& context) > { > if (isDisturbedOrLocked()) >- return Exception { TypeError }; >+ return Exception { TypeError, ASCIILiteral("Body is disturbed or locked") }; > > auto clone = adoptRef(*new FetchRequest(context, std::nullopt, FetchHeaders::create(m_headers.get()), ResourceRequest { m_request }, FetchOptions { m_options}, String { m_referrer })); > clone->cloneBody(*this); >diff --git a/Source/WebCore/Modules/fetch/FetchResponse.cpp b/Source/WebCore/Modules/fetch/FetchResponse.cpp >index d96c7bb8696b600d7d15fb543c25d88b113ce530..f927880beb5bddcc8edc037318ab0fe8d169737d 100644 >--- a/Source/WebCore/Modules/fetch/FetchResponse.cpp >+++ b/Source/WebCore/Modules/fetch/FetchResponse.cpp >@@ -36,6 +36,7 @@ > #include "ReadableStreamSink.h" > #include "ResourceError.h" > #include "ScriptExecutionContext.h" >+#include <wtf/text/StringConcatenateNumbers.h> > > namespace WebCore { > >@@ -143,10 +144,12 @@ ExceptionOr<Ref<FetchResponse>> FetchResponse::redirect(ScriptExecutionContext& > { > // FIXME: Tighten the URL parsing algorithm according https://url.spec.whatwg.org/#concept-url-parser. > URL requestURL = context.completeURL(url); >- if (!requestURL.isValid() || !requestURL.user().isEmpty() || !requestURL.pass().isEmpty()) >- return Exception { TypeError }; >+ if (!requestURL.isValid()) >+ return Exception { TypeError, makeString("Redirection URL '", requestURL.string(), "' is invalid") }; >+ if (!requestURL.user().isEmpty() || !requestURL.pass().isEmpty()) >+ return Exception { TypeError, ASCIILiteral("Redirection URL contains credentials") }; > if (!ResourceResponse::isRedirectionStatusCode(status)) >- return Exception { RangeError }; >+ return Exception { RangeError, makeString("Status code ", status, "is not a redirection status code") }; > auto redirectResponse = adoptRef(*new FetchResponse(context, { }, FetchHeaders::create(FetchHeaders::Guard::Immutable), { })); > redirectResponse->m_internalResponse.setHTTPStatusCode(status); > redirectResponse->m_internalResponse.setHTTPHeaderField(HTTPHeaderName::Location, requestURL.string()); >@@ -163,7 +166,7 @@ FetchResponse::FetchResponse(ScriptExecutionContext& context, std::optional<Fetc > ExceptionOr<Ref<FetchResponse>> FetchResponse::clone(ScriptExecutionContext& context) > { > if (isDisturbedOrLocked()) >- return Exception { TypeError }; >+ return Exception { TypeError, ASCIILiteral("Body is disturbed or locked") }; > > ASSERT(scriptExecutionContext()); > >diff --git a/Source/WebCore/workers/service/context/ServiceWorkerFetch.cpp b/Source/WebCore/workers/service/context/ServiceWorkerFetch.cpp >index b1525b9babdce2022afa0f1ae1605995fdfd41a9..63be95c8a61b5239ef9b39f766f00a1d5de61093 100644 >--- a/Source/WebCore/workers/service/context/ServiceWorkerFetch.cpp >+++ b/Source/WebCore/workers/service/context/ServiceWorkerFetch.cpp >@@ -46,7 +46,7 @@ namespace ServiceWorkerFetch { > static void processResponse(Ref<Client>&& client, FetchResponse* response) > { > if (!response) { >- client->didFail(); >+ client->didFail(ResourceError { errorDomainWebKitInternal, 0, URL(), ASCIILiteral("Response is null") }); > return; > } > auto protectedResponse = makeRef(*response); >@@ -54,14 +54,14 @@ static void processResponse(Ref<Client>&& client, FetchResponse* response) > client->didReceiveResponse(response->resourceResponse()); > > if (response->loadingError()) { >- client->didFail(); >+ client->didFail(*response->loadingError()); > return; > } > > if (response->isBodyReceivedByChunk()) { > response->consumeBodyReceivedByChunk([client = WTFMove(client)] (auto&& result) mutable { > if (result.hasException()) { >- client->didFail(); >+ client->didFail(ResourceError { errorDomainWebKitInternal, 0, URL(), result.exception().message() }); > return; > } > >@@ -108,6 +108,7 @@ void dispatchFetchEvent(Ref<Client>&& client, ServiceWorkerGlobalScope& globalSc > if (isNavigation) > options.redirect = FetchOptions::Redirect::Manual; > >+ URL requestURL = request.url(); > auto fetchRequest = FetchRequest::create(globalScope, WTFMove(body), WTFMove(requestHeaders), WTFMove(request), WTFMove(options), WTFMove(referrer)); > > FetchEvent::Init init; >@@ -129,7 +130,7 @@ void dispatchFetchEvent(Ref<Client>&& client, ServiceWorkerGlobalScope& globalSc > > if (!event->respondWithEntered()) { > if (event->defaultPrevented()) { >- client->didFail(); >+ client->didFail(ResourceError { errorDomainWebKitInternal, 0, requestURL, ASCIILiteral("Fetch event was canceled") }); > return; > } > client->didNotHandle(); >diff --git a/Source/WebCore/workers/service/context/ServiceWorkerFetch.h b/Source/WebCore/workers/service/context/ServiceWorkerFetch.h >index c540388b45d7c45387b1442bbfb02fa0e9182549..861228ce2f241802ab71258db5b1e7274a9c0251 100644 >--- a/Source/WebCore/workers/service/context/ServiceWorkerFetch.h >+++ b/Source/WebCore/workers/service/context/ServiceWorkerFetch.h >@@ -35,6 +35,7 @@ class FetchEvent; > struct FetchOptions; > class FetchResponse; > class FormData; >+class ResourceError; > class ResourceRequest; > class ResourceResponse; > struct ServiceWorkerClientIdentifier; >@@ -50,7 +51,7 @@ public: > virtual void didReceiveResponse(const ResourceResponse&) = 0; > virtual void didReceiveData(Ref<SharedBuffer>&&) = 0; > virtual void didReceiveFormDataAndFinish(Ref<FormData>&&) = 0; >- virtual void didFail() = 0; >+ virtual void didFail(const ResourceError&) = 0; > virtual void didFinish() = 0; > virtual void didNotHandle() = 0; > virtual void cancel() = 0; >diff --git a/Source/WebKit/StorageProcess/ServiceWorker/WebSWServerConnection.cpp b/Source/WebKit/StorageProcess/ServiceWorker/WebSWServerConnection.cpp >index d9a513820cd595d112a7aab0f996070464cf1984..a941843d4f8b19e7e7becdaa54054ce33bebcee2 100644 >--- a/Source/WebKit/StorageProcess/ServiceWorker/WebSWServerConnection.cpp >+++ b/Source/WebKit/StorageProcess/ServiceWorker/WebSWServerConnection.cpp >@@ -256,10 +256,10 @@ void WebSWServerConnection::didFinishFetch(FetchIdentifier fetchIdentifier) > m_contentConnection->send(Messages::ServiceWorkerClientFetch::DidFinish { }, fetchIdentifier.toUInt64()); > } > >-void WebSWServerConnection::didFailFetch(FetchIdentifier fetchIdentifier) >+void WebSWServerConnection::didFailFetch(FetchIdentifier fetchIdentifier, const ResourceError& error) > { > SWSERVERCONNECTION_RELEASE_LOG_ERROR_IF_ALLOWED("didFailFetch: fetchIdentifier: %s", fetchIdentifier.loggingString().utf8().data()); >- m_contentConnection->send(Messages::ServiceWorkerClientFetch::DidFail { }, fetchIdentifier.toUInt64()); >+ m_contentConnection->send(Messages::ServiceWorkerClientFetch::DidFail { error }, fetchIdentifier.toUInt64()); > } > > void WebSWServerConnection::didNotHandleFetch(FetchIdentifier fetchIdentifier) >diff --git a/Source/WebKit/StorageProcess/ServiceWorker/WebSWServerConnection.h b/Source/WebKit/StorageProcess/ServiceWorker/WebSWServerConnection.h >index f4ccb6b99181cc5f5d53a1baaa274a43c301b243..9cf90464f1516f6a1fc8af18cb81368ce65d9809 100644 >--- a/Source/WebKit/StorageProcess/ServiceWorker/WebSWServerConnection.h >+++ b/Source/WebKit/StorageProcess/ServiceWorker/WebSWServerConnection.h >@@ -66,7 +66,7 @@ public: > void didReceiveFetchData(WebCore::FetchIdentifier, const IPC::DataReference&, int64_t encodedDataLength); > void didReceiveFetchFormData(WebCore::FetchIdentifier, const IPC::FormDataReference&); > void didFinishFetch(WebCore::FetchIdentifier); >- void didFailFetch(WebCore::FetchIdentifier); >+ void didFailFetch(WebCore::FetchIdentifier, const WebCore::ResourceError&); > void didNotHandleFetch(WebCore::FetchIdentifier); > > void postMessageToServiceWorkerClient(WebCore::DocumentIdentifier destinationContextIdentifier, WebCore::MessageWithMessagePorts&&, WebCore::ServiceWorkerIdentifier sourceServiceWorkerIdentifier, const String& sourceOrigin); >diff --git a/Source/WebKit/StorageProcess/StorageProcess.cpp b/Source/WebKit/StorageProcess/StorageProcess.cpp >index a7903156b0b29aa38e7e6668992b8ab457b0e5fa..19e4be649536f77904511b87bc617cef934b8d20 100644 >--- a/Source/WebKit/StorageProcess/StorageProcess.cpp >+++ b/Source/WebKit/StorageProcess/StorageProcess.cpp >@@ -473,10 +473,10 @@ void StorageProcess::createServerToContextConnection(const SecurityOriginData& s > parentProcessConnection()->send(Messages::StorageProcessProxy::EstablishWorkerContextConnectionToStorageProcess(securityOrigin), 0); > } > >-void StorageProcess::didFailFetch(SWServerConnectionIdentifier serverConnectionIdentifier, FetchIdentifier fetchIdentifier) >+void StorageProcess::didFailFetch(SWServerConnectionIdentifier serverConnectionIdentifier, FetchIdentifier fetchIdentifier, const ResourceError& error) > { > if (auto* connection = m_swServerConnections.get(serverConnectionIdentifier)) >- connection->didFailFetch(fetchIdentifier); >+ connection->didFailFetch(fetchIdentifier, error); > } > > void StorageProcess::didNotHandleFetch(SWServerConnectionIdentifier serverConnectionIdentifier, FetchIdentifier fetchIdentifier) >diff --git a/Source/WebKit/StorageProcess/StorageProcess.h b/Source/WebKit/StorageProcess/StorageProcess.h >index ab1bb2e097876ee8132636d0a83ccb6561309e30..298390b3d8ac4fd69bdf870487622f1dca4cb194 100644 >--- a/Source/WebKit/StorageProcess/StorageProcess.h >+++ b/Source/WebKit/StorageProcess/StorageProcess.h >@@ -43,6 +43,7 @@ class FormDataReference; > } > > namespace WebCore { >+class ResourceError; > class SWServer; > class ServiceWorkerRegistrationKey; > struct MessageWithMessagePorts; >@@ -141,7 +142,7 @@ private: > void didReceiveFetchData(WebCore::SWServerConnectionIdentifier, WebCore::FetchIdentifier, const IPC::DataReference&, int64_t encodedDataLength); > void didReceiveFetchFormData(WebCore::SWServerConnectionIdentifier, WebCore::FetchIdentifier, const IPC::FormDataReference&); > void didFinishFetch(WebCore::SWServerConnectionIdentifier, WebCore::FetchIdentifier); >- void didFailFetch(WebCore::SWServerConnectionIdentifier, WebCore::FetchIdentifier); >+ void didFailFetch(WebCore::SWServerConnectionIdentifier, WebCore::FetchIdentifier, const WebCore::ResourceError&); > void didNotHandleFetch(WebCore::SWServerConnectionIdentifier, WebCore::FetchIdentifier); > > void postMessageToServiceWorkerClient(const WebCore::ServiceWorkerClientIdentifier& destinationIdentifier, WebCore::MessageWithMessagePorts&&, WebCore::ServiceWorkerIdentifier sourceIdentifier, const String& sourceOrigin); >diff --git a/Source/WebKit/StorageProcess/StorageProcess.messages.in b/Source/WebKit/StorageProcess/StorageProcess.messages.in >index 31a0507884f82de8a916648ab69612e361d1577b..8190be31371faa7fe64f182f3e3d8611025098fc 100644 >--- a/Source/WebKit/StorageProcess/StorageProcess.messages.in >+++ b/Source/WebKit/StorageProcess/StorageProcess.messages.in >@@ -39,7 +39,7 @@ messages -> StorageProcess LegacyReceiver { > > #if ENABLE(SERVICE_WORKER) > DidNotHandleFetch(WebCore::SWServerConnectionIdentifier serverConnectionIdentifier, WebCore::FetchIdentifier fetchIdentifier) >- DidFailFetch(WebCore::SWServerConnectionIdentifier serverConnectionIdentifier, WebCore::FetchIdentifier fetchIdentifier) >+ DidFailFetch(WebCore::SWServerConnectionIdentifier serverConnectionIdentifier, WebCore::FetchIdentifier fetchIdentifier, WebCore::ResourceError error) > DidReceiveFetchResponse(WebCore::SWServerConnectionIdentifier serverConnectionIdentifier, WebCore::FetchIdentifier fetchIdentifier, WebCore::ResourceResponse response) > DidReceiveFetchData(WebCore::SWServerConnectionIdentifier serverConnectionIdentifier, WebCore::FetchIdentifier fetchIdentifier, IPC::DataReference data, int64_t encodedDataLength) > DidReceiveFetchFormData(WebCore::SWServerConnectionIdentifier serverConnectionIdentifier, WebCore::FetchIdentifier fetchIdentifier, IPC::FormDataReference data) >diff --git a/Source/WebKit/WebProcess/Storage/ServiceWorkerClientFetch.cpp b/Source/WebKit/WebProcess/Storage/ServiceWorkerClientFetch.cpp >index 1397deab38e63d4ab8986daf4619264ccc9de9b4..a80a8801b64ebc38c9d5f48b8bcad5efb9b8671a 100644 >--- a/Source/WebKit/WebProcess/Storage/ServiceWorkerClientFetch.cpp >+++ b/Source/WebKit/WebProcess/Storage/ServiceWorkerClientFetch.cpp >@@ -221,9 +221,10 @@ void ServiceWorkerClientFetch::didFinish() > }); > } > >-void ServiceWorkerClientFetch::didFail() >+void ServiceWorkerClientFetch::didFail(ResourceError&& error) > { > m_didFail = true; >+ m_error = WTFMove(error); > > if (m_isCheckingResponse) > return; >@@ -232,7 +233,7 @@ void ServiceWorkerClientFetch::didFail() > if (!m_loader) > return; > >- m_loader->didFail({ ResourceError::Type::General }); >+ m_loader->didFail(m_error); > > if (auto callback = WTFMove(m_callback)) > callback(Result::Succeeded); >@@ -285,7 +286,7 @@ void ServiceWorkerClientFetch::continueLoadingAfterCheckingResponse() > } > > if (m_didFail) { >- didFail(); >+ didFail(WTFMove(m_error)); > return; > } > >diff --git a/Source/WebKit/WebProcess/Storage/ServiceWorkerClientFetch.h b/Source/WebKit/WebProcess/Storage/ServiceWorkerClientFetch.h >index 7d6df82bb300fe581065d4735bba9c4c06e93041..aec641e97b8a7cd79fea60c421b717ea565e67fc 100644 >--- a/Source/WebKit/WebProcess/Storage/ServiceWorkerClientFetch.h >+++ b/Source/WebKit/WebProcess/Storage/ServiceWorkerClientFetch.h >@@ -32,6 +32,7 @@ > #include "MessageReceiver.h" > #include "MessageSender.h" > #include <WebCore/FetchIdentifier.h> >+#include <WebCore/ResourceError.h> > #include <WebCore/ResourceLoader.h> > #include <wtf/CompletionHandler.h> > >@@ -64,7 +65,7 @@ private: > void didReceiveData(const IPC::DataReference&, int64_t encodedDataLength); > void didReceiveFormData(const IPC::FormDataReference&); > void didFinish(); >- void didFail(); >+ void didFail(WebCore::ResourceError&&); > void didNotHandle(); > > void continueLoadingAfterCheckingResponse(); >@@ -82,6 +83,7 @@ private: > bool m_isCheckingResponse { false }; > bool m_didFinish { false }; > bool m_didFail { false }; >+ WebCore::ResourceError m_error; > > WebCore::ServiceWorkerRegistrationIdentifier m_serviceWorkerRegistrationIdentifier; > }; >diff --git a/Source/WebKit/WebProcess/Storage/ServiceWorkerClientFetch.messages.in b/Source/WebKit/WebProcess/Storage/ServiceWorkerClientFetch.messages.in >index ae44f5b26f1cdeb9f2e6eb1288404bce747d5cfb..e0153d36fc79f331c245cd1892b52224b67da1fc 100644 >--- a/Source/WebKit/WebProcess/Storage/ServiceWorkerClientFetch.messages.in >+++ b/Source/WebKit/WebProcess/Storage/ServiceWorkerClientFetch.messages.in >@@ -27,7 +27,7 @@ messages -> ServiceWorkerClientFetch { > DidReceiveData(IPC::DataReference data, int64_t encodedDataLength) > DidReceiveFormData(IPC::FormDataReference data) > DidFinish() >- DidFail() >+ DidFail(WebCore::ResourceError error) > DidNotHandle() > } > >diff --git a/Source/WebKit/WebProcess/Storage/WebServiceWorkerFetchTaskClient.cpp b/Source/WebKit/WebProcess/Storage/WebServiceWorkerFetchTaskClient.cpp >index 472db576d84d2e73f5e841eb39c6222cdfd01ec8..7a56812a052766b609115b95d7fdc041850c5a0f 100644 >--- a/Source/WebKit/WebProcess/Storage/WebServiceWorkerFetchTaskClient.cpp >+++ b/Source/WebKit/WebProcess/Storage/WebServiceWorkerFetchTaskClient.cpp >@@ -32,6 +32,8 @@ > #include "FormDataReference.h" > #include "StorageProcessMessages.h" > #include "WebCoreArgumentCoders.h" >+#include "WebErrors.h" >+#include <WebCore/ResourceError.h> > #include <WebCore/ResourceResponse.h> > #include <WebCore/SWContextManager.h> > #include <wtf/RunLoop.h> >@@ -85,7 +87,7 @@ void WebServiceWorkerFetchTaskClient::didReceiveFormDataAndFinish(Ref<FormData>& > callOnMainThread([this, protectedThis = makeRef(*this), blobURL = blobURL.isolatedCopy()] () { > auto* serviceWorkerThreadProxy = SWContextManager::singleton().serviceWorkerThreadProxy(m_serviceWorkerIdentifier); > if (!serviceWorkerThreadProxy) { >- didFail(); >+ didFail(internalError(blobURL)); > return; > } > >@@ -93,7 +95,7 @@ void WebServiceWorkerFetchTaskClient::didReceiveFormDataAndFinish(Ref<FormData>& > auto loader = serviceWorkerThreadProxy->createBlobLoader(*m_blobLoader, blobURL); > if (!loader) { > m_blobLoader = std::nullopt; >- didFail(); >+ didFail(internalError(blobURL)); > return; > } > >@@ -117,12 +119,12 @@ void WebServiceWorkerFetchTaskClient::didFinishBlobLoading() > std::exchange(m_blobLoader, std::nullopt); > } > >-void WebServiceWorkerFetchTaskClient::didFail() >+void WebServiceWorkerFetchTaskClient::didFail(const ResourceError& error) > { > if (!m_connection) > return; > >- m_connection->send(Messages::StorageProcess::DidFailFetch { m_serverConnectionIdentifier, m_fetchIdentifier }, 0); >+ m_connection->send(Messages::StorageProcess::DidFailFetch { m_serverConnectionIdentifier, m_fetchIdentifier, error }, 0); > > cleanup(); > } >diff --git a/Source/WebKit/WebProcess/Storage/WebServiceWorkerFetchTaskClient.h b/Source/WebKit/WebProcess/Storage/WebServiceWorkerFetchTaskClient.h >index 1a8daca78945a019047f0f8204169943481dddb6..36e05ac97b10241757acd7c4ea2555a13d8f5951 100644 >--- a/Source/WebKit/WebProcess/Storage/WebServiceWorkerFetchTaskClient.h >+++ b/Source/WebKit/WebProcess/Storage/WebServiceWorkerFetchTaskClient.h >@@ -51,7 +51,7 @@ private: > void didReceiveResponse(const WebCore::ResourceResponse&) final; > void didReceiveData(Ref<WebCore::SharedBuffer>&&) final; > void didReceiveFormDataAndFinish(Ref<WebCore::FormData>&&) final; >- void didFail() final; >+ void didFail(const WebCore::ResourceError&) final; > void didFinish() final; > void didNotHandle() final; > void cancel() final; >@@ -67,7 +67,7 @@ private: > // FetchLoaderClient API > void didReceiveResponse(const WebCore::ResourceResponse&) final { } > void didReceiveData(const char* data, size_t size) final { client->didReceiveBlobChunk(data, size); } >- void didFail(const WebCore::ResourceError&) final { client->didFail(); } >+ void didFail(const WebCore::ResourceError& error) final { client->didFail(error); } > void didSucceed() final { client->didFinishBlobLoading(); } > > Ref<WebServiceWorkerFetchTaskClient> client; >diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog >index 109d0e7df7db362f5af9baa45f4def299ec37340..53a52112fc74cc5fa987a84a1180d38c15524adc 100644 >--- a/LayoutTests/ChangeLog >+++ b/LayoutTests/ChangeLog >@@ -1,3 +1,14 @@ >+2018-06-04 Chris Dumez <cdumez@apple.com> >+ >+ Update Fetch code to provide more useful exception messages >+ https://bugs.webkit.org/show_bug.cgi?id=186156 >+ >+ Reviewed by Youenn Fablet. >+ >+ Rebaseline tests that have different output. >+ >+ * http/tests/workers/service/basic-fetch.https-expected.txt: >+ > 2018-06-04 Per Arne Vollan <pvollan@apple.com> > > Rebaseline editing/style/apply-style-iframe-crash.html on Windows. >diff --git a/LayoutTests/imported/w3c/ChangeLog b/LayoutTests/imported/w3c/ChangeLog >index 3c0a35c3f431d3a577b113e65e509e8367c971a8..b90285599aa4202af8bd782c5d40a0e87cfc913e 100644 >--- a/LayoutTests/imported/w3c/ChangeLog >+++ b/LayoutTests/imported/w3c/ChangeLog >@@ -1,3 +1,16 @@ >+2018-06-04 Chris Dumez <cdumez@apple.com> >+ >+ Update Fetch code to provide more useful exception messages >+ https://bugs.webkit.org/show_bug.cgi?id=186156 >+ >+ Reviewed by Youenn Fablet. >+ >+ Rebaseline tests that have different output. >+ >+ * web-platform-tests/fetch/api/headers/header-values-expected.txt: >+ * web-platform-tests/fetch/api/headers/header-values-normalize-expected.txt: >+ * web-platform-tests/service-workers/service-worker/fetch-event-network-error.https-expected.txt: >+ > 2018-06-04 Youenn Fablet <youenn@apple.com> > > NetworkCORSPreflightChecker should set the preflight request User-Agent header >diff --git a/LayoutTests/http/tests/workers/service/basic-fetch.https-expected.txt b/LayoutTests/http/tests/workers/service/basic-fetch.https-expected.txt >index 59749166e39ee3fa8adab199f3f80b1d44cc3863..d7e9471cc096bd8ca65a7630a571381e20a8062f 100644 >--- a/LayoutTests/http/tests/workers/service/basic-fetch.https-expected.txt >+++ b/LayoutTests/http/tests/workers/service/basic-fetch.https-expected.txt >@@ -1,3 +1,4 @@ >+CONSOLE MESSAGE: Fetch API cannot load https://127.0.0.1:8443/workers/service/resources/test5. > > test1 url: https://127.0.0.1:8443/workers/service/resources/test1 > test1 status code: 200 >diff --git a/LayoutTests/imported/w3c/web-platform-tests/fetch/api/headers/header-values-expected.txt b/LayoutTests/imported/w3c/web-platform-tests/fetch/api/headers/header-values-expected.txt >index 675a84494ae46acce8129a637d66e1e96469852d..0af148b89bbd01e1dae851ce68c72bb46cf4bbce 100644 >--- a/LayoutTests/imported/w3c/web-platform-tests/fetch/api/headers/header-values-expected.txt >+++ b/LayoutTests/imported/w3c/web-platform-tests/fetch/api/headers/header-values-expected.txt >@@ -6,5 +6,5 @@ PASS fetch() with value x%0Ax needs to throw > PASS XMLHttpRequest with value x%0Dx needs to throw > PASS fetch() with value x%0Dx needs to throw > FAIL XMLHttpRequest with all valid values The string did not match the expected pattern. >-FAIL fetch() with all valid values Type error >+FAIL fetch() with all valid values Header 'val0' has invalid value: 'xx' > >diff --git a/LayoutTests/imported/w3c/web-platform-tests/fetch/api/headers/header-values-normalize-expected.txt b/LayoutTests/imported/w3c/web-platform-tests/fetch/api/headers/header-values-normalize-expected.txt >index 1a63326ce295e59a3cf70f27328d207a2307d2ce..f1671060b6b6edd811190d3416494dcfde8d822d 100644 >--- a/LayoutTests/imported/w3c/web-platform-tests/fetch/api/headers/header-values-normalize-expected.txt >+++ b/LayoutTests/imported/w3c/web-platform-tests/fetch/api/headers/header-values-normalize-expected.txt >@@ -2,21 +2,21 @@ > PASS XMLHttpRequest with value %00 > PASS fetch() with value %00 > FAIL XMLHttpRequest with value %01 The string did not match the expected pattern. >-FAIL fetch() with value %01 promise_test: Unhandled rejection with value: object "TypeError: Type error" >+FAIL fetch() with value %01 promise_test: Unhandled rejection with value: object "TypeError: Header 'val1' has invalid value: ''" > FAIL XMLHttpRequest with value %02 The string did not match the expected pattern. >-FAIL fetch() with value %02 promise_test: Unhandled rejection with value: object "TypeError: Type error" >+FAIL fetch() with value %02 promise_test: Unhandled rejection with value: object "TypeError: Header 'val1' has invalid value: ''" > FAIL XMLHttpRequest with value %03 The string did not match the expected pattern. >-FAIL fetch() with value %03 promise_test: Unhandled rejection with value: object "TypeError: Type error" >+FAIL fetch() with value %03 promise_test: Unhandled rejection with value: object "TypeError: Header 'val1' has invalid value: ''" > FAIL XMLHttpRequest with value %04 The string did not match the expected pattern. >-FAIL fetch() with value %04 promise_test: Unhandled rejection with value: object "TypeError: Type error" >+FAIL fetch() with value %04 promise_test: Unhandled rejection with value: object "TypeError: Header 'val1' has invalid value: ''" > FAIL XMLHttpRequest with value %05 The string did not match the expected pattern. >-FAIL fetch() with value %05 promise_test: Unhandled rejection with value: object "TypeError: Type error" >+FAIL fetch() with value %05 promise_test: Unhandled rejection with value: object "TypeError: Header 'val1' has invalid value: ''" > FAIL XMLHttpRequest with value %06 The string did not match the expected pattern. >-FAIL fetch() with value %06 promise_test: Unhandled rejection with value: object "TypeError: Type error" >+FAIL fetch() with value %06 promise_test: Unhandled rejection with value: object "TypeError: Header 'val1' has invalid value: ''" > FAIL XMLHttpRequest with value %07 The string did not match the expected pattern. >-FAIL fetch() with value %07 promise_test: Unhandled rejection with value: object "TypeError: Type error" >+FAIL fetch() with value %07 promise_test: Unhandled rejection with value: object "TypeError: Header 'val1' has invalid value: ''" > FAIL XMLHttpRequest with value %08 The string did not match the expected pattern. >-FAIL fetch() with value %08 promise_test: Unhandled rejection with value: object "TypeError: Type error" >+FAIL fetch() with value %08 promise_test: Unhandled rejection with value: object "TypeError: Header 'val1' has invalid value: ''" > PASS XMLHttpRequest with value %09 > PASS fetch() with value %09 > PASS XMLHttpRequest with value %0A >@@ -24,41 +24,41 @@ PASS fetch() with value %0A > PASS XMLHttpRequest with value %0D > PASS fetch() with value %0D > FAIL XMLHttpRequest with value %0E The string did not match the expected pattern. >-FAIL fetch() with value %0E promise_test: Unhandled rejection with value: object "TypeError: Type error" >+FAIL fetch() with value %0E promise_test: Unhandled rejection with value: object "TypeError: Header 'val1' has invalid value: ''" > FAIL XMLHttpRequest with value %0F The string did not match the expected pattern. >-FAIL fetch() with value %0F promise_test: Unhandled rejection with value: object "TypeError: Type error" >+FAIL fetch() with value %0F promise_test: Unhandled rejection with value: object "TypeError: Header 'val1' has invalid value: ''" > FAIL XMLHttpRequest with value %10 The string did not match the expected pattern. >-FAIL fetch() with value %10 promise_test: Unhandled rejection with value: object "TypeError: Type error" >+FAIL fetch() with value %10 promise_test: Unhandled rejection with value: object "TypeError: Header 'val1' has invalid value: ''" > FAIL XMLHttpRequest with value %11 The string did not match the expected pattern. >-FAIL fetch() with value %11 promise_test: Unhandled rejection with value: object "TypeError: Type error" >+FAIL fetch() with value %11 promise_test: Unhandled rejection with value: object "TypeError: Header 'val1' has invalid value: ''" > FAIL XMLHttpRequest with value %12 The string did not match the expected pattern. >-FAIL fetch() with value %12 promise_test: Unhandled rejection with value: object "TypeError: Type error" >+FAIL fetch() with value %12 promise_test: Unhandled rejection with value: object "TypeError: Header 'val1' has invalid value: ''" > FAIL XMLHttpRequest with value %13 The string did not match the expected pattern. >-FAIL fetch() with value %13 promise_test: Unhandled rejection with value: object "TypeError: Type error" >+FAIL fetch() with value %13 promise_test: Unhandled rejection with value: object "TypeError: Header 'val1' has invalid value: ''" > FAIL XMLHttpRequest with value %14 The string did not match the expected pattern. >-FAIL fetch() with value %14 promise_test: Unhandled rejection with value: object "TypeError: Type error" >+FAIL fetch() with value %14 promise_test: Unhandled rejection with value: object "TypeError: Header 'val1' has invalid value: ''" > FAIL XMLHttpRequest with value %15 The string did not match the expected pattern. >-FAIL fetch() with value %15 promise_test: Unhandled rejection with value: object "TypeError: Type error" >+FAIL fetch() with value %15 promise_test: Unhandled rejection with value: object "TypeError: Header 'val1' has invalid value: ''" > FAIL XMLHttpRequest with value %16 The string did not match the expected pattern. >-FAIL fetch() with value %16 promise_test: Unhandled rejection with value: object "TypeError: Type error" >+FAIL fetch() with value %16 promise_test: Unhandled rejection with value: object "TypeError: Header 'val1' has invalid value: ''" > FAIL XMLHttpRequest with value %17 The string did not match the expected pattern. >-FAIL fetch() with value %17 promise_test: Unhandled rejection with value: object "TypeError: Type error" >+FAIL fetch() with value %17 promise_test: Unhandled rejection with value: object "TypeError: Header 'val1' has invalid value: ''" > FAIL XMLHttpRequest with value %18 The string did not match the expected pattern. >-FAIL fetch() with value %18 promise_test: Unhandled rejection with value: object "TypeError: Type error" >+FAIL fetch() with value %18 promise_test: Unhandled rejection with value: object "TypeError: Header 'val1' has invalid value: ''" > FAIL XMLHttpRequest with value %19 The string did not match the expected pattern. >-FAIL fetch() with value %19 promise_test: Unhandled rejection with value: object "TypeError: Type error" >+FAIL fetch() with value %19 promise_test: Unhandled rejection with value: object "TypeError: Header 'val1' has invalid value: ''" > FAIL XMLHttpRequest with value %1A The string did not match the expected pattern. >-FAIL fetch() with value %1A promise_test: Unhandled rejection with value: object "TypeError: Type error" >+FAIL fetch() with value %1A promise_test: Unhandled rejection with value: object "TypeError: Header 'val1' has invalid value: ''" > FAIL XMLHttpRequest with value %1B The string did not match the expected pattern. >-FAIL fetch() with value %1B promise_test: Unhandled rejection with value: object "TypeError: Type error" >+FAIL fetch() with value %1B promise_test: Unhandled rejection with value: object "TypeError: Header 'val1' has invalid value: ''" > FAIL XMLHttpRequest with value %1C The string did not match the expected pattern. >-FAIL fetch() with value %1C promise_test: Unhandled rejection with value: object "TypeError: Type error" >+FAIL fetch() with value %1C promise_test: Unhandled rejection with value: object "TypeError: Header 'val1' has invalid value: ''" > FAIL XMLHttpRequest with value %1D The string did not match the expected pattern. >-FAIL fetch() with value %1D promise_test: Unhandled rejection with value: object "TypeError: Type error" >+FAIL fetch() with value %1D promise_test: Unhandled rejection with value: object "TypeError: Header 'val1' has invalid value: ''" > FAIL XMLHttpRequest with value %1E The string did not match the expected pattern. >-FAIL fetch() with value %1E promise_test: Unhandled rejection with value: object "TypeError: Type error" >+FAIL fetch() with value %1E promise_test: Unhandled rejection with value: object "TypeError: Header 'val1' has invalid value: ''" > FAIL XMLHttpRequest with value %1F The string did not match the expected pattern. >-FAIL fetch() with value %1F promise_test: Unhandled rejection with value: object "TypeError: Type error" >+FAIL fetch() with value %1F promise_test: Unhandled rejection with value: object "TypeError: Header 'val1' has invalid value: ''" > PASS XMLHttpRequest with value %20 > PASS fetch() with value %20 > >diff --git a/LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/fetch-event-network-error.https-expected.txt b/LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/fetch-event-network-error.https-expected.txt >index b49143c0d3f6e4689d18d68640813cf8543adce4..a8b8aa21344defa04da22e3261fcc6577011c676 100644 >--- a/LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/fetch-event-network-error.https-expected.txt >+++ b/LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/fetch-event-network-error.https-expected.txt >@@ -1,3 +1,4 @@ >+CONSOLE MESSAGE: XMLHttpRequest cannot load https://localhost:9443/service-workers/service-worker/resources/fetch-event-network-error-controllee-iframe.html?prevent-default. > > PASS Rejecting the fetch event or using preventDefault() causes a network error >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 186156
:
341915
|
341920
|
341923
|
341928