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

Unified Diff: Source/modules/serviceworkers/RespondWithObserver.cpp

Issue 1067303002: [ServiceWorker] Treat cors response as a network error for client requests. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: wrap the line Created 5 years, 8 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
« no previous file with comments | « LayoutTests/http/tests/serviceworker/fetch-frame-resource.html ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/modules/serviceworkers/RespondWithObserver.cpp
diff --git a/Source/modules/serviceworkers/RespondWithObserver.cpp b/Source/modules/serviceworkers/RespondWithObserver.cpp
index 410d4ccaeed73d326f567c9ef6f1d5d6864972d9..d492a194f255ef24d73574d2183b5633d876849d 100644
--- a/Source/modules/serviceworkers/RespondWithObserver.cpp
+++ b/Source/modules/serviceworkers/RespondWithObserver.cpp
@@ -185,15 +185,15 @@ void RespondWithObserver::responseWasFulfilled(const ScriptValue& value)
return;
}
Response* response = V8Response::toImplWithTypeCheck(toIsolate(executionContext()), value.v8Value());
- // "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 one of the following conditions is true, return a network error:
+ // - |response|'s type is |error|.
+ // - |request|'s mode is not |no-cors| and response's type is |opaque|.
+ // - |request| is a client request and |response|'s type is neither
+ // |basic| nor |default|."
const FetchResponseData::Type responseType = response->response()->type();
- if ((responseType == FetchResponseData::OpaqueType && m_requestMode != WebURLRequest::FetchRequestModeNoCORS) || responseType == FetchResponseData::ErrorType) {
- responseWasRejected();
- return;
- }
- // Treat the opaque response as a network error for frame loading.
- if (responseType == FetchResponseData::OpaqueType && m_frameType != WebURLRequest::FrameTypeNone) {
+ if (responseType == FetchResponseData::ErrorType
+ || (m_requestMode != WebURLRequest::FetchRequestModeNoCORS && responseType == FetchResponseData::OpaqueType)
+ || (m_frameType != WebURLRequest::FrameTypeNone && responseType != FetchResponseData::BasicType && responseType != FetchResponseData::DefaultType)) {
responseWasRejected();
return;
}
« no previous file with comments | « LayoutTests/http/tests/serviceworker/fetch-frame-resource.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698