DocumentThreadableLoader should ensure service worker is not reused if redirection...
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 25 Jan 2018 21:27:32 +0000 (21:27 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 25 Jan 2018 21:27:32 +0000 (21:27 +0000)
https://bugs.webkit.org/show_bug.cgi?id=182137

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

LayoutTests/imported/w3c:

* web-platform-tests/service-workers/service-worker/fetch-request-fallback.https-expected.txt:

Source/WebCore:

Covered by rebased test.
In case redirection does not come from memory cache or service worker, disable service worker interception when following the redirection.

* loader/DocumentThreadableLoader.cpp:
(WebCore::DocumentThreadableLoader::redirectReceived):

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

LayoutTests/imported/w3c/ChangeLog
LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/fetch-request-fallback.https-expected.txt
Source/WebCore/ChangeLog
Source/WebCore/loader/DocumentThreadableLoader.cpp

index 4577929..a01b083 100644 (file)
@@ -1,5 +1,14 @@
 2018-01-25  Youenn Fablet  <youenn@apple.com>
 
+        DocumentThreadableLoader should ensure service worker is not reused if redirection comes from the network
+        https://bugs.webkit.org/show_bug.cgi?id=182137
+
+        Reviewed by Chris Dumez.
+
+        * web-platform-tests/service-workers/service-worker/fetch-request-fallback.https-expected.txt:
+
+2018-01-25  Youenn Fablet  <youenn@apple.com>
+
         DocumentLoader should interrupt ongoing load when getting a redirection from network that matches a service worker
         https://bugs.webkit.org/show_bug.cgi?id=182115
 
index 1f76404..c8b5244 100644 (file)
@@ -13,8 +13,8 @@ PASS The SW must intercept the request of same origin XHR.
 PASS The SW must intercept the request of CORS-unsupported other origin XHR. 
 PASS The SW must intercept the request of CORS-supported other origin XHR. 
 PASS The SW must intercept only the first request of redirected XHR. 
-FAIL The SW must intercept only the first request for XHR which is redirected to CORS-unsupported other origin. assert_object_equals: unexpected property "1"
-FAIL The SW must intercept only the first request for XHR which is redirected to CORS-supported other origin. assert_object_equals: unexpected property "1"
+PASS The SW must intercept only the first request for XHR which is redirected to CORS-unsupported other origin. 
+PASS The SW must intercept only the first request for XHR which is redirected to CORS-supported other origin. 
 PASS The SW must intercept the request for image. 
 PASS The SW must intercept the request for other origin image. 
 PASS The SW must intercept the request for CORS-unsupported other origin image. 
index 3d58d41..c870820 100644 (file)
@@ -1,5 +1,18 @@
 2018-01-25  Youenn Fablet  <youenn@apple.com>
 
+        DocumentThreadableLoader should ensure service worker is not reused if redirection comes from the network
+        https://bugs.webkit.org/show_bug.cgi?id=182137
+
+        Reviewed by Chris Dumez.
+
+        Covered by rebased test.
+        In case redirection does not come from memory cache or service worker, disable service worker interception when following the redirection.
+
+        * loader/DocumentThreadableLoader.cpp:
+        (WebCore::DocumentThreadableLoader::redirectReceived):
+
+2018-01-25  Youenn Fablet  <youenn@apple.com>
+
         DocumentLoader should interrupt ongoing load when getting a redirection from network that matches a service worker
         https://bugs.webkit.org/show_bug.cgi?id=182115
 
index 44ab9c2..4f4be1a 100644 (file)
@@ -293,6 +293,10 @@ void DocumentThreadableLoader::redirectReceived(CachedResource& resource, Resour
         m_originalHeaders->remove(HTTPHeaderName::Authorization);
     request.setHTTPHeaderFields(*m_originalHeaders);
 
+#if ENABLE(SERVICE_WORKER)
+    if (redirectResponse.source() != ResourceResponse::Source::ServiceWorker && redirectResponse.source() != ResourceResponse::Source::MemoryCache)
+        m_options.serviceWorkersMode = ServiceWorkersMode::None;
+#endif
     makeCrossOriginAccessRequest(ResourceRequest(request));
     completionHandler(WTFMove(request));
 }