Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(790)

Unified Diff: Source/core/fetch/ResourceFetcher.cpp

Issue 399543002: [ServiceWorker] Make fetch() method better conformance with the spec. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: update m_forceDoNotAllowStoredCredentials in DocumentThreadableLoader Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: Source/core/fetch/ResourceFetcher.cpp
diff --git a/Source/core/fetch/ResourceFetcher.cpp b/Source/core/fetch/ResourceFetcher.cpp
index 3bd9550a71935ed145041bc6ca7088ad3d98d5df..0f9be6b1e6c0ca01fb37187c23bdd49602be665c 100644
--- a/Source/core/fetch/ResourceFetcher.cpp
+++ b/Source/core/fetch/ResourceFetcher.cpp
@@ -1336,7 +1336,14 @@ void ResourceFetcher::willSendRequest(unsigned long identifier, ResourceRequest&
void ResourceFetcher::didReceiveResponse(const Resource* resource, const ResourceResponse& response)
{
- // FIXME: When response.wasFetchedViaServiceWorker() is true, we need to check the URL of the responce 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 (!canRequest(resource->type(), response.url(), resource->options(), false, FetchRequest::UseDefaultOriginRestrictionForType)) {
+ resource->loader()->cancel();
+ context().dispatchDidFail(m_documentLoader, resource->identifier(), ResourceError(errorDomainBlinkInternal, 0, response.url().string(), "Original url check of ServiceWorker fetched resource failed."));
+ return;
+ }
+ }
context().dispatchDidReceiveResponse(m_documentLoader, resource->identifier(), response, resource->loader());
}

Powered by Google App Engine
This is Rietveld 408576698