ServiceWorkerClientFetch should not consider responses without Location headers as...
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 30 Jan 2018 02:15:14 +0000 (02:15 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 30 Jan 2018 02:15:14 +0000 (02:15 +0000)
https://bugs.webkit.org/show_bug.cgi?id=182134

Patch by Youenn Fablet <youenn@apple.com> on 2018-01-29
Reviewed by Chris Dumez.

LayoutTests/imported/w3c:

* web-platform-tests/service-workers/service-worker/navigation-redirect.https-expected.txt:

Source/WebKit:

As per fetch spec, a response with a redirection status code but no Location header should not be considered as a redirection.
This is also consistent with SubresourceLoader::didReceiveResponse.

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

LayoutTests:

* TestExpectations:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@227770 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/TestExpectations
LayoutTests/imported/w3c/ChangeLog
LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/navigation-redirect.https-expected.txt
Source/WebCore/platform/network/HTTPHeaderMap.h
Source/WebKit/ChangeLog
Source/WebKit/WebProcess/Storage/ServiceWorkerClientFetch.cpp

index adbd5fc..465196f 100644 (file)
@@ -1,5 +1,14 @@
 2018-01-29  Youenn Fablet  <youenn@apple.com>
 
+        ServiceWorkerClientFetch should not consider responses without Location headers as redirection responses
+        https://bugs.webkit.org/show_bug.cgi?id=182134
+
+        Reviewed by Chris Dumez.
+
+        * TestExpectations:
+
+2018-01-29  Youenn Fablet  <youenn@apple.com>
+
         Cache API should make sure to resolve caches.open promises in the same order as called
         https://bugs.webkit.org/show_bug.cgi?id=182193
         <rdar://problem/36930363>
index 254b0c7..f23d638 100644 (file)
@@ -153,7 +153,6 @@ imported/w3c/web-platform-tests/service-workers/service-worker/import-scripts-re
 imported/w3c/web-platform-tests/fetch/api/abort/general-serviceworker.https.html [ Skip ]
 imported/w3c/web-platform-tests/service-workers/service-worker/fetch-event-respond-with-partial-stream.https.html [ Skip ]
 imported/w3c/web-platform-tests/service-workers/service-worker/http-to-https-redirect-and-register.https.html [ Skip ]
-imported/w3c/web-platform-tests/service-workers/service-worker/navigation-redirect.https.html [ Skip ]
 imported/w3c/web-platform-tests/service-workers/service-worker/postmessage.https.html [ Skip ]
 imported/w3c/web-platform-tests/service-workers/service-worker/respond-with-body-accessed-response.https.html [ Skip ]
 imported/w3c/web-platform-tests/service-workers/service-worker/sandboxed-iframe-fetch-event.https.html [ Skip ]
index cc097f3..ec62746 100644 (file)
@@ -1,3 +1,12 @@
+2018-01-29  Youenn Fablet  <youenn@apple.com>
+
+        ServiceWorkerClientFetch should not consider responses without Location headers as redirection responses
+        https://bugs.webkit.org/show_bug.cgi?id=182134
+
+        Reviewed by Chris Dumez.
+
+        * web-platform-tests/service-workers/service-worker/navigation-redirect.https-expected.txt:
+
 2018-01-29  Oleksandr Skachkov  <gskachkov@gmail.com>
 
         FetchResponse should support ConsumeData callback on chunk data is received: handling ReadableStream bodies
index 49c6c9d..e820538 100644 (file)
@@ -1,6 +1,4 @@
-  
 
-Harness Error (TIMEOUT), message = null
 
 PASS Normal redirect to same-origin scope. 
 PASS Normal redirect to other-origin scope. 
@@ -24,11 +22,11 @@ PASS Redirect to same-origin same-scope with opaque redirect response.
 PASS Redirect to same-origin other-scope with opaque redirect response. 
 PASS Redirect to other-origin out-scope with opaque redirect response. 
 PASS Redirect to other-origin in-scope with opaque redirect response. 
-TIMEOUT No location redirect response. Test timed out
-NOTRUN Redirect to same-origin out-scope with opaque redirect response which is passed through Cache. 
-NOTRUN Redirect to same-origin same-scope with opaque redirect response which is passed through Cache. 
-NOTRUN Redirect to same-origin other-scope with opaque redirect response which is passed through Cache. 
-NOTRUN Redirect to other-origin out-scope with opaque redirect response which is passed through Cache. 
-NOTRUN Redirect to other-origin in-scope with opaque redirect response which is passed through Cache. 
-NOTRUN No location redirect response via Cache. 
+PASS No location redirect response. 
+PASS Redirect to same-origin out-scope with opaque redirect response which is passed through Cache. 
+PASS Redirect to same-origin same-scope with opaque redirect response which is passed through Cache. 
+PASS Redirect to same-origin other-scope with opaque redirect response which is passed through Cache. 
+PASS Redirect to other-origin out-scope with opaque redirect response which is passed through Cache. 
+PASS Redirect to other-origin in-scope with opaque redirect response which is passed through Cache. 
+PASS No location redirect response via Cache. 
 
index 64559e1..7214c5f 100644 (file)
@@ -142,7 +142,7 @@ public:
     void set(HTTPHeaderName, const String& value);
     void add(HTTPHeaderName, const String& value);
     bool addIfNotPresent(HTTPHeaderName, const String&);
-    bool contains(HTTPHeaderName) const;
+    WEBCORE_EXPORT bool contains(HTTPHeaderName) const;
     WEBCORE_EXPORT bool remove(HTTPHeaderName);
 
     // Instead of passing a string literal to any of these functions, just use a HTTPHeaderName instead.
index 5d1aa0c..e8be436 100644 (file)
@@ -1,5 +1,18 @@
 2018-01-29  Youenn Fablet  <youenn@apple.com>
 
+        ServiceWorkerClientFetch should not consider responses without Location headers as redirection responses
+        https://bugs.webkit.org/show_bug.cgi?id=182134
+
+        Reviewed by Chris Dumez.
+
+        As per fetch spec, a response with a redirection status code but no Location header should not be considered as a redirection.
+        This is also consistent with SubresourceLoader::didReceiveResponse.
+
+        * WebProcess/Storage/ServiceWorkerClientFetch.cpp:
+        (WebKit::ServiceWorkerClientFetch::didReceiveResponse):
+
+2018-01-29  Youenn Fablet  <youenn@apple.com>
+
         Cache API should make sure to resolve caches.open promises in the same order as called
         https://bugs.webkit.org/show_bug.cgi?id=182193
         <rdar://problem/36930363>
index ee05b8f..e3d3177 100644 (file)
@@ -110,9 +110,8 @@ void ServiceWorkerClientFetch::didReceiveResponse(ResourceResponse&& response)
     }
     response.setSource(ResourceResponse::Source::ServiceWorker);
 
-    if (response.isRedirection()) {
+    if (response.isRedirection() && response.httpHeaderFields().contains(HTTPHeaderName::Location)) {
         m_redirectionStatus = RedirectionStatus::Receiving;
-        // FIXME: Get shouldClearReferrerOnHTTPSToHTTPRedirect value from
         m_loader->willSendRequest(m_loader->request().redirectedRequest(response, m_shouldClearReferrerOnHTTPSToHTTPRedirect), response, [protectedThis = makeRef(*this), this](ResourceRequest&& request) {
             if (request.isNull() || !m_callback)
                 return;