Diff
Modified: branches/safari-605-branch/LayoutTests/ChangeLog (229555 => 229556)
--- branches/safari-605-branch/LayoutTests/ChangeLog 2018-03-12 21:59:34 UTC (rev 229555)
+++ branches/safari-605-branch/LayoutTests/ChangeLog 2018-03-12 21:59:39 UTC (rev 229556)
@@ -1,5 +1,27 @@
2018-03-11 Jason Marcell <jmarc...@apple.com>
+ Cherry-pick r229086. rdar://problem/37992301
+
+ 2018-02-27 Youenn Fablet <you...@apple.com>
+
+ Do not trigger a service worker match in case of document redirection if it will be already served by AppCache
+ https://bugs.webkit.org/show_bug.cgi?id=183185
+ <rdar://problem/37693796>
+
+ Reviewed by Chris Dumez.
+
+ * http/tests/appcache/main-resource-redirect-with-sw-expected.txt: Added.
+ * http/tests/appcache/main-resource-redirect-with-sw.html: Added.
+ * http/tests/appcache/resources/main-resource-redirect-with-sw.manifest: Added.
+ * http/tests/appcache/resources/register-resources-service-worker.html: Added.
+ * http/tests/appcache/service-worker-proxy.js: Added.
+ * platform/gtk/TestExpectations:
+ * platform/mac-wk1/TestExpectations:
+ * platform/win/TestExpectations:
+ * platform/wpe/TestExpectations:
+
+2018-03-11 Jason Marcell <jmarc...@apple.com>
+
Cherry-pick r228279. rdar://problem/38154561
2018-02-08 Chris Fleizach <cfleiz...@apple.com>
Added: branches/safari-605-branch/LayoutTests/http/tests/appcache/main-resource-redirect-with-sw-expected.txt (0 => 229556)
--- branches/safari-605-branch/LayoutTests/http/tests/appcache/main-resource-redirect-with-sw-expected.txt (rev 0)
+++ branches/safari-605-branch/LayoutTests/http/tests/appcache/main-resource-redirect-with-sw-expected.txt 2018-03-12 21:59:39 UTC (rev 229556)
@@ -0,0 +1,2 @@
+CONSOLE MESSAGE: line 1: ApplicationCache is deprecated. Please use ServiceWorkers instead.
+PASS
Added: branches/safari-605-branch/LayoutTests/http/tests/appcache/main-resource-redirect-with-sw.html (0 => 229556)
--- branches/safari-605-branch/LayoutTests/http/tests/appcache/main-resource-redirect-with-sw.html (rev 0)
+++ branches/safari-605-branch/LayoutTests/http/tests/appcache/main-resource-redirect-with-sw.html 2018-03-12 21:59:39 UTC (rev 229556)
@@ -0,0 +1,52 @@
+<html manifest="resources/main-resource-redirect-with-sw.manifest">
+<body>
+<p>Test that application cache and service worker do not mess with each other in case of redirections.</p>
+<div id="result">Testing...</div>
+<script>
+if (window.testRunner) {
+ testRunner.waitUntilDone();
+ testRunner.dumpAsText();
+ testRunner.setShouldDecideNavigationPolicyAfterDelay(true);
+}
+
+var serviceWorkerIframe;
+function prepareTest()
+{
+ serviceWorkerIframe = document.createElement("iframe");
+ serviceWorkerIframe.setAttribute("src", "/appcache/resources/register-resources-service-worker.html");
+ document.body.appendChild(serviceWorkerIframe);
+ serviceWorkerIframe._onload_ = async (e) => {
+ try {
+ await serviceWorkerIframe.contentWindow.registerServiceWorker();
+ } catch (e) {
+ console.log(e);
+ }
+ test();
+ };
+}
+
+function test()
+{
+ applicationCache._oncached_ = null;
+ applicationCache._onnoupdate_ = null;
+ var iframe = document.createElement("iframe");
+ iframe.setAttribute("src", "/resources/redirect.php?url=""
+ document.body.appendChild(iframe);
+ iframe._onload_ = done;
+}
+
+function done()
+{
+ applicationCache._onerror_ = null;
+ // We wait some small time to ensure that the frame loading does not trigger two concurrent loads.
+ setTimeout(() => {
+ window.document.body.innerHTML = "PASS";
+ if (window.testRunner)
+ testRunner.notifyDone();
+ }, 10);
+}
+
+applicationCache._oncached_=prepareTest;
+applicationCache._onnoupdate_=prepareTest;
+</script>
+</body>
Added: branches/safari-605-branch/LayoutTests/http/tests/appcache/resources/main-resource-redirect-with-sw.manifest (0 => 229556)
--- branches/safari-605-branch/LayoutTests/http/tests/appcache/resources/main-resource-redirect-with-sw.manifest (rev 0)
+++ branches/safari-605-branch/LayoutTests/http/tests/appcache/resources/main-resource-redirect-with-sw.manifest 2018-03-12 21:59:39 UTC (rev 229556)
@@ -0,0 +1,2 @@
+CACHE MANIFEST
+http://127.0.0.1:8000/appcache/resources/simple.txt
Added: branches/safari-605-branch/LayoutTests/http/tests/appcache/resources/register-resources-service-worker.html (0 => 229556)
--- branches/safari-605-branch/LayoutTests/http/tests/appcache/resources/register-resources-service-worker.html (rev 0)
+++ branches/safari-605-branch/LayoutTests/http/tests/appcache/resources/register-resources-service-worker.html 2018-03-12 21:59:39 UTC (rev 229556)
@@ -0,0 +1,22 @@
+<html>
+<body>
+<script>
+var scope = "/appcache/resources";
+var script = "/appcache/service-worker-proxy.js";
+
+async function registerServiceWorker()
+{
+ var registration = await navigator.serviceWorker.register(script, { scope : scope });
+ await new Promise(resolve => {
+ if (registration.active)
+ resolve(registration);
+ worker = registration.installing;
+ worker.addEventListener("statechange", () => {
+ if (worker.state === "activated")
+ resolve(registration);
+ });
+ });
+}
+</script>
+</body>
+</html>
Added: branches/safari-605-branch/LayoutTests/http/tests/appcache/service-worker-proxy.js (0 => 229556)
--- branches/safari-605-branch/LayoutTests/http/tests/appcache/service-worker-proxy.js (rev 0)
+++ branches/safari-605-branch/LayoutTests/http/tests/appcache/service-worker-proxy.js 2018-03-12 21:59:39 UTC (rev 229556)
@@ -0,0 +1,3 @@
+self.addEventListener("fetch", (event) => {
+ event.respondWith(fetch(event.request));
+});
Modified: branches/safari-605-branch/LayoutTests/platform/gtk/TestExpectations (229555 => 229556)
--- branches/safari-605-branch/LayoutTests/platform/gtk/TestExpectations 2018-03-12 21:59:34 UTC (rev 229555)
+++ branches/safari-605-branch/LayoutTests/platform/gtk/TestExpectations 2018-03-12 21:59:39 UTC (rev 229556)
@@ -1130,6 +1130,7 @@
webkit.org/b/175419 http/wpt/service-workers [ Failure ]
webkit.org/b/175419 http/tests/inspector/network/resource-response-service-worker.html [ Skip ]
webkit.org/b/175419 imported/w3c/web-platform-tests/service-workers [ Skip ]
+http/tests/appcache/main-resource-redirect-with-sw.html [ Skip ]
webkit.org/b/175419 imported/w3c/web-platform-tests/background-fetch/interfaces-worker.https.html [ Failure ]
webkit.org/b/175419 imported/w3c/web-platform-tests/background-fetch/interfaces.html [ Failure ]
Modified: branches/safari-605-branch/LayoutTests/platform/mac-wk1/TestExpectations (229555 => 229556)
--- branches/safari-605-branch/LayoutTests/platform/mac-wk1/TestExpectations 2018-03-12 21:59:34 UTC (rev 229555)
+++ branches/safari-605-branch/LayoutTests/platform/mac-wk1/TestExpectations 2018-03-12 21:59:39 UTC (rev 229556)
@@ -125,6 +125,7 @@
http/wpt/cache-storage [ Skip ]
http/tests/cache-storage [ Skip ]
imported/w3c/web-platform-tests/streams/readable-byte-streams/detached-buffers.serviceworker.https.html [ Skip ]
+http/tests/appcache/main-resource-redirect-with-sw.html [ Skip ]
# Skip WebRTC for now in WK1
imported/w3c/web-platform-tests/webrtc [ Skip ]
Modified: branches/safari-605-branch/LayoutTests/platform/win/TestExpectations (229555 => 229556)
--- branches/safari-605-branch/LayoutTests/platform/win/TestExpectations 2018-03-12 21:59:34 UTC (rev 229555)
+++ branches/safari-605-branch/LayoutTests/platform/win/TestExpectations 2018-03-12 21:59:39 UTC (rev 229556)
@@ -3715,6 +3715,7 @@
imported/w3c/web-platform-tests/service-workers [ Skip ]
http/tests/cache-storage [ Skip ]
http/wpt/cache-storage [ Skip ]
+http/tests/appcache/main-resource-redirect-with-sw.html [ Skip ]
# Flaky tests on Windows:
Modified: branches/safari-605-branch/LayoutTests/platform/wpe/TestExpectations (229555 => 229556)
--- branches/safari-605-branch/LayoutTests/platform/wpe/TestExpectations 2018-03-12 21:59:34 UTC (rev 229555)
+++ branches/safari-605-branch/LayoutTests/platform/wpe/TestExpectations 2018-03-12 21:59:39 UTC (rev 229556)
@@ -1060,6 +1060,7 @@
webkit.org/b/178576 imported/w3c/web-platform-tests/service-workers [ Skip ]
webkit.org/b/178576 imported/w3c/web-platform-tests/service-workers/stub-4.6.2-cache.html [ Pass ]
webkit.org/b/178576 imported/w3c/web-platform-tests/service-workers/stub-4.6.3-cache-storage.html [ Pass ]
+http/tests/appcache/main-resource-redirect-with-sw.html [ Skip ]
webkit.org/b/178316 imported/w3c/web-platform-tests/service-workers/cache-storage [ Skip ]
webkit.org/b/178316 http/wpt/cache-storage [ Skip ]
Modified: branches/safari-605-branch/Source/WebCore/ChangeLog (229555 => 229556)
--- branches/safari-605-branch/Source/WebCore/ChangeLog 2018-03-12 21:59:34 UTC (rev 229555)
+++ branches/safari-605-branch/Source/WebCore/ChangeLog 2018-03-12 21:59:39 UTC (rev 229556)
@@ -1,5 +1,27 @@
2018-03-11 Jason Marcell <jmarc...@apple.com>
+ Cherry-pick r229086. rdar://problem/37992301
+
+ 2018-02-27 Youenn Fablet <you...@apple.com>
+
+ Do not trigger a service worker match in case of document redirection if it will be already served by AppCache
+ https://bugs.webkit.org/show_bug.cgi?id=183185
+ <rdar://problem/37693796>
+
+ Reviewed by Chris Dumez.
+
+ Disabling service worker matching in case there is a substitute data.
+ Otherwise there is a risk for a double load, substitute data first and the new load
+ triggered if matching a new registration.
+ A future fix should first do service worker registration matching and if there is no registration query appcache.
+
+ Test: http/tests/appcache/main-resource-redirect-with-sw.html
+
+ * loader/DocumentLoader.cpp:
+ (WebCore::DocumentLoader::redirectReceived):
+
+2018-03-11 Jason Marcell <jmarc...@apple.com>
+
Cherry-pick r229028. rdar://problem/37992284
2018-02-26 Youenn Fablet <you...@apple.com>
Modified: branches/safari-605-branch/Source/WebCore/loader/DocumentLoader.cpp (229555 => 229556)
--- branches/safari-605-branch/Source/WebCore/loader/DocumentLoader.cpp 2018-03-12 21:59:34 UTC (rev 229555)
+++ branches/safari-605-branch/Source/WebCore/loader/DocumentLoader.cpp 2018-03-12 21:59:39 UTC (rev 229556)
@@ -519,7 +519,7 @@
#if ENABLE(SERVICE_WORKER)
bool isRedirectionFromServiceWorker = redirectResponse.source() == ResourceResponse::Source::ServiceWorker;
willSendRequest(WTFMove(request), redirectResponse, [isRedirectionFromServiceWorker, completionHandler = WTFMove(completionHandler), protectedThis = makeRef(*this), this] (auto&& request) mutable {
- if (request.isNull() || !m_mainDocumentError.isNull() || !m_frame) {
+ if (request.isNull() || !m_mainDocumentError.isNull() || !m_frame || m_substituteData.isValid()) {
completionHandler({ });
return;
}