| Index: Source/core/loader/DocumentThreadableLoader.cpp
|
| diff --git a/Source/core/loader/DocumentThreadableLoader.cpp b/Source/core/loader/DocumentThreadableLoader.cpp
|
| index a7c82ef910716aed701c02dd3f609ad45492ca9c..22c9b09b28f7916866ff372897f9e4445131d64e 100644
|
| --- a/Source/core/loader/DocumentThreadableLoader.cpp
|
| +++ b/Source/core/loader/DocumentThreadableLoader.cpp
|
| @@ -183,6 +183,15 @@ void DocumentThreadableLoader::redirectReceived(Resource* resource, ResourceRequ
|
| ASSERT_UNUSED(resource, resource == this->resource());
|
|
|
| RefPtr<DocumentThreadableLoader> protect(this);
|
| +
|
| + // We don't support redirect in Fech API yet.
|
| + // FIXME: Support redirect in Fech API.
|
| + if (resource->resourceRequest().requestContext() == blink::WebURLRequest::RequestContextFetch) {
|
| + m_client->didFailRedirectCheck();
|
| + request = ResourceRequest();
|
| + return;
|
| + }
|
| +
|
| if (!isAllowedByPolicy(request.url())) {
|
| m_client->didFailRedirectCheck();
|
| request = ResourceRequest();
|
| @@ -319,7 +328,26 @@ void DocumentThreadableLoader::handleResponse(unsigned long identifier, const Re
|
| return;
|
| }
|
|
|
| - // FIXME: When response.wasFetchedViaServiceWorker() is true, we need to check the URL of the response for CSP and CORS.
|
| + // If the response is fetched via ServiceWorker, the original URL of the response could be different from the URL of the request.
|
| + if (response.wasFetchedViaServiceWorker()) {
|
| + if (!isAllowedByPolicy(response.url())) {
|
| + m_client->didFailRedirectCheck();
|
| + return;
|
| + }
|
| + if (!isAllowedRedirect(response.url())) {
|
| + if (m_options.crossOriginRequestPolicy == DenyCrossOriginRequests) {
|
| + m_client->didFail(ResourceError(errorDomainBlinkInternal, 0, response.url().string(), "Cross origin requests are not supported."));
|
| + return;
|
| + }
|
| + if (m_options.crossOriginRequestPolicy == UseAccessControl) {
|
| + String accessControlErrorDescription;
|
| + if (!passesAccessControlCheck(response, effectiveAllowCredentials(), securityOrigin(), accessControlErrorDescription)) {
|
| + m_client->didFailAccessControlCheck(ResourceError(errorDomainBlinkInternal, 0, response.url().string(), accessControlErrorDescription));
|
| + return;
|
| + }
|
| + }
|
| + }
|
| + }
|
|
|
| if (!m_sameOriginRequest && m_options.crossOriginRequestPolicy == UseAccessControl) {
|
| String accessControlErrorDescription;
|
|
|