Improve error messages in case FetchEvent.respondWith has a rejected promise
authoryouenn@apple.com <youenn@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 12 Jun 2018 02:37:17 +0000 (02:37 +0000)
committeryouenn@apple.com <youenn@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 12 Jun 2018 02:37:17 +0000 (02:37 +0000)
commit13c738a8b6be7b6982e9aa4ea8ffd43e143cdd17
tree559cfcb58b2b219f7e6ee68f4aa236306ca9cc45
parentc1b0db713fe8f1a043ebf822f556820c3ba09fbf
Improve error messages in case FetchEvent.respondWith has a rejected promise
https://bugs.webkit.org/show_bug.cgi?id=186368

Reviewed by Chris Dumez.

LayoutTests/imported/w3c:

* web-platform-tests/service-workers/service-worker/fetch-event-network-error.https-expected.txt:
* web-platform-tests/service-workers/service-worker/fetch-event-redirect.https-expected.txt:
* web-platform-tests/service-workers/service-worker/fetch-event-respond-with-argument.https-expected.txt:
* web-platform-tests/service-workers/service-worker/fetch-event-respond-with-response-body-with-invalid-chunk.https-expected.txt:
* web-platform-tests/service-workers/service-worker/fetch-frame-resource.https-expected.txt:
* web-platform-tests/service-workers/service-worker/fetch-mixed-content-to-inscope.https-expected.txt:
* web-platform-tests/service-workers/service-worker/fetch-mixed-content-to-outscope.https-expected.txt:
* web-platform-tests/service-workers/service-worker/fetch-request-css-images.https-expected.txt:
* web-platform-tests/service-workers/service-worker/fetch-request-resources.https-expected.txt:
* web-platform-tests/service-workers/service-worker/invalid-header.https-expected.txt:
* web-platform-tests/service-workers/service-worker/update-recovery.https-expected.txt:

Source/WebCore:

Covered by rebased tests.

Introduce a new error domain for service worker ResourceError.
Used this domain to log in the console any such error.

Update FetchEvent implementation to get meaningful error messages for respondWith error cases.
In particular, convert the rejected promise JS value as a string to populate the error message.

* loader/SubresourceLoader.cpp:
(WebCore::SubresourceLoader::didFail):
* platform/network/ResourceErrorBase.cpp:
* platform/network/ResourceErrorBase.h:
* testing/ServiceWorkerInternals.cpp:
(WebCore::ServiceWorkerInternals::waitForFetchEventToFinish):
* workers/service/FetchEvent.cpp:
(WebCore::FetchEvent::~FetchEvent):
(WebCore::FetchEvent::createResponseError):
(WebCore::FetchEvent::onResponse):
(WebCore::FetchEvent::respondWithError):
(WebCore::FetchEvent::processResponse):
(WebCore::FetchEvent::promiseIsSettled):
* workers/service/FetchEvent.h:
* workers/service/context/ServiceWorkerFetch.cpp:
(WebCore::ServiceWorkerFetch::processResponse):
(WebCore::ServiceWorkerFetch::dispatchFetchEvent):

Source/WebKit:

Log in JS console in case of failures.
Rely on ThreadableLoader to log which client actually failed.

* WebProcess/Storage/ServiceWorkerClientFetch.cpp:
(WebKit::ServiceWorkerClientFetch::didFail):

LayoutTests:

* TestExpectations:
* http/tests/workers/service/basic-fetch.https-expected.txt:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@232739 268f45cc-cd09-0410-ab3c-d52691b4dbfc
23 files changed:
LayoutTests/ChangeLog
LayoutTests/TestExpectations
LayoutTests/http/tests/workers/service/basic-fetch.https-expected.txt
LayoutTests/imported/w3c/ChangeLog
LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/fetch-event-network-error.https-expected.txt
LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/fetch-event-redirect.https-expected.txt
LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/fetch-event-respond-with-argument.https-expected.txt
LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/fetch-event-respond-with-response-body-with-invalid-chunk.https-expected.txt
LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/fetch-frame-resource.https-expected.txt
LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/fetch-mixed-content-to-inscope.https-expected.txt
LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/fetch-mixed-content-to-outscope.https-expected.txt
LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/invalid-header.https-expected.txt
LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/update-recovery.https-expected.txt
Source/WebCore/ChangeLog
Source/WebCore/loader/ThreadableLoader.cpp
Source/WebCore/platform/network/ResourceErrorBase.cpp
Source/WebCore/platform/network/ResourceErrorBase.h
Source/WebCore/testing/ServiceWorkerInternals.cpp
Source/WebCore/workers/service/FetchEvent.cpp
Source/WebCore/workers/service/FetchEvent.h
Source/WebCore/workers/service/context/ServiceWorkerFetch.cpp
Source/WebKit/ChangeLog
Source/WebKit/WebProcess/Storage/ServiceWorkerClientFetch.cpp