- Revision
- 228551
- Author
- [email protected]
- Date
- 2018-02-15 20:27:43 -0800 (Thu, 15 Feb 2018)
Log Message
Resources loaded from service workers are not downloadable
https://bugs.webkit.org/show_bug.cgi?id=182848
Patch by Youenn Fablet <[email protected]> on 2018-02-15
Reviewed by Chris Dumez.
Source/WebKit:
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):
LayoutTests:
* 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.
Modified Paths
Added Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (228550 => 228551)
--- trunk/LayoutTests/ChangeLog 2018-02-16 03:28:24 UTC (rev 228550)
+++ trunk/LayoutTests/ChangeLog 2018-02-16 04:27:43 UTC (rev 228551)
@@ -1,3 +1,15 @@
+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-15 Ryan Haddad <[email protected]>
Mark imported/w3c/web-platform-tests/service-workers/service-worker/register-closed-window.https.html as flaky.
Added: trunk/LayoutTests/http/tests/workers/service/resources/download-binary.php (0 => 228551)
--- trunk/LayoutTests/http/tests/workers/service/resources/download-binary.php (rev 0)
+++ trunk/LayoutTests/http/tests/workers/service/resources/download-binary.php 2018-02-16 04:27:43 UTC (rev 228551)
@@ -0,0 +1,4 @@
+<?php
+header("Content-Type: application/my-super-binary");
+echo "[1, 2, 3]";
+?>
Added: trunk/LayoutTests/http/tests/workers/service/resources/service-worker-download-worker.js (0 => 228551)
--- trunk/LayoutTests/http/tests/workers/service/resources/service-worker-download-worker.js (rev 0)
+++ trunk/LayoutTests/http/tests/workers/service/resources/service-worker-download-worker.js 2018-02-16 04:27:43 UTC (rev 228551)
@@ -0,0 +1,3 @@
+self.addEventListener("fetch", (event) => {
+ event.respondWith(fetch(event.request.url));
+});
Added: trunk/LayoutTests/http/tests/workers/service/service-worker-download.https-expected.txt (0 => 228551)
--- trunk/LayoutTests/http/tests/workers/service/service-worker-download.https-expected.txt (rev 0)
+++ trunk/LayoutTests/http/tests/workers/service/service-worker-download.https-expected.txt 2018-02-16 04:27:43 UTC (rev 228551)
@@ -0,0 +1,4 @@
+Download started.
+Downloading URL with suggested filename "download-binary.php"
+Download completed.
+
Added: trunk/LayoutTests/http/tests/workers/service/service-worker-download.https.html (0 => 228551)
--- trunk/LayoutTests/http/tests/workers/service/service-worker-download.https.html (rev 0)
+++ trunk/LayoutTests/http/tests/workers/service/service-worker-download.https.html 2018-02-16 04:27:43 UTC (rev 228551)
@@ -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: trunk/Source/WebKit/ChangeLog (228550 => 228551)
--- trunk/Source/WebKit/ChangeLog 2018-02-16 03:28:24 UTC (rev 228550)
+++ trunk/Source/WebKit/ChangeLog 2018-02-16 04:27:43 UTC (rev 228551)
@@ -1,3 +1,20 @@
+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 Megan Gardner <[email protected]>
Support scrolling for non-editable web-selection and start autoscroll when near screen edges
Modified: trunk/Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.cpp (228550 => 228551)
--- trunk/Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.cpp 2018-02-16 03:28:24 UTC (rev 228550)
+++ trunk/Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.cpp 2018-02-16 04:27:43 UTC (rev 228551)
@@ -321,7 +321,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;
}