Diff
Modified: branches/safari-605-branch/LayoutTests/ChangeLog (228598 => 228599)
--- branches/safari-605-branch/LayoutTests/ChangeLog 2018-02-17 18:35:51 UTC (rev 228598)
+++ branches/safari-605-branch/LayoutTests/ChangeLog 2018-02-17 18:35:54 UTC (rev 228599)
@@ -1,3 +1,19 @@
+2018-02-16 Jason Marcell <[email protected]>
+
+ Cherry-pick r228551. rdar://problem/37615430
+
+ 2018-02-15 Youenn Fablet <[email protected]>
+
+ Resources loaded from service workers are not downloadable
+ https://bugs.webkit.org/show_bug.cgi?id=182848
+
+ Reviewed by Chris Dumez.
+
+ * http/tests/workers/service/resources/download-binary.php: Added.
+ * http/tests/workers/service/resources/service-worker-download-worker.js: Added.
+ * http/tests/workers/service/service-worker-download.https-expected.txt: Added.
+ * http/tests/workers/service/service-worker-download.https.html: Added.
+
2018-02-16 Ryan Haddad <[email protected]>
Cherry-pick r228579. rdar://problem/36837397
Added: branches/safari-605-branch/LayoutTests/http/tests/workers/service/resources/download-binary.php (0 => 228599)
--- branches/safari-605-branch/LayoutTests/http/tests/workers/service/resources/download-binary.php (rev 0)
+++ branches/safari-605-branch/LayoutTests/http/tests/workers/service/resources/download-binary.php 2018-02-17 18:35:54 UTC (rev 228599)
@@ -0,0 +1,4 @@
+<?php
+header("Content-Type: application/my-super-binary");
+echo "[1, 2, 3]";
+?>
Added: branches/safari-605-branch/LayoutTests/http/tests/workers/service/resources/service-worker-download-worker.js (0 => 228599)
--- branches/safari-605-branch/LayoutTests/http/tests/workers/service/resources/service-worker-download-worker.js (rev 0)
+++ branches/safari-605-branch/LayoutTests/http/tests/workers/service/resources/service-worker-download-worker.js 2018-02-17 18:35:54 UTC (rev 228599)
@@ -0,0 +1,3 @@
+self.addEventListener("fetch", (event) => {
+ event.respondWith(fetch(event.request.url));
+});
Added: branches/safari-605-branch/LayoutTests/http/tests/workers/service/service-worker-download.https-expected.txt (0 => 228599)
--- branches/safari-605-branch/LayoutTests/http/tests/workers/service/service-worker-download.https-expected.txt (rev 0)
+++ branches/safari-605-branch/LayoutTests/http/tests/workers/service/service-worker-download.https-expected.txt 2018-02-17 18:35:54 UTC (rev 228599)
@@ -0,0 +1,4 @@
+Download started.
+Downloading URL with suggested filename "download-binary.php"
+Download completed.
+
Added: branches/safari-605-branch/LayoutTests/http/tests/workers/service/service-worker-download.https.html (0 => 228599)
--- branches/safari-605-branch/LayoutTests/http/tests/workers/service/service-worker-download.https.html (rev 0)
+++ branches/safari-605-branch/LayoutTests/http/tests/workers/service/service-worker-download.https.html 2018-02-17 18:35:54 UTC (rev 228599)
@@ -0,0 +1,22 @@
+<html>
+<head>
+<script src=""
+</head>
+<body>
+<script>
+if (window.testRunner) {
+ testRunner.dumpAsText();
+ testRunner.setShouldLogDownloadCallbacks(true);
+ testRunner.waitUntilDownloadFinished();
+ testRunner.setShouldDownloadUndisplayableMIMETypes(true);
+}
+
+async function doTest()
+{
+ await interceptedFrame("resources/service-worker-download-worker.js", "/workers/service/resources/");
+ window.location = "/workers/service/resources/download-binary.php";
+}
+doTest();
+</script>
+</body>
+</html>
Modified: branches/safari-605-branch/Source/WebKit/ChangeLog (228598 => 228599)
--- branches/safari-605-branch/Source/WebKit/ChangeLog 2018-02-17 18:35:51 UTC (rev 228598)
+++ branches/safari-605-branch/Source/WebKit/ChangeLog 2018-02-17 18:35:54 UTC (rev 228599)
@@ -1,3 +1,24 @@
+2018-02-16 Jason Marcell <[email protected]>
+
+ Cherry-pick r228551. rdar://problem/37615430
+
+ 2018-02-15 Youenn Fablet <[email protected]>
+
+ Resources loaded from service workers are not downloadable
+ https://bugs.webkit.org/show_bug.cgi?id=182848
+
+ Reviewed by Chris Dumez.
+
+ Downloads are not supporting resources loaded through service worker.
+ As a temporary solution, we will let network process handle it.
+ Note that this would not work if the URL can only be loaded through service worker.
+ Note also that for navigation loads, if the content type is the default one (application/octet-stream) we are overriding it to
+ text/html as we do not support mime sniffing yet from service worker responses.
+ This might interfere with automatic downloads from navigation.
+
+ * NetworkProcess/NetworkConnectionToWebProcess.cpp:
+ (WebKit::NetworkConnectionToWebProcess::convertMainResourceLoadToDownload):
+
2018-02-15 Jason Marcell <[email protected]>
Cherry-pick r228472. rdar://problem/37570861
Modified: branches/safari-605-branch/Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.cpp (228598 => 228599)
--- branches/safari-605-branch/Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.cpp 2018-02-17 18:35:51 UTC (rev 228598)
+++ branches/safari-605-branch/Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.cpp 2018-02-17 18:35:54 UTC (rev 228599)
@@ -333,7 +333,8 @@
void NetworkConnectionToWebProcess::convertMainResourceLoadToDownload(PAL::SessionID sessionID, uint64_t mainResourceLoadIdentifier, DownloadID downloadID, const ResourceRequest& request, const ResourceResponse& response)
{
auto& networkProcess = NetworkProcess::singleton();
- if (!mainResourceLoadIdentifier) {
+ // In case a response is served from service worker, we do not have yet the ability to convert the load.
+ if (!mainResourceLoadIdentifier || response.source() == ResourceResponse::Source::ServiceWorker) {
networkProcess.downloadManager().startDownload(this, sessionID, downloadID, request);
return;
}