Title: [224956] trunk
Revision
224956
Author
[email protected]
Date
2017-11-16 18:36:03 -0800 (Thu, 16 Nov 2017)

Log Message

Service Worker should get the body of intercepted requests
https://bugs.webkit.org/show_bug.cgi?id=179776

Patch by Youenn Fablet <[email protected]> on 2017-11-16
Reviewed by Alex Christensen.

LayoutTests/imported/w3c:

* imported/w3c/web-platform-tests/fetch/api/request/request-consume-empty-expected.txt:
* imported/w3c/web-platform-tests/fetch/api/request/request-init-002-expected.txt:
* imported/w3c/web-platform-tests/fetch/api/response/response-consume-empty-expected.txt:
* imported/w3c/web-platform-tests/fetch/api/response/response-consume-expected.txt:
* imported/w3c/web-platform-tests/fetch/api/response/response-init-002-expected.txt:
* web-platform-tests/service-workers/service-worker/fetch-event.https-expected.txt:
* web-platform-tests/service-workers/service-worker/fetch-request-xhr.https-expected.txt:

Source/WebCore:

Test: http/tests/workers/service/service-worker-request-with-body.https.html

Make use of FetchBodyConsumer to store raw data for FetchRequest.
This is used when setting FetchRequest body from a FormData.
If FormData is only bytes (no blob, no file), FetchBodyConsumer will store that data.
This allows Service Worker to get access to simple request bodies.

* Modules/fetch/FetchBody.cpp:
(WebCore::FetchBody::fromFormData):
(WebCore::FetchBody::consume):
(WebCore::FetchBody::bodyAsFormData const): Making sure body is set appropriately when used to make fetch load.
* Modules/fetch/FetchBody.h: Making some methods private.
* Modules/fetch/FetchBodyConsumer.h: Adding accessors.
(WebCore::FetchBodyConsumer::hasData const):
(WebCore::FetchBodyConsumer::data const):
* Modules/fetch/FetchRequest.h:
(WebCore::FetchRequest::FetchRequest):
* platform/network/FormData.cpp:
(WebCore::FormData::asSharedBuffer const):
* platform/network/FormData.h:
* workers/service/context/ServiceWorkerFetch.cpp:
(WebCore::ServiceWorkerFetch::dispatchFetchEvent): Setting FetchRequest body based on given FormData.

Source/WebKit:

Pass a FormDataReference when starting fetch IPC.
Convert this FormDataReference in a FormData and using it to set the FetchRequest body properly in Service Worker process.
Forbid fetch interception when URL is not HTTP/HTTPS.

* Platform/IPC/FormDataReference.h:
(IPC::FormDataReference::FormDataReference):
(IPC::FormDataReference::takeData):
(IPC::FormDataReference::encode const):
(IPC::FormDataReference::decode):
* StorageProcess/ServiceWorker/WebSWServerConnection.cpp:
(WebKit::WebSWServerConnection::startFetch):
* StorageProcess/ServiceWorker/WebSWServerConnection.h:
* StorageProcess/ServiceWorker/WebSWServerConnection.messages.in:
* WebProcess/Storage/WebSWClientConnection.cpp:
(WebKit::WebSWClientConnection::startFetch):
* WebProcess/Storage/WebSWContextManagerConnection.cpp:
(WebKit::WebSWContextManagerConnection::startFetch):
* WebProcess/Storage/WebSWContextManagerConnection.h:
* WebProcess/Storage/WebSWContextManagerConnection.messages.in:
* WebProcess/Storage/WebServiceWorkerProvider.cpp:
(WebKit::WebServiceWorkerProvider::handleFetch):

LayoutTests:

* http/tests/workers/service/resources/service-worker-fetch.js:
* http/tests/workers/service/service-worker-fetch.https-expected.txt:
* http/tests/workers/service/resources/service-worker-request-with-body-worker.js: Added.
* http/tests/workers/service/service-worker-request-with-body.https-expected.txt: Added.
* http/tests/workers/service/service-worker-request-with-body.https.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (224955 => 224956)


--- trunk/LayoutTests/ChangeLog	2017-11-17 02:32:12 UTC (rev 224955)
+++ trunk/LayoutTests/ChangeLog	2017-11-17 02:36:03 UTC (rev 224956)
@@ -1,3 +1,16 @@
+2017-11-16  Youenn Fablet  <[email protected]>
+
+        Service Worker should get the body of intercepted requests
+        https://bugs.webkit.org/show_bug.cgi?id=179776
+
+        Reviewed by Alex Christensen.
+
+        * http/tests/workers/service/resources/service-worker-fetch.js:
+        * http/tests/workers/service/service-worker-fetch.https-expected.txt:
+        * http/tests/workers/service/resources/service-worker-request-with-body-worker.js: Added.
+        * http/tests/workers/service/service-worker-request-with-body.https-expected.txt: Added.
+        * http/tests/workers/service/service-worker-request-with-body.https.html: Added.
+
 2017-11-16  Nan Wang  <[email protected]>
 
         AX: AOM: Implement string type properties

Modified: trunk/LayoutTests/http/tests/workers/service/resources/service-worker-fetch.js (224955 => 224956)


--- trunk/LayoutTests/http/tests/workers/service/resources/service-worker-fetch.js	2017-11-17 02:32:12 UTC (rev 224955)
+++ trunk/LayoutTests/http/tests/workers/service/resources/service-worker-fetch.js	2017-11-17 02:36:03 UTC (rev 224956)
@@ -12,9 +12,17 @@
         log("Got image response with buffer byte length being " + buffer.byteLength);
 
         response = await fetch("/resources/square100.png.bodyasanemptystream");
-        var buffer =  await response.arrayBuffer();
+        buffer =  await response.arrayBuffer();
         log("Got should-be-empty response with buffer byte length being " + buffer.byteLength + " and status is " + response.statusText);
 
+        response = await fetch("data:text/plain;base64,cmVzcG9uc2UncyBib2R5");
+        var text  =  await response.text();
+        log("Got data URL response with data="" + text + "\" and status is " + response.statusText);
+
+        response = await fetch(window.URL.createObjectURL(new Blob(["PASS"])));
+        text =  await response.text();
+        log("Got blob response with data="" + text + "\" and status is " + response.statusText);
+
         response = await fetch("status");
         log("Status is " + response.statusText);
     } catch(e) {

Added: trunk/LayoutTests/http/tests/workers/service/resources/service-worker-request-with-body-worker.js (0 => 224956)


--- trunk/LayoutTests/http/tests/workers/service/resources/service-worker-request-with-body-worker.js	                        (rev 0)
+++ trunk/LayoutTests/http/tests/workers/service/resources/service-worker-request-with-body-worker.js	2017-11-17 02:36:03 UTC (rev 224956)
@@ -0,0 +1,21 @@
+self.addEventListener("fetch", (event) => {
+    if (event.request.url.endsWith("request-with-text-body.fromserviceworker")) {
+        event.respondWith(
+            event.request.text().then(value => {
+                return new Response(value);
+            })
+        );
+        return;
+    }
+    if (event.request.url.endsWith("request-with-cloned-text-body.fromserviceworker")) {
+        event.respondWith(
+            event.request.clone().text().then(value => {
+                return new Response(value);
+            })
+        );
+    }
+    if (event.request.url.endsWith("post-echo.cgi")) {
+        event.respondWith(fetch(event.request));
+        return;
+    }
+});

Modified: trunk/LayoutTests/http/tests/workers/service/service-worker-fetch.https-expected.txt (224955 => 224956)


--- trunk/LayoutTests/http/tests/workers/service/service-worker-fetch.https-expected.txt	2017-11-17 02:32:12 UTC (rev 224955)
+++ trunk/LayoutTests/http/tests/workers/service/service-worker-fetch.https-expected.txt	2017-11-17 02:36:03 UTC (rev 224956)
@@ -2,5 +2,7 @@
 Status is no status
 Got image response with buffer byte length being 12940
 Got should-be-empty response with buffer byte length being 0 and status is Empty stream
+Got data URL response with data="" body" and status is OK
+Got blob response with data="" and status is OK
 Status is https://127.0.0.1:8443/resources/square100.png through fetch
 

Added: trunk/LayoutTests/http/tests/workers/service/service-worker-request-with-body.https-expected.txt (0 => 224956)


--- trunk/LayoutTests/http/tests/workers/service/service-worker-request-with-body.https-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/http/tests/workers/service/service-worker-request-with-body.https-expected.txt	2017-11-17 02:36:03 UTC (rev 224956)
@@ -0,0 +1,8 @@
+
+
+PASS Setup test 
+PASS Request with text body 
+PASS Request with arrayBuffer body 
+PASS Request with cloned text body 
+PASS Request with text body then fetched 
+

Added: trunk/LayoutTests/http/tests/workers/service/service-worker-request-with-body.https.html (0 => 224956)


--- trunk/LayoutTests/http/tests/workers/service/service-worker-request-with-body.https.html	                        (rev 0)
+++ trunk/LayoutTests/http/tests/workers/service/service-worker-request-with-body.https.html	2017-11-17 02:36:03 UTC (rev 224956)
@@ -0,0 +1,63 @@
+<html>
+<head>
+<script src=""
+<script src=""
+</head>
+<body>
+<script>
+async function interceptedFrame(workerURL, scopeURL)
+{
+    var registration = await navigator.serviceWorker.register(workerURL, { scope : scopeURL });
+    await new Promise(resolve => {
+        if (registration.active)
+            resolve();
+        worker = registration.installing;
+        if (worker.state === "activated")
+            resolve();
+        worker.addEventListener("statechange", () => {
+            if (worker.state === "activated")
+                resolve();
+        });
+    });
+
+    return await new Promise((resolve) => {
+        var frame = document.createElement('iframe');
+        frame.src = ""
+        frame._onload_ = function() { resolve(frame); };
+        document.body.appendChild(frame);
+    });
+}
+
+var fetch;
+
+promise_test(async (test) => {
+    var frame = await interceptedFrame("resources/service-worker-request-with-body-worker.js", "/");
+    fetch = frame.contentWindow.fetch;
+}, "Setup test");
+
+promise_test(async (test) => {
+    response = await fetch("request-with-text-body.fromserviceworker", { method: "POST", body: "PASS" });
+    var buffer =  await response.text();
+    assert_equals(buffer, "PASS");
+}, "Request with text body");
+
+promise_test(async (test) => {
+    response = await fetch("request-with-text-body.fromserviceworker", { method: "POST", body: new TextEncoder().encode("PASS") });
+    var buffer =  await response.text();
+    assert_equals(buffer, "PASS");
+}, "Request with arrayBuffer body");
+
+promise_test(async (test) => {
+    response = await fetch("request-with-cloned-text-body.fromserviceworker", { method: "POST", body: "PASS" });
+    var buffer =  await response.text();
+    assert_equals(buffer, "PASS");
+}, "Request with cloned text body");
+
+promise_test(async (test) => {
+    response = await fetch("/xmlhttprequest/resources/post-echo.cgi", { method: "POST", body: "PASS" });
+    var buffer =  await response.text();
+    assert_equals(buffer, "PASS");
+}, "Request with text body then fetched");
+</script>
+</body>
+</html>

Modified: trunk/LayoutTests/imported/w3c/ChangeLog (224955 => 224956)


--- trunk/LayoutTests/imported/w3c/ChangeLog	2017-11-17 02:32:12 UTC (rev 224955)
+++ trunk/LayoutTests/imported/w3c/ChangeLog	2017-11-17 02:36:03 UTC (rev 224956)
@@ -1,3 +1,18 @@
+2017-11-16  Youenn Fablet  <[email protected]>
+
+        Service Worker should get the body of intercepted requests
+        https://bugs.webkit.org/show_bug.cgi?id=179776
+
+        Reviewed by Alex Christensen.
+
+        * imported/w3c/web-platform-tests/fetch/api/request/request-consume-empty-expected.txt:
+        * imported/w3c/web-platform-tests/fetch/api/request/request-init-002-expected.txt:
+        * imported/w3c/web-platform-tests/fetch/api/response/response-consume-empty-expected.txt:
+        * imported/w3c/web-platform-tests/fetch/api/response/response-consume-expected.txt:
+        * imported/w3c/web-platform-tests/fetch/api/response/response-init-002-expected.txt:
+        * web-platform-tests/service-workers/service-worker/fetch-event.https-expected.txt:
+        * web-platform-tests/service-workers/service-worker/fetch-request-xhr.https-expected.txt:
+
 2017-11-16  Chris Dumez  <[email protected]>
 
         [Service Worker] Implement "Try Clear Registration" algorithm

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/request/request-consume-empty-expected.txt (224955 => 224956)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/request/request-consume-empty-expected.txt	2017-11-17 02:32:12 UTC (rev 224955)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/request/request-consume-empty-expected.txt	2017-11-17 02:36:03 UTC (rev 224956)
@@ -11,6 +11,6 @@
 PASS Consume empty blob request body as text 
 PASS Consume empty text request body as text 
 PASS Consume empty URLSearchParams request body as text 
-FAIL Consume empty FormData request body as text promise_test: Unhandled rejection with value: undefined
+FAIL Consume empty FormData request body as text promise_test: Unhandled rejection with value: object "NotSupportedError: The operation is not supported."
 PASS Consume empty ArrayBuffer request body as text 
 

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/request/request-init-002-expected.txt (224955 => 224956)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/request/request-init-002-expected.txt	2017-11-17 02:32:12 UTC (rev 224955)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/request/request-init-002-expected.txt	2017-11-17 02:36:03 UTC (rev 224956)
@@ -3,7 +3,7 @@
 PASS Initialize Request's body with undefined 
 PASS Initialize Request's body with null 
 PASS Initialize Request's body with application/octet-binary 
-FAIL Initialize Request's body with multipart/form-data promise_test: Unhandled rejection with value: undefined
+FAIL Initialize Request's body with multipart/form-data promise_test: Unhandled rejection with value: object "NotSupportedError: The operation is not supported."
 PASS Initialize Request's body with text/plain;charset=UTF-8 
 PASS Initialize Request's body with application/x-www-form-urlencoded;charset=UTF-8 
 

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-consume-empty-expected.txt (224955 => 224956)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-consume-empty-expected.txt	2017-11-17 02:32:12 UTC (rev 224955)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-consume-empty-expected.txt	2017-11-17 02:36:03 UTC (rev 224956)
@@ -11,6 +11,6 @@
 PASS Consume empty blob response body as text 
 PASS Consume empty text response body as text 
 PASS Consume empty URLSearchParams response body as text 
-FAIL Consume empty FormData response body as text promise_test: Unhandled rejection with value: undefined
+FAIL Consume empty FormData response body as text promise_test: Unhandled rejection with value: object "NotSupportedError: The operation is not supported."
 PASS Consume empty ArrayBuffer response body as text 
 

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-consume-expected.txt (224955 => 224956)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-consume-expected.txt	2017-11-17 02:32:12 UTC (rev 224955)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-consume-expected.txt	2017-11-17 02:36:03 UTC (rev 224956)
@@ -17,9 +17,9 @@
 FAIL Consume response's body: from blob without correct urlencoded type to formData (error case) assert_throws: function "function () { throw e }" threw object "NotSupportedError: The operation is not supported." ("NotSupportedError") expected object "TypeError" ("TypeError")
 FAIL Consume response's body: from FormData to formData promise_test: Unhandled rejection with value: object "NotSupportedError: The operation is not supported."
 FAIL Consume response's body: from FormData without correct type to formData (error case) assert_throws: function "function () { throw e }" threw object "NotSupportedError: The operation is not supported." ("NotSupportedError") expected object "TypeError" ("TypeError")
-FAIL Consume response's body: from FormData to blob promise_test: Unhandled rejection with value: undefined
-FAIL Consume response's body: from FormData to text promise_test: Unhandled rejection with value: undefined
-FAIL Consume response's body: from FormData to arrayBuffer promise_test: Unhandled rejection with value: undefined
+FAIL Consume response's body: from FormData to blob promise_test: Unhandled rejection with value: object "NotSupportedError: The operation is not supported."
+FAIL Consume response's body: from FormData to text promise_test: Unhandled rejection with value: object "NotSupportedError: The operation is not supported."
+FAIL Consume response's body: from FormData to arrayBuffer promise_test: Unhandled rejection with value: object "NotSupportedError: The operation is not supported."
 FAIL Consume response's body: from URLSearchParams to formData promise_test: Unhandled rejection with value: object "NotSupportedError: The operation is not supported."
 FAIL Consume response's body: from URLSearchParams without correct type to formData (error case) assert_throws: function "function () { throw e }" threw object "NotSupportedError: The operation is not supported." ("NotSupportedError") expected object "TypeError" ("TypeError")
 FAIL Consume response's body: from URLSearchParams to blob assert_equals: Blob body type should be computed from the response Content-Type expected "application/x-www-form-urlencoded;charset=utf-8" but got "application/x-www-form-urlencoded"

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-init-002-expected.txt (224955 => 224956)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-init-002-expected.txt	2017-11-17 02:32:12 UTC (rev 224955)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-init-002-expected.txt	2017-11-17 02:36:03 UTC (rev 224956)
@@ -1,7 +1,7 @@
 
 PASS Initialize Response with headers values 
 PASS Initialize Response's body with application/octet-binary 
-FAIL Initialize Response's body with multipart/form-data promise_test: Unhandled rejection with value: undefined
+FAIL Initialize Response's body with multipart/form-data promise_test: Unhandled rejection with value: object "NotSupportedError: The operation is not supported."
 PASS Initialize Response's body with application/x-www-form-urlencoded;charset=UTF-8 
 PASS Initialize Response's body with text/plain;charset=UTF-8 
 PASS Read Response's body as readableStream 

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/fetch-event.https-expected.txt (224955 => 224956)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/fetch-event.https-expected.txt	2017-11-17 02:32:12 UTC (rev 224955)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/fetch-event.https-expected.txt	2017-11-17 02:36:03 UTC (rev 224956)
@@ -8,7 +8,7 @@
 PASS Service Worker does not respond to fetch event 
 PASS Service Worker responds to fetch event with null response body 
 PASS Service Worker fetches other file in fetch event 
-FAIL Service Worker responds to fetch event with POST form assert_unreached: unexpected rejection: assert_equals: expected "POST:application/x-www-form-urlencoded:testName1=testValue1&testName2=testValue2" but got "POST:application/x-www-form-urlencoded:" Reached unreachable code
+PASS Service Worker responds to fetch event with POST form 
 PASS Multiple calls of respondWith must throw InvalidStateErrors 
 PASS Service Worker event.respondWith must set the used flag 
 PASS Service Worker should expose FetchEvent URL fragments. 
@@ -15,7 +15,7 @@
 FAIL Service Worker responds to fetch event with the correct cache types assert_unreached: unexpected rejection: assert_equals: expected "no-cache" but got "default" Reached unreachable code
 PASS Service Worker should intercept EventSource 
 PASS Service Worker responds to fetch event with the correct integrity_metadata 
-FAIL FetchEvent#body is a string assert_equals: expected "i am the request body" but got ""
+PASS FetchEvent#body is a string 
 FAIL FetchEvent#body is a blob assert_equals: expected "it's me the blob and more blob!" but got ""
 PASS Service Worker responds to fetch event with the correct keepalive value 
 

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/fetch-request-xhr.https-expected.txt (224955 => 224956)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/fetch-request-xhr.https-expected.txt	2017-11-17 02:32:12 UTC (rev 224955)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/fetch-request-xhr.https-expected.txt	2017-11-17 02:36:03 UTC (rev 224956)
@@ -4,11 +4,11 @@
 FAIL event.request has the expected headers for same-origin POST. promise_test: Unhandled rejection with value: object "Error: assert_array_equals: event.request has the expected headers for same-origin POST. lengths differ, expected 2 got 5"
 FAIL event.request has the expected headers for cross-origin GET. promise_test: Unhandled rejection with value: object "Error: assert_array_equals: event.request has the expected headers for cross-origin GET. lengths differ, expected 1 got 4"
 FAIL event.request has the expected headers for cross-origin POST. promise_test: Unhandled rejection with value: object "Error: assert_array_equals: event.request has the expected headers for cross-origin POST. lengths differ, expected 2 got 5"
-FAIL FetchEvent#request.body contains XHR request data (string) promise_test: Unhandled rejection with value: object "Error: assert_equals: expected "test string" but got """
+PASS FetchEvent#request.body contains XHR request data (string) 
 FAIL FetchEvent#request.body contains XHR request data (blob) promise_test: Unhandled rejection with value: object "Error: assert_equals: expected "test blob" but got """
-FAIL FetchEvent#request.method is set to XHR method promise_test: Unhandled rejection with value: object "Error: assert_equals: expected "test string xxx" but got """
-FAIL XHR using OPTIONS method promise_test: Unhandled rejection with value: object "Error: assert_equals: expected "test string xxx" but got """
-FAIL XHR with form data promise_test: Unhandled rejection with value: object "Error: assert_equals: expected "------WebKitFormBoundaryXQcTUBfCg2hFT0zU\r\nContent-Disposition: form-data; name=\"sample string\"\r\n\r\n1234567890\r\n------WebKitFormBoundaryXQcTUBfCg2hFT0zU\r\nContent-Disposition: form-data; name=\"sample blob\"; filename=\"blob\"\r\nContent-Type: application/octet-stream\r\n\r\nblob content\r\n------WebKitFormBoundaryXQcTUBfCg2hFT0zU\r\nContent-Disposition: form-data; name=\"sample file\"; filename=\"file.dat\"\r\nContent-Type: application/octet-stream\r\n\r\nfile content\r\n------WebKitFormBoundaryXQcTUBfCg2hFT0zU--\r\n" but got """
+PASS FetchEvent#request.method is set to XHR method 
+PASS XHR using OPTIONS method 
+FAIL XHR with form data promise_test: Unhandled rejection with value: object "Error: assert_equals: expected "------WebKitFormBoundaryvjEQu9gV1uP6AQOG\r\nContent-Disposition: form-data; name=\"sample string\"\r\n\r\n1234567890\r\n------WebKitFormBoundaryvjEQu9gV1uP6AQOG\r\nContent-Disposition: form-data; name=\"sample blob\"; filename=\"blob\"\r\nContent-Type: application/octet-stream\r\n\r\nblob content\r\n------WebKitFormBoundaryvjEQu9gV1uP6AQOG\r\nContent-Disposition: form-data; name=\"sample file\"; filename=\"file.dat\"\r\nContent-Type: application/octet-stream\r\n\r\nfile content\r\n------WebKitFormBoundaryvjEQu9gV1uP6AQOG--\r\n" but got """
 FAIL XHR with mode/credentials set promise_test: Unhandled rejection with value: object "Error: assert_equals: expected "include" but got "same-origin""
 PASS XHR to data URL 
 PASS restore global state 

Modified: trunk/Source/WebCore/ChangeLog (224955 => 224956)


--- trunk/Source/WebCore/ChangeLog	2017-11-17 02:32:12 UTC (rev 224955)
+++ trunk/Source/WebCore/ChangeLog	2017-11-17 02:36:03 UTC (rev 224956)
@@ -1,3 +1,33 @@
+2017-11-16  Youenn Fablet  <[email protected]>
+
+        Service Worker should get the body of intercepted requests
+        https://bugs.webkit.org/show_bug.cgi?id=179776
+
+        Reviewed by Alex Christensen.
+
+        Test: http/tests/workers/service/service-worker-request-with-body.https.html
+
+        Make use of FetchBodyConsumer to store raw data for FetchRequest.
+        This is used when setting FetchRequest body from a FormData.
+        If FormData is only bytes (no blob, no file), FetchBodyConsumer will store that data.
+        This allows Service Worker to get access to simple request bodies.
+
+        * Modules/fetch/FetchBody.cpp:
+        (WebCore::FetchBody::fromFormData):
+        (WebCore::FetchBody::consume):
+        (WebCore::FetchBody::bodyAsFormData const): Making sure body is set appropriately when used to make fetch load.
+        * Modules/fetch/FetchBody.h: Making some methods private.
+        * Modules/fetch/FetchBodyConsumer.h: Adding accessors.
+        (WebCore::FetchBodyConsumer::hasData const):
+        (WebCore::FetchBodyConsumer::data const):
+        * Modules/fetch/FetchRequest.h:
+        (WebCore::FetchRequest::FetchRequest):
+        * platform/network/FormData.cpp:
+        (WebCore::FormData::asSharedBuffer const):
+        * platform/network/FormData.h:
+        * workers/service/context/ServiceWorkerFetch.cpp:
+        (WebCore::ServiceWorkerFetch::dispatchFetchEvent): Setting FetchRequest body based on given FormData.
+
 2017-11-16  Chris Dumez  <[email protected]>
 
         Make sure service workers get terminated between tests

Modified: trunk/Source/WebCore/Modules/fetch/FetchBody.cpp (224955 => 224956)


--- trunk/Source/WebCore/Modules/fetch/FetchBody.cpp	2017-11-17 02:32:12 UTC (rev 224955)
+++ trunk/Source/WebCore/Modules/fetch/FetchBody.cpp	2017-11-17 02:36:03 UTC (rev 224956)
@@ -69,6 +69,21 @@
     });
 }
 
+std::optional<FetchBody> FetchBody::fromFormData(FormData* formData)
+{
+    if (!formData || formData->isEmpty())
+        return std::nullopt;
+
+    if (auto buffer = formData->asSharedBuffer()) {
+        FetchBody body;
+        body.m_consumer.setData(buffer.releaseNonNull());
+        return WTFMove(body);
+    }
+
+    // FIXME: Support blob and form data bodies.
+    return std::nullopt;
+}
+
 void FetchBody::arrayBuffer(FetchBodyOwner& owner, Ref<DeferredPromise>&& promise)
 {
     m_consumer.setType(FetchBodyConsumer::Type::ArrayBuffer);
@@ -134,7 +149,7 @@
     }
     if (isFormData()) {
         // FIXME: Support consuming FormData.
-        promise->reject();
+        promise->reject(NotSupportedError);
         return;
     }
 
@@ -231,6 +246,9 @@
         body->generateFiles(&downcast<Document>(context));
         return body;
     }
+    if (auto* data = ""
+        return FormData::create(data->data(), data->size());
+
     ASSERT_NOT_REACHED();
     return nullptr;
 }

Modified: trunk/Source/WebCore/Modules/fetch/FetchBody.h (224955 => 224956)


--- trunk/Source/WebCore/Modules/fetch/FetchBody.h	2017-11-17 02:32:12 UTC (rev 224955)
+++ trunk/Source/WebCore/Modules/fetch/FetchBody.h	2017-11-17 02:36:03 UTC (rev 224956)
@@ -54,18 +54,12 @@
     void consumeAsStream(FetchBodyOwner&, FetchBodySource&);
 #endif
 
-    bool isBlob() const { return WTF::holds_alternative<Ref<const Blob>>(m_data); }
-    bool isFormData() const { return WTF::holds_alternative<Ref<FormData>>(m_data); }
-    bool isArrayBuffer() const { return WTF::holds_alternative<Ref<const ArrayBuffer>>(m_data); }
-    bool isArrayBufferView() const { return WTF::holds_alternative<Ref<const ArrayBufferView>>(m_data); }
-    bool isURLSearchParams() const { return WTF::holds_alternative<Ref<const URLSearchParams>>(m_data); }
-    bool isText() const { return WTF::holds_alternative<String>(m_data); }
-    bool hasReadableStream() const { return !!m_readableStream; }
-
     using Init = Variant<RefPtr<Blob>, RefPtr<ArrayBufferView>, RefPtr<ArrayBuffer>, RefPtr<DOMFormData>, RefPtr<URLSearchParams>, RefPtr<ReadableStream>, String>;
     static FetchBody extract(ScriptExecutionContext&, Init&&, String&);
     FetchBody() = default;
 
+    static std::optional<FetchBody> fromFormData(FormData*);
+
     void loadingFailed();
     void loadingSucceeded();
 
@@ -81,6 +75,8 @@
     void cleanConsumer() { m_consumer.clean(); }
 
     FetchBody clone();
+
+    bool hasReadableStream() const { return !!m_readableStream; }
     const ReadableStream* readableStream() const { return m_readableStream.get(); }
     ReadableStream* readableStream() { return m_readableStream.get(); }
     void setReadableStream(Ref<ReadableStream>&& stream)
@@ -106,6 +102,13 @@
     void consumeText(Ref<DeferredPromise>&&, const String&);
     void consumeBlob(FetchBodyOwner&, Ref<DeferredPromise>&&);
 
+    bool isBlob() const { return WTF::holds_alternative<Ref<const Blob>>(m_data); }
+    bool isFormData() const { return WTF::holds_alternative<Ref<FormData>>(m_data); }
+    bool isArrayBuffer() const { return WTF::holds_alternative<Ref<const ArrayBuffer>>(m_data); }
+    bool isArrayBufferView() const { return WTF::holds_alternative<Ref<const ArrayBufferView>>(m_data); }
+    bool isURLSearchParams() const { return WTF::holds_alternative<Ref<const URLSearchParams>>(m_data); }
+    bool isText() const { return WTF::holds_alternative<String>(m_data); }
+
     const Blob& blobBody() const { return WTF::get<Ref<const Blob>>(m_data).get(); }
     FormData& formDataBody() { return WTF::get<Ref<FormData>>(m_data).get(); }
     const FormData& formDataBody() const { return WTF::get<Ref<FormData>>(m_data).get(); }

Modified: trunk/Source/WebCore/Modules/fetch/FetchBodyConsumer.h (224955 => 224956)


--- trunk/Source/WebCore/Modules/fetch/FetchBodyConsumer.h	2017-11-17 02:32:12 UTC (rev 224955)
+++ trunk/Source/WebCore/Modules/fetch/FetchBodyConsumer.h	2017-11-17 02:36:03 UTC (rev 224956)
@@ -48,6 +48,8 @@
     void append(const char* data, unsigned);
     void append(const unsigned char* data, unsigned);
 
+    bool hasData() const { return !!m_buffer; }
+    const SharedBuffer* data() const { return m_buffer.get(); }
     void setData(Ref<SharedBuffer>&& data) { m_buffer = WTFMove(data); }
 
     RefPtr<SharedBuffer> takeData();
@@ -64,8 +66,6 @@
     void resolve(Ref<DeferredPromise>&&, ReadableStream*);
     void resolveWithData(Ref<DeferredPromise>&&, const unsigned char*, unsigned);
 
-    bool hasData() const { return !!m_buffer; }
-
     void loadingFailed();
     void loadingSucceeded();
 

Modified: trunk/Source/WebCore/Modules/fetch/FetchRequest.h (224955 => 224956)


--- trunk/Source/WebCore/Modules/fetch/FetchRequest.h	2017-11-17 02:32:12 UTC (rev 224955)
+++ trunk/Source/WebCore/Modules/fetch/FetchRequest.h	2017-11-17 02:36:03 UTC (rev 224956)
@@ -104,6 +104,7 @@
     , m_options(WTFMove(options))
     , m_referrer(WTFMove(referrer))
 {
+    updateContentType();
 }
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/platform/network/FormData.cpp (224955 => 224956)


--- trunk/Source/WebCore/platform/network/FormData.cpp	2017-11-17 02:32:12 UTC (rev 224955)
+++ trunk/Source/WebCore/platform/network/FormData.cpp	2017-11-17 02:36:03 UTC (rev 224956)
@@ -428,4 +428,13 @@
     return *m_lengthInBytes;
 }
 
+RefPtr<SharedBuffer> FormData::asSharedBuffer() const
+{
+    for (auto& element : m_elements) {
+        if (element.m_type != FormDataElement::Type::Data)
+            return nullptr;
+    }
+    return SharedBuffer::create(flatten());
+}
+
 } // namespace WebCore

Modified: trunk/Source/WebCore/platform/network/FormData.h (224955 => 224956)


--- trunk/Source/WebCore/platform/network/FormData.h	2017-11-17 02:32:12 UTC (rev 224955)
+++ trunk/Source/WebCore/platform/network/FormData.h	2017-11-17 02:36:03 UTC (rev 224956)
@@ -31,6 +31,7 @@
 class DOMFormData;
 class Document;
 class File;
+class SharedBuffer;
 class TextEncoding;
 
 class FormDataElement {
@@ -234,6 +235,8 @@
     const Vector<FormDataElement>& elements() const { return m_elements; }
     const Vector<char>& boundary() const { return m_boundary; }
 
+    RefPtr<SharedBuffer> asSharedBuffer() const;
+
     void generateFiles(Document*);
     void removeGeneratedFilesIfNeeded();
 

Modified: trunk/Source/WebCore/workers/service/context/ServiceWorkerFetch.cpp (224955 => 224956)


--- trunk/Source/WebCore/workers/service/context/ServiceWorkerFetch.cpp	2017-11-17 02:32:12 UTC (rev 224955)
+++ trunk/Source/WebCore/workers/service/context/ServiceWorkerFetch.cpp	2017-11-17 02:36:03 UTC (rev 224956)
@@ -93,9 +93,9 @@
 {
     ASSERT(globalScope.isServiceWorkerGlobalScope());
 
-    // FIXME: Set request body and referrer.
+    // FIXME: Set request referrer.
     auto requestHeaders = FetchHeaders::create(FetchHeaders::Guard::Immutable, HTTPHeaderMap { request.httpHeaderFields() });
-    auto fetchRequest = FetchRequest::create(globalScope, std::nullopt, WTFMove(requestHeaders),  WTFMove(request), WTFMove(options), { });
+    auto fetchRequest = FetchRequest::create(globalScope, FetchBody::fromFormData(request.httpBody()), WTFMove(requestHeaders),  WTFMove(request), WTFMove(options), { });
 
     // FIXME: Initialize other FetchEvent::Init fields.
     FetchEvent::Init init;

Modified: trunk/Source/WebKit/ChangeLog (224955 => 224956)


--- trunk/Source/WebKit/ChangeLog	2017-11-17 02:32:12 UTC (rev 224955)
+++ trunk/Source/WebKit/ChangeLog	2017-11-17 02:36:03 UTC (rev 224956)
@@ -1,3 +1,32 @@
+2017-11-16  Youenn Fablet  <[email protected]>
+
+        Service Worker should get the body of intercepted requests
+        https://bugs.webkit.org/show_bug.cgi?id=179776
+
+        Reviewed by Alex Christensen.
+
+        Pass a FormDataReference when starting fetch IPC.
+        Convert this FormDataReference in a FormData and using it to set the FetchRequest body properly in Service Worker process.
+        Forbid fetch interception when URL is not HTTP/HTTPS.
+
+        * Platform/IPC/FormDataReference.h:
+        (IPC::FormDataReference::FormDataReference):
+        (IPC::FormDataReference::takeData):
+        (IPC::FormDataReference::encode const):
+        (IPC::FormDataReference::decode):
+        * StorageProcess/ServiceWorker/WebSWServerConnection.cpp:
+        (WebKit::WebSWServerConnection::startFetch):
+        * StorageProcess/ServiceWorker/WebSWServerConnection.h:
+        * StorageProcess/ServiceWorker/WebSWServerConnection.messages.in:
+        * WebProcess/Storage/WebSWClientConnection.cpp:
+        (WebKit::WebSWClientConnection::startFetch):
+        * WebProcess/Storage/WebSWContextManagerConnection.cpp:
+        (WebKit::WebSWContextManagerConnection::startFetch):
+        * WebProcess/Storage/WebSWContextManagerConnection.h:
+        * WebProcess/Storage/WebSWContextManagerConnection.messages.in:
+        * WebProcess/Storage/WebServiceWorkerProvider.cpp:
+        (WebKit::WebServiceWorkerProvider::handleFetch):
+
 2017-11-16  Daniel Bates  <[email protected]>
 
         Add feature define for alternative presentation button element

Modified: trunk/Source/WebKit/Platform/IPC/FormDataReference.h (224955 => 224956)


--- trunk/Source/WebKit/Platform/IPC/FormDataReference.h	2017-11-17 02:32:12 UTC (rev 224955)
+++ trunk/Source/WebKit/Platform/IPC/FormDataReference.h	2017-11-17 02:36:03 UTC (rev 224956)
@@ -28,27 +28,40 @@
 #include "Decoder.h"
 #include "Encoder.h"
 #include <WebCore/FormData.h>
-#include <wtf/Vector.h>
 
 namespace IPC {
 
+// FIXME: In case of file based form data, we should pass sandbox extensions as well.
 class FormDataReference {
 public:
     FormDataReference() = default;
-
-    explicit FormDataReference(Ref<WebCore::FormData>&& data)
+    explicit FormDataReference(RefPtr<WebCore::FormData>&& data)
         : m_data(WTFMove(data))
     {
     }
 
-    Ref<WebCore::FormData> takeData() { return m_data.releaseNonNull(); }
+    RefPtr<WebCore::FormData> takeData() { return WTFMove(m_data); }
 
-    void encode(Encoder& encoder) const { encoder << *m_data; }
+    void encode(Encoder& encoder) const
+    {
+        encoder << !!m_data;
+        if (m_data)
+            encoder << *m_data;
+    }
+
     static std::optional<FormDataReference> decode(Decoder& decoder)
     {
+        std::optional<bool> hasFormData;
+        decoder >> hasFormData;
+        if (!hasFormData)
+            return std::nullopt;
+        if (!hasFormData.value())
+            return FormDataReference { };
+
         auto formData = WebCore::FormData::decode(decoder);
         if (!formData)
             return std::nullopt;
+
         return FormDataReference { formData.releaseNonNull() };
     }
 

Modified: trunk/Source/WebKit/StorageProcess/ServiceWorker/WebSWServerConnection.cpp (224955 => 224956)


--- trunk/Source/WebKit/StorageProcess/ServiceWorker/WebSWServerConnection.cpp	2017-11-17 02:32:12 UTC (rev 224955)
+++ trunk/Source/WebKit/StorageProcess/ServiceWorker/WebSWServerConnection.cpp	2017-11-17 02:36:03 UTC (rev 224956)
@@ -107,9 +107,9 @@
     send(Messages::WebSWClientConnection::UpdateWorkerState(worker, state));
 }
 
-void WebSWServerConnection::startFetch(uint64_t fetchIdentifier, std::optional<ServiceWorkerIdentifier> serviceWorkerIdentifier, const ResourceRequest& request, const FetchOptions& options)
+void WebSWServerConnection::startFetch(uint64_t fetchIdentifier, std::optional<ServiceWorkerIdentifier> serviceWorkerIdentifier, const ResourceRequest& request, const FetchOptions& options, const IPC::FormDataReference& formData)
 {
-    sendToContextProcess(Messages::WebSWContextManagerConnection::StartFetch(identifier(), fetchIdentifier, serviceWorkerIdentifier, request, options));
+    sendToContextProcess(Messages::WebSWContextManagerConnection::StartFetch { identifier(), fetchIdentifier, serviceWorkerIdentifier, request, options, formData });
 }
 
 void WebSWServerConnection::postMessageToServiceWorkerGlobalScope(ServiceWorkerIdentifier destinationServiceWorkerIdentifier, const IPC::DataReference& message, ServiceWorkerClientData&& source)

Modified: trunk/Source/WebKit/StorageProcess/ServiceWorker/WebSWServerConnection.h (224955 => 224956)


--- trunk/Source/WebKit/StorageProcess/ServiceWorker/WebSWServerConnection.h	2017-11-17 02:32:12 UTC (rev 224955)
+++ trunk/Source/WebKit/StorageProcess/ServiceWorker/WebSWServerConnection.h	2017-11-17 02:36:03 UTC (rev 224956)
@@ -74,7 +74,7 @@
     void updateWorkerStateInClient(WebCore::ServiceWorkerIdentifier, WebCore::ServiceWorkerState) final;
     void fireUpdateFoundEvent(WebCore::ServiceWorkerRegistrationIdentifier) final;
 
-    void startFetch(uint64_t fetchIdentifier, std::optional<WebCore::ServiceWorkerIdentifier>, const WebCore::ResourceRequest&, const WebCore::FetchOptions&);
+    void startFetch(uint64_t fetchIdentifier, std::optional<WebCore::ServiceWorkerIdentifier>, const WebCore::ResourceRequest&, const WebCore::FetchOptions&, const IPC::FormDataReference&);
 
     void postMessageToServiceWorkerGlobalScope(WebCore::ServiceWorkerIdentifier destinationIdentifier, const IPC::DataReference& message, WebCore::ServiceWorkerClientData&& source);
 

Modified: trunk/Source/WebKit/StorageProcess/ServiceWorker/WebSWServerConnection.messages.in (224955 => 224956)


--- trunk/Source/WebKit/StorageProcess/ServiceWorker/WebSWServerConnection.messages.in	2017-11-17 02:32:12 UTC (rev 224955)
+++ trunk/Source/WebKit/StorageProcess/ServiceWorker/WebSWServerConnection.messages.in	2017-11-17 02:36:03 UTC (rev 224956)
@@ -31,7 +31,7 @@
     ServiceWorkerStartedControllingClient(WebCore::ServiceWorkerIdentifier serviceWorkerIdentifier, uint64_t scriptExecutionContextIdentifier)
     ServiceWorkerStoppedControllingClient(WebCore::ServiceWorkerIdentifier serviceWorkerIdentifier, uint64_t scriptExecutionContextIdentifier)
 
-    StartFetch(uint64_t identifier, std::optional<WebCore::ServiceWorkerIdentifier> serviceWorkerIdentifier, WebCore::ResourceRequest request, struct WebCore::FetchOptions options)
+    StartFetch(uint64_t identifier, std::optional<WebCore::ServiceWorkerIdentifier> serviceWorkerIdentifier, WebCore::ResourceRequest request, struct WebCore::FetchOptions options, IPC::FormDataReference requestBody)
     PostMessageToServiceWorkerGlobalScope(WebCore::ServiceWorkerIdentifier destinationServiceWorkerIdentifier, IPC::DataReference message, struct WebCore::ServiceWorkerClientData source)
 
     DidResolveRegistrationPromise(WebCore::ServiceWorkerRegistrationKey key)

Modified: trunk/Source/WebKit/WebProcess/Storage/WebSWClientConnection.cpp (224955 => 224956)


--- trunk/Source/WebKit/WebProcess/Storage/WebSWClientConnection.cpp	2017-11-17 02:32:12 UTC (rev 224955)
+++ trunk/Source/WebKit/WebProcess/Storage/WebSWClientConnection.cpp	2017-11-17 02:36:03 UTC (rev 224956)
@@ -29,6 +29,7 @@
 #if ENABLE(SERVICE_WORKER)
 
 #include "DataReference.h"
+#include "FormDataReference.h"
 #include "Logging.h"
 #include "ServiceWorkerClientFetch.h"
 #include "StorageToWebProcessConnectionMessages.h"
@@ -159,7 +160,7 @@
 {
     ASSERT(loader->options().serviceWorkersMode != ServiceWorkersMode::None && loader->options().serviceWorkerIdentifier);
 
-    send(Messages::WebSWServerConnection::StartFetch(identifier, loader->options().serviceWorkerIdentifier, loader->originalRequest(), loader->options()));
+    send(Messages::WebSWServerConnection::StartFetch { identifier, loader->options().serviceWorkerIdentifier, loader->originalRequest(), loader->options(), IPC::FormDataReference { loader->originalRequest().httpBody() } });
     return ServiceWorkerClientFetch::create(provider, WTFMove(loader), identifier, m_connection.get(), WTFMove(callback));
 }
 

Modified: trunk/Source/WebKit/WebProcess/Storage/WebSWContextManagerConnection.cpp (224955 => 224956)


--- trunk/Source/WebKit/WebProcess/Storage/WebSWContextManagerConnection.cpp	2017-11-17 02:32:12 UTC (rev 224955)
+++ trunk/Source/WebKit/WebProcess/Storage/WebSWContextManagerConnection.cpp	2017-11-17 02:36:03 UTC (rev 224956)
@@ -29,6 +29,7 @@
 #if ENABLE(SERVICE_WORKER)
 
 #include "DataReference.h"
+#include "FormDataReference.h"
 #include "Logging.h"
 #include "StorageProcessMessages.h"
 #include "WebCacheStorageProvider.h"
@@ -131,7 +132,7 @@
         m_connectionToStorageProcess->send(Messages::WebSWServerToContextConnection::ScriptContextFailedToStart(serviceWorkerIdentifier, exceptionMessage), 0);
 }
 
-void WebSWContextManagerConnection::startFetch(uint64_t serverConnectionIdentifier, uint64_t fetchIdentifier, std::optional<ServiceWorkerIdentifier> serviceWorkerIdentifier, ResourceRequest&& request, FetchOptions&& options)
+void WebSWContextManagerConnection::startFetch(uint64_t serverConnectionIdentifier, uint64_t fetchIdentifier, std::optional<ServiceWorkerIdentifier> serviceWorkerIdentifier, ResourceRequest&& request, FetchOptions&& options, IPC::FormDataReference&& formData)
 {
     auto* serviceWorkerThreadProxy = serviceWorkerIdentifier ? SWContextManager::singleton().serviceWorkerThreadProxy(*serviceWorkerIdentifier) : nullptr;
     if (!serviceWorkerThreadProxy) {
@@ -140,6 +141,8 @@
     }
 
     auto client = WebServiceWorkerFetchTaskClient::create(m_connectionToStorageProcess.copyRef(), serverConnectionIdentifier, fetchIdentifier);
+
+    request.setHTTPBody(formData.takeData());
     serviceWorkerThreadProxy->thread().postFetchTask(WTFMove(client), WTFMove(request), WTFMove(options));
 }
 

Modified: trunk/Source/WebKit/WebProcess/Storage/WebSWContextManagerConnection.h (224955 => 224956)


--- trunk/Source/WebKit/WebProcess/Storage/WebSWContextManagerConnection.h	2017-11-17 02:32:12 UTC (rev 224955)
+++ trunk/Source/WebKit/WebProcess/Storage/WebSWContextManagerConnection.h	2017-11-17 02:36:03 UTC (rev 224956)
@@ -31,6 +31,10 @@
 #include "MessageReceiver.h"
 #include <WebCore/SWContextManager.h>
 
+namespace IPC {
+class FormDataReference;
+}
+
 namespace WebCore {
 struct FetchOptions;
 class ResourceRequest;
@@ -60,7 +64,7 @@
     // IPC messages.
     void serviceWorkerStartedWithMessage(WebCore::ServiceWorkerIdentifier, const String& exceptionMessage) final;
     void installServiceWorker(const WebCore::ServiceWorkerContextData&);
-    void startFetch(uint64_t serverConnectionIdentifier, uint64_t fetchIdentifier, std::optional<WebCore::ServiceWorkerIdentifier>, WebCore::ResourceRequest&&, WebCore::FetchOptions&&);
+    void startFetch(uint64_t serverConnectionIdentifier, uint64_t fetchIdentifier, std::optional<WebCore::ServiceWorkerIdentifier>, WebCore::ResourceRequest&&, WebCore::FetchOptions&&, IPC::FormDataReference&&);
     void postMessageToServiceWorkerGlobalScope(WebCore::ServiceWorkerIdentifier destinationIdentifier, const IPC::DataReference& message, WebCore::ServiceWorkerClientData&& source);
     void fireInstallEvent(WebCore::ServiceWorkerIdentifier);
     void fireActivateEvent(WebCore::ServiceWorkerIdentifier);

Modified: trunk/Source/WebKit/WebProcess/Storage/WebSWContextManagerConnection.messages.in (224955 => 224956)


--- trunk/Source/WebKit/WebProcess/Storage/WebSWContextManagerConnection.messages.in	2017-11-17 02:32:12 UTC (rev 224955)
+++ trunk/Source/WebKit/WebProcess/Storage/WebSWContextManagerConnection.messages.in	2017-11-17 02:36:03 UTC (rev 224956)
@@ -24,7 +24,7 @@
 
 messages -> WebSWContextManagerConnection {
     InstallServiceWorker(struct WebCore::ServiceWorkerContextData contextData)
-    StartFetch(uint64_t serverConnectionIdentifier, uint64_t fetchIdentifier, std::optional<WebCore::ServiceWorkerIdentifier> serviceWorkerIdentifier, WebCore::ResourceRequest request, struct WebCore::FetchOptions options)
+    StartFetch(uint64_t serverConnectionIdentifier, uint64_t fetchIdentifier, std::optional<WebCore::ServiceWorkerIdentifier> serviceWorkerIdentifier, WebCore::ResourceRequest request, struct WebCore::FetchOptions options, IPC::FormDataReference requestBody)
     PostMessageToServiceWorkerGlobalScope(WebCore::ServiceWorkerIdentifier destinationIdentifier, IPC::DataReference message, struct WebCore::ServiceWorkerClientData source)
     FireInstallEvent(WebCore::ServiceWorkerIdentifier identifier)
     FireActivateEvent(WebCore::ServiceWorkerIdentifier identifier)

Modified: trunk/Source/WebKit/WebProcess/Storage/WebServiceWorkerProvider.cpp (224955 => 224956)


--- trunk/Source/WebKit/WebProcess/Storage/WebServiceWorkerProvider.cpp	2017-11-17 02:32:12 UTC (rev 224955)
+++ trunk/Source/WebKit/WebProcess/Storage/WebServiceWorkerProvider.cpp	2017-11-17 02:36:03 UTC (rev 224956)
@@ -72,7 +72,7 @@
 
 void WebServiceWorkerProvider::handleFetch(ResourceLoader& loader, CachedResource* resource, PAL::SessionID sessionID, ServiceWorkerClientFetch::Callback&& callback)
 {
-    if (!shouldHandleFetch(loader.options())) {
+    if (!loader.request().url().protocolIsInHTTPFamily() || !shouldHandleFetch(loader.options())) {
         callback(ServiceWorkerClientFetch::Result::Unhandled);
         return;
     }
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to