Title: [198891] trunk
Revision
198891
Author
[email protected]
Date
2016-03-31 04:05:11 -0700 (Thu, 31 Mar 2016)

Log Message

[Fetch API] Add basic loading of resources for Workers
https://bugs.webkit.org/show_bug.cgi?id=155886

Reviewed by Alex Christensen.

LayoutTests/imported/w3c:

Updating test expectations as new tests are passing.

* web-platform-tests/fetch/api/basic/accept-header-worker-expected.txt:
* web-platform-tests/fetch/api/basic/integrity-worker-expected.txt:
* web-platform-tests/fetch/api/basic/mode-no-cors-worker-expected.txt:
* web-platform-tests/fetch/api/basic/mode-same-origin-worker-expected.txt:
* web-platform-tests/fetch/api/basic/request-forbidden-headers-worker-expected.txt:
* web-platform-tests/fetch/api/basic/request-headers-worker-expected.txt:
* web-platform-tests/fetch/api/basic/scheme-about-worker-expected.txt:
* web-platform-tests/fetch/api/basic/scheme-blob-worker-expected.txt:
* web-platform-tests/fetch/api/basic/scheme-data-worker-expected.txt:
* web-platform-tests/fetch/api/basic/scheme-others-worker-expected.txt:
* web-platform-tests/fetch/api/basic/stream-response-worker-expected.txt:

Source/WebCore:

Adding impplementation to WorkerGlobalScopeFetch::fetch similarly to DOMWindowFetch::fetch.
Refactored code in FetchResponse to share code between the two.

Updated WorkerThreadableLoader to cope with an ASSERT.
The ASSERT ensures that a DocumentThreadableLoader::create returns non null.
In our case, it might happen as all cross origin fetch requests are denied at the moment.
This leads to calling didFail in DocumentThreadableLoader::create call and DocumentThreadableLoader::create to return null.
Updated the ASSERT to ensures that either the load is finished or DocumentThreadableLoader::create does not return null.

Covered by rebased tests.

* Modules/fetch/DOMWindowFetch.cpp:
(WebCore::DOMWindowFetch::fetch):
* Modules/fetch/FetchResponse.cpp:
(WebCore::FetchResponse::startFetching):
(WebCore::FetchResponse::fetch):
* Modules/fetch/FetchResponse.h:
* Modules/fetch/WorkerGlobalScopeFetch.cpp:
(WebCore::WorkerGlobalScopeFetch::fetch):
* Modules/fetch/WorkerGlobalScopeFetch.h:
* loader/WorkerThreadableLoader.cpp:
(WebCore::WorkerThreadableLoader::MainThreadBridge::MainThreadBridge):
(WebCore::WorkerThreadableLoader::MainThreadBridge::didFinishLoading):
(WebCore::WorkerThreadableLoader::MainThreadBridge::didFail):
(WebCore::WorkerThreadableLoader::MainThreadBridge::didFailAccessControlCheck):
(WebCore::WorkerThreadableLoader::MainThreadBridge::didFailRedirectCheck):
* loader/WorkerThreadableLoader.h:

LayoutTests:

Soup and Mac HTTP backends differ on Content-Length header handling.

* platform/gtk/imported/w3c/web-platform-tests/fetch/api/basic/request-headers-worker-expected.txt: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (198890 => 198891)


--- trunk/LayoutTests/ChangeLog	2016-03-31 10:31:28 UTC (rev 198890)
+++ trunk/LayoutTests/ChangeLog	2016-03-31 11:05:11 UTC (rev 198891)
@@ -1,5 +1,16 @@
 2016-03-31  Youenn Fablet  <[email protected]>
 
+        [Fetch API] Add basic loading of resources for Workers
+        https://bugs.webkit.org/show_bug.cgi?id=155886
+
+        Reviewed by Alex Christensen.
+
+        Soup and Mac HTTP backends differ on Content-Length header handling.
+
+        * platform/gtk/imported/w3c/web-platform-tests/fetch/api/basic/request-headers-worker-expected.txt: Added.
+
+2016-03-31  Youenn Fablet  <[email protected]>
+
         Remove forEach use from Fetch Headers builtin constructor
         https://bugs.webkit.org/show_bug.cgi?id=155967
 

Modified: trunk/LayoutTests/imported/w3c/ChangeLog (198890 => 198891)


--- trunk/LayoutTests/imported/w3c/ChangeLog	2016-03-31 10:31:28 UTC (rev 198890)
+++ trunk/LayoutTests/imported/w3c/ChangeLog	2016-03-31 11:05:11 UTC (rev 198891)
@@ -1,5 +1,26 @@
 2016-03-31  Youenn Fablet  <[email protected]>
 
+        [Fetch API] Add basic loading of resources for Workers
+        https://bugs.webkit.org/show_bug.cgi?id=155886
+
+        Reviewed by Alex Christensen.
+
+        Updating test expectations as new tests are passing.
+
+        * web-platform-tests/fetch/api/basic/accept-header-worker-expected.txt:
+        * web-platform-tests/fetch/api/basic/integrity-worker-expected.txt:
+        * web-platform-tests/fetch/api/basic/mode-no-cors-worker-expected.txt:
+        * web-platform-tests/fetch/api/basic/mode-same-origin-worker-expected.txt:
+        * web-platform-tests/fetch/api/basic/request-forbidden-headers-worker-expected.txt:
+        * web-platform-tests/fetch/api/basic/request-headers-worker-expected.txt:
+        * web-platform-tests/fetch/api/basic/scheme-about-worker-expected.txt:
+        * web-platform-tests/fetch/api/basic/scheme-blob-worker-expected.txt:
+        * web-platform-tests/fetch/api/basic/scheme-data-worker-expected.txt:
+        * web-platform-tests/fetch/api/basic/scheme-others-worker-expected.txt:
+        * web-platform-tests/fetch/api/basic/stream-response-worker-expected.txt:
+
+2016-03-31  Youenn Fablet  <[email protected]>
+
         [Fetch API] Update web-platform-test fetch API tests
         https://bugs.webkit.org/show_bug.cgi?id=155969
 

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/basic/accept-header-worker-expected.txt (198890 => 198891)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/basic/accept-header-worker-expected.txt	2016-03-31 10:31:28 UTC (rev 198890)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/basic/accept-header-worker-expected.txt	2016-03-31 11:05:11 UTC (rev 198891)
@@ -1,3 +1,3 @@
 
-FAIL Request through fetch should have 'accept' header with value '*/*' promise_test: Unhandled rejection with value: "Fetch is not yet implemented"
+PASS Request through fetch should have 'accept' header with value '*/*' 
 

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/basic/integrity-worker-expected.txt (198890 => 198891)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/basic/integrity-worker-expected.txt	2016-03-31 10:31:28 UTC (rev 198890)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/basic/integrity-worker-expected.txt	2016-03-31 11:05:11 UTC (rev 198891)
@@ -1,15 +1,15 @@
 
-FAIL Empty string integrity promise_test: Unhandled rejection with value: "Fetch is not yet implemented"
-FAIL SHA-256 integrity promise_test: Unhandled rejection with value: "Fetch is not yet implemented"
-FAIL SHA-384 integrity promise_test: Unhandled rejection with value: "Fetch is not yet implemented"
-FAIL SHA-512 integrity promise_test: Unhandled rejection with value: "Fetch is not yet implemented"
-FAIL Invalid integrity assert_throws: function "function () { throw e }" threw "Fetch is not yet implemented" (undefined) expected object "TypeError" ("TypeError")
-FAIL Multiple integrities: valid stronger than invalid promise_test: Unhandled rejection with value: "Fetch is not yet implemented"
-FAIL Multiple integrities: invalid stronger than valid assert_throws: function "function () { throw e }" threw "Fetch is not yet implemented" (undefined) expected object "TypeError" ("TypeError")
-FAIL Multiple integrities: invalid as strong as valid promise_test: Unhandled rejection with value: "Fetch is not yet implemented"
-FAIL Multiple integrities: both are valid promise_test: Unhandled rejection with value: "Fetch is not yet implemented"
-FAIL Multiple integrities: both are invalid assert_throws: function "function () { throw e }" threw "Fetch is not yet implemented" (undefined) expected object "TypeError" ("TypeError")
-FAIL CORS empty integrity promise_test: Unhandled rejection with value: "Fetch is not yet implemented"
-FAIL CORS SHA-512 integrity promise_test: Unhandled rejection with value: "Fetch is not yet implemented"
-FAIL CORS invalid integrity assert_throws: function "function () { throw e }" threw "Fetch is not yet implemented" (undefined) expected object "TypeError" ("TypeError")
+PASS Empty string integrity 
+PASS SHA-256 integrity 
+PASS SHA-384 integrity 
+PASS SHA-512 integrity 
+FAIL Invalid integrity assert_unreached: Should have rejected. Reached unreachable code
+PASS Multiple integrities: valid stronger than invalid 
+FAIL Multiple integrities: invalid stronger than valid assert_unreached: Should have rejected. Reached unreachable code
+PASS Multiple integrities: invalid as strong as valid 
+PASS Multiple integrities: both are valid 
+FAIL Multiple integrities: both are invalid assert_unreached: Should have rejected. Reached unreachable code
+FAIL CORS empty integrity promise_test: Unhandled rejection with value: object "TypeError: Type error"
+FAIL CORS SHA-512 integrity promise_test: Unhandled rejection with value: object "TypeError: Type error"
+PASS CORS invalid integrity 
 

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/basic/mode-no-cors-worker-expected.txt (198890 => 198891)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/basic/mode-no-cors-worker-expected.txt	2016-03-31 10:31:28 UTC (rev 198890)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/basic/mode-no-cors-worker-expected.txt	2016-03-31 11:05:11 UTC (rev 198891)
@@ -1,6 +1,6 @@
 
-FAIL Fetch ../resources/top.txt with no-cors mode promise_test: Unhandled rejection with value: "Fetch is not yet implemented"
-FAIL Fetch http://localhost:8800/fetch/api/resources/top.txt with no-cors mode promise_test: Unhandled rejection with value: "Fetch is not yet implemented"
-FAIL Fetch https://localhost:9443/fetch/api/resources/top.txt with no-cors mode promise_test: Unhandled rejection with value: "Fetch is not yet implemented"
-FAIL Fetch http://www.localhost:8800/fetch/api/resources/top.txt with no-cors mode promise_test: Unhandled rejection with value: "Fetch is not yet implemented"
+PASS Fetch ../resources/top.txt with no-cors mode 
+PASS Fetch http://localhost:8800/fetch/api/resources/top.txt with no-cors mode 
+FAIL Fetch https://localhost:9443/fetch/api/resources/top.txt with no-cors mode promise_test: Unhandled rejection with value: object "TypeError: Type error"
+FAIL Fetch http://www.localhost:8800/fetch/api/resources/top.txt with no-cors mode promise_test: Unhandled rejection with value: object "TypeError: Type error"
 

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/basic/mode-same-origin-worker-expected.txt (198890 => 198891)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/basic/mode-same-origin-worker-expected.txt	2016-03-31 10:31:28 UTC (rev 198890)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/basic/mode-same-origin-worker-expected.txt	2016-03-31 11:05:11 UTC (rev 198891)
@@ -1,6 +1,6 @@
 
-FAIL Fetch ../resources/top.txt with same-origin mode promise_test: Unhandled rejection with value: "Fetch is not yet implemented"
-FAIL Fetch http://localhost:8800/fetch/api/resources/top.txt with same-origin mode promise_test: Unhandled rejection with value: "Fetch is not yet implemented"
-FAIL Fetch https://localhost:9443/fetch/api/resources/top.txt with same-origin mode assert_throws: function "function () { throw e }" threw "Fetch is not yet implemented" (undefined) expected object "TypeError" ("TypeError")
-FAIL Fetch http://www.localhost:8800/fetch/api/resources/top.txt with same-origin mode assert_throws: function "function () { throw e }" threw "Fetch is not yet implemented" (undefined) expected object "TypeError" ("TypeError")
+PASS Fetch ../resources/top.txt with same-origin mode 
+PASS Fetch http://localhost:8800/fetch/api/resources/top.txt with same-origin mode 
+PASS Fetch https://localhost:9443/fetch/api/resources/top.txt with same-origin mode 
+PASS Fetch http://www.localhost:8800/fetch/api/resources/top.txt with same-origin mode 
 

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/basic/request-forbidden-headers-worker-expected.txt (198890 => 198891)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/basic/request-forbidden-headers-worker-expected.txt	2016-03-31 10:31:28 UTC (rev 198890)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/basic/request-forbidden-headers-worker-expected.txt	2016-03-31 11:05:11 UTC (rev 198891)
@@ -1,26 +1,26 @@
 
-FAIL Accept-Charset is a forbidden request header promise_test: Unhandled rejection with value: "Fetch is not yet implemented"
-FAIL Accept-Encoding is a forbidden request header promise_test: Unhandled rejection with value: "Fetch is not yet implemented"
-FAIL Access-Control-Request-Headers is a forbidden request header promise_test: Unhandled rejection with value: "Fetch is not yet implemented"
-FAIL Access-Control-Request-Method is a forbidden request header promise_test: Unhandled rejection with value: "Fetch is not yet implemented"
-FAIL Connection is a forbidden request header promise_test: Unhandled rejection with value: "Fetch is not yet implemented"
-FAIL Content-Length is a forbidden request header promise_test: Unhandled rejection with value: "Fetch is not yet implemented"
-FAIL Cookie is a forbidden request header promise_test: Unhandled rejection with value: "Fetch is not yet implemented"
-FAIL Cookie2 is a forbidden request header promise_test: Unhandled rejection with value: "Fetch is not yet implemented"
-FAIL Date is a forbidden request header promise_test: Unhandled rejection with value: "Fetch is not yet implemented"
-FAIL DNT is a forbidden request header promise_test: Unhandled rejection with value: "Fetch is not yet implemented"
-FAIL Expect is a forbidden request header promise_test: Unhandled rejection with value: "Fetch is not yet implemented"
-FAIL Host is a forbidden request header promise_test: Unhandled rejection with value: "Fetch is not yet implemented"
-FAIL Keep-Alive is a forbidden request header promise_test: Unhandled rejection with value: "Fetch is not yet implemented"
-FAIL Origin is a forbidden request header promise_test: Unhandled rejection with value: "Fetch is not yet implemented"
-FAIL Referer is a forbidden request header promise_test: Unhandled rejection with value: "Fetch is not yet implemented"
-FAIL TE is a forbidden request header promise_test: Unhandled rejection with value: "Fetch is not yet implemented"
-FAIL Trailer is a forbidden request header promise_test: Unhandled rejection with value: "Fetch is not yet implemented"
-FAIL Transfer-Encoding is a forbidden request header promise_test: Unhandled rejection with value: "Fetch is not yet implemented"
-FAIL Upgrade is a forbidden request header promise_test: Unhandled rejection with value: "Fetch is not yet implemented"
-FAIL Via is a forbidden request header promise_test: Unhandled rejection with value: "Fetch is not yet implemented"
-FAIL Proxy- is a forbidden request header promise_test: Unhandled rejection with value: "Fetch is not yet implemented"
-FAIL Proxy-Test is a forbidden request header promise_test: Unhandled rejection with value: "Fetch is not yet implemented"
-FAIL Sec- is a forbidden request header promise_test: Unhandled rejection with value: "Fetch is not yet implemented"
-FAIL Sec-Test is a forbidden request header promise_test: Unhandled rejection with value: "Fetch is not yet implemented"
+PASS Accept-Charset is a forbidden request header 
+PASS Accept-Encoding is a forbidden request header 
+PASS Access-Control-Request-Headers is a forbidden request header 
+PASS Access-Control-Request-Method is a forbidden request header 
+PASS Connection is a forbidden request header 
+PASS Content-Length is a forbidden request header 
+PASS Cookie is a forbidden request header 
+PASS Cookie2 is a forbidden request header 
+PASS Date is a forbidden request header 
+PASS DNT is a forbidden request header 
+PASS Expect is a forbidden request header 
+PASS Host is a forbidden request header 
+PASS Keep-Alive is a forbidden request header 
+PASS Origin is a forbidden request header 
+PASS Referer is a forbidden request header 
+PASS TE is a forbidden request header 
+PASS Trailer is a forbidden request header 
+PASS Transfer-Encoding is a forbidden request header 
+PASS Upgrade is a forbidden request header 
+PASS Via is a forbidden request header 
+PASS Proxy- is a forbidden request header 
+PASS Proxy-Test is a forbidden request header 
+PASS Sec- is a forbidden request header 
+PASS Sec-Test is a forbidden request header 
 

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/basic/request-headers-worker-expected.txt (198890 => 198891)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/basic/request-headers-worker-expected.txt	2016-03-31 10:31:28 UTC (rev 198890)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/basic/request-headers-worker-expected.txt	2016-03-31 11:05:11 UTC (rev 198891)
@@ -1,11 +1,11 @@
 
-FAIL Fetch with GET promise_test: Unhandled rejection with value: "Fetch is not yet implemented"
-FAIL Fetch with HEAD promise_test: Unhandled rejection with value: "Fetch is not yet implemented"
-FAIL Fetch with HEAD with body promise_test: Unhandled rejection with value: "Fetch is not yet implemented"
-FAIL Fetch with PUT without body promise_test: Unhandled rejection with value: "Fetch is not yet implemented"
-FAIL Fetch with PUT with body promise_test: Unhandled rejection with value: "Fetch is not yet implemented"
-FAIL Fetch with POST without body promise_test: Unhandled rejection with value: "Fetch is not yet implemented"
-FAIL Fetch with POST with body promise_test: Unhandled rejection with value: "Fetch is not yet implemented"
-FAIL Fetch with Chicken promise_test: Unhandled rejection with value: "Fetch is not yet implemented"
-FAIL Fetch with Chicken with body promise_test: Unhandled rejection with value: "Fetch is not yet implemented"
+FAIL Fetch with GET assert_equals: Request has header origin: http://localhost:8800 expected (string) "http://localhost:8800" but got (object) null
+FAIL Fetch with HEAD assert_equals: Request has header origin: http://localhost:8800 expected (string) "http://localhost:8800" but got (object) null
+FAIL Fetch with HEAD with body promise_test: Unhandled rejection with value: object "TypeError: Type error"
+PASS Fetch with PUT without body 
+PASS Fetch with PUT with body 
+PASS Fetch with POST without body 
+PASS Fetch with POST with body 
+FAIL Fetch with Chicken assert_equals: Request has header content-length: null expected (object) null but got (string) "0"
+PASS Fetch with Chicken with body 
 

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/basic/scheme-about-worker-expected.txt (198890 => 198891)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/basic/scheme-about-worker-expected.txt	2016-03-31 10:31:28 UTC (rev 198890)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/basic/scheme-about-worker-expected.txt	2016-03-31 11:05:11 UTC (rev 198891)
@@ -1,6 +1,6 @@
 
-FAIL Fetching about:blank is OK promise_test: Unhandled rejection with value: "Fetch is not yet implemented"
-FAIL Fetching about:unicorn is OK promise_test: Unhandled rejection with value: "Fetch is not yet implemented"
-FAIL Fetching about:invalid.com is KO assert_throws: function "function () { throw e }" threw "Fetch is not yet implemented" (undefined) expected object "TypeError" ("TypeError")
-FAIL Fetching about:config is KO assert_throws: function "function () { throw e }" threw "Fetch is not yet implemented" (undefined) expected object "TypeError" ("TypeError")
+FAIL Fetching about:blank is OK promise_test: Unhandled rejection with value: object "TypeError: Type error"
+FAIL Fetching about:unicorn is OK promise_test: Unhandled rejection with value: object "TypeError: Type error"
+PASS Fetching about:invalid.com is KO 
+PASS Fetching about:config is KO 
 

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/basic/scheme-blob-worker-expected.txt (198890 => 198891)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/basic/scheme-blob-worker-expected.txt	2016-03-31 10:31:28 UTC (rev 198890)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/basic/scheme-blob-worker-expected.txt	2016-03-31 11:05:11 UTC (rev 198891)
@@ -1,5 +1,5 @@
 
-FAIL Fetching [GET] URL.createObjectURL(blob) is OK promise_test: Unhandled rejection with value: "Fetch is not yet implemented"
-FAIL Fetching [GET] blob:http://www.localhost:8800/ is KO assert_throws: function "function () { throw e }" threw "Fetch is not yet implemented" (undefined) expected object "TypeError" ("TypeError")
-FAIL Fetching [POST] URL.createObjectURL(blob) is KO assert_throws: function "function () { throw e }" threw "Fetch is not yet implemented" (undefined) expected object "TypeError" ("TypeError")
+PASS Fetching [GET] URL.createObjectURL(blob) is OK 
+PASS Fetching [GET] blob:http://www.localhost:8800/ is KO 
+FAIL Fetching [POST] URL.createObjectURL(blob) is KO assert_unreached: Should have rejected. Reached unreachable code
 

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/basic/scheme-data-worker-expected.txt (198890 => 198891)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/basic/scheme-data-worker-expected.txt	2016-03-31 10:31:28 UTC (rev 198890)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/basic/scheme-data-worker-expected.txt	2016-03-31 11:05:11 UTC (rev 198891)
@@ -1,8 +1,8 @@
 
-FAIL Fetching data:,response%27s%20body is OK promise_test: Unhandled rejection with value: "Fetch is not yet implemented"
-FAIL Fetching data:text/plain;base64,cmVzcG9uc2UncyBib[...] is OK promise_test: Unhandled rejection with value: "Fetch is not yet implemented"
-FAIL Fetching data:image/png;base64,cmVzcG9uc2UncyBib2[...] is OK promise_test: Unhandled rejection with value: "Fetch is not yet implemented"
-FAIL Fetching [GET] data:notAdataUrl.com is KO assert_throws: function "function () { throw e }" threw "Fetch is not yet implemented" (undefined) expected object "TypeError" ("TypeError")
-FAIL Fetching [POST] data:,response%27s%20body is KO assert_throws: function "function () { throw e }" threw "Fetch is not yet implemented" (undefined) expected object "TypeError" ("TypeError")
-FAIL Fetching [HEAD] data:,response%27s%20body is KO assert_throws: function "function () { throw e }" threw "Fetch is not yet implemented" (undefined) expected object "TypeError" ("TypeError")
+FAIL Fetching data:,response%27s%20body is OK promise_test: Unhandled rejection with value: object "TypeError: Type error"
+FAIL Fetching data:text/plain;base64,cmVzcG9uc2UncyBib[...] is OK promise_test: Unhandled rejection with value: object "TypeError: Type error"
+FAIL Fetching data:image/png;base64,cmVzcG9uc2UncyBib2[...] is OK promise_test: Unhandled rejection with value: object "TypeError: Type error"
+PASS Fetching [GET] data:notAdataUrl.com is KO 
+PASS Fetching [POST] data:,response%27s%20body is KO 
+PASS Fetching [HEAD] data:,response%27s%20body is KO 
 

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/basic/scheme-others-worker-expected.txt (198890 => 198891)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/basic/scheme-others-worker-expected.txt	2016-03-31 10:31:28 UTC (rev 198890)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/basic/scheme-others-worker-expected.txt	2016-03-31 11:05:11 UTC (rev 198891)
@@ -1,18 +1,18 @@
 
-FAIL Fetching aaa://localhost:8800/ is KO assert_throws: function "function () { throw e }" threw "Fetch is not yet implemented" (undefined) expected object "TypeError" ("TypeError")
-FAIL Fetching cap://localhost:8800/ is KO assert_throws: function "function () { throw e }" threw "Fetch is not yet implemented" (undefined) expected object "TypeError" ("TypeError")
-FAIL Fetching cid://localhost:8800/ is KO assert_throws: function "function () { throw e }" threw "Fetch is not yet implemented" (undefined) expected object "TypeError" ("TypeError")
-FAIL Fetching dav://localhost:8800/ is KO assert_throws: function "function () { throw e }" threw "Fetch is not yet implemented" (undefined) expected object "TypeError" ("TypeError")
-FAIL Fetching dict://localhost:8800/ is KO assert_throws: function "function () { throw e }" threw "Fetch is not yet implemented" (undefined) expected object "TypeError" ("TypeError")
-FAIL Fetching dns://localhost:8800/ is KO assert_throws: function "function () { throw e }" threw "Fetch is not yet implemented" (undefined) expected object "TypeError" ("TypeError")
-FAIL Fetching geo://localhost:8800/ is KO assert_throws: function "function () { throw e }" threw "Fetch is not yet implemented" (undefined) expected object "TypeError" ("TypeError")
-FAIL Fetching im://localhost:8800/ is KO assert_throws: function "function () { throw e }" threw "Fetch is not yet implemented" (undefined) expected object "TypeError" ("TypeError")
-FAIL Fetching imap://localhost:8800/ is KO assert_throws: function "function () { throw e }" threw "Fetch is not yet implemented" (undefined) expected object "TypeError" ("TypeError")
-FAIL Fetching ipp://localhost:8800/ is KO assert_throws: function "function () { throw e }" threw "Fetch is not yet implemented" (undefined) expected object "TypeError" ("TypeError")
-FAIL Fetching ldap://localhost:8800/ is KO assert_throws: function "function () { throw e }" threw "Fetch is not yet implemented" (undefined) expected object "TypeError" ("TypeError")
-FAIL Fetching mailto://localhost:8800/ is KO assert_throws: function "function () { throw e }" threw "Fetch is not yet implemented" (undefined) expected object "TypeError" ("TypeError")
-FAIL Fetching nfs://localhost:8800/ is KO assert_throws: function "function () { throw e }" threw "Fetch is not yet implemented" (undefined) expected object "TypeError" ("TypeError")
-FAIL Fetching pop://localhost:8800/ is KO assert_throws: function "function () { throw e }" threw "Fetch is not yet implemented" (undefined) expected object "TypeError" ("TypeError")
-FAIL Fetching rtsp://localhost:8800/ is KO assert_throws: function "function () { throw e }" threw "Fetch is not yet implemented" (undefined) expected object "TypeError" ("TypeError")
-FAIL Fetching snmp://localhost:8800/ is KO assert_throws: function "function () { throw e }" threw "Fetch is not yet implemented" (undefined) expected object "TypeError" ("TypeError")
+PASS Fetching aaa://localhost:8800/ is KO 
+PASS Fetching cap://localhost:8800/ is KO 
+PASS Fetching cid://localhost:8800/ is KO 
+PASS Fetching dav://localhost:8800/ is KO 
+PASS Fetching dict://localhost:8800/ is KO 
+PASS Fetching dns://localhost:8800/ is KO 
+PASS Fetching geo://localhost:8800/ is KO 
+PASS Fetching im://localhost:8800/ is KO 
+PASS Fetching imap://localhost:8800/ is KO 
+PASS Fetching ipp://localhost:8800/ is KO 
+PASS Fetching ldap://localhost:8800/ is KO 
+PASS Fetching mailto://localhost:8800/ is KO 
+PASS Fetching nfs://localhost:8800/ is KO 
+PASS Fetching pop://localhost:8800/ is KO 
+PASS Fetching rtsp://localhost:8800/ is KO 
+PASS Fetching snmp://localhost:8800/ is KO 
 

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/basic/stream-response-worker-expected.txt (198890 => 198891)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/basic/stream-response-worker-expected.txt	2016-03-31 10:31:28 UTC (rev 198890)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/basic/stream-response-worker-expected.txt	2016-03-31 11:05:11 UTC (rev 198891)
@@ -1,3 +1,3 @@
 
-FAIL Stream response's body promise_test: Unhandled rejection with value: "Fetch is not yet implemented"
+FAIL Stream response's body assert_unreached: Body does not exist in response Reached unreachable code
 

Added: trunk/LayoutTests/platform/gtk/imported/w3c/web-platform-tests/fetch/api/basic/request-headers-worker-expected.txt (0 => 198891)


--- trunk/LayoutTests/platform/gtk/imported/w3c/web-platform-tests/fetch/api/basic/request-headers-worker-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/platform/gtk/imported/w3c/web-platform-tests/fetch/api/basic/request-headers-worker-expected.txt	2016-03-31 11:05:11 UTC (rev 198891)
@@ -0,0 +1,11 @@
+
+FAIL Fetch with GET assert_equals: Request has header origin: http://localhost:8800 expected (string) "http://localhost:8800" but got (object) null
+FAIL Fetch with HEAD assert_equals: Request has header origin: http://localhost:8800 expected (string) "http://localhost:8800" but got (object) null
+FAIL Fetch with HEAD with body promise_test: Unhandled rejection with value: object "TypeError: Type error"
+PASS Fetch with PUT without body 
+PASS Fetch with PUT with body 
+PASS Fetch with POST without body 
+PASS Fetch with POST with body 
+PASS Fetch with Chicken 
+PASS Fetch with Chicken with body 
+

Modified: trunk/Source/WebCore/ChangeLog (198890 => 198891)


--- trunk/Source/WebCore/ChangeLog	2016-03-31 10:31:28 UTC (rev 198890)
+++ trunk/Source/WebCore/ChangeLog	2016-03-31 11:05:11 UTC (rev 198891)
@@ -1,5 +1,40 @@
 2016-03-31  Youenn Fablet  <[email protected]>
 
+        [Fetch API] Add basic loading of resources for Workers
+        https://bugs.webkit.org/show_bug.cgi?id=155886
+
+        Reviewed by Alex Christensen.
+
+        Adding impplementation to WorkerGlobalScopeFetch::fetch similarly to DOMWindowFetch::fetch.
+        Refactored code in FetchResponse to share code between the two.
+
+        Updated WorkerThreadableLoader to cope with an ASSERT.
+        The ASSERT ensures that a DocumentThreadableLoader::create returns non null. 
+        In our case, it might happen as all cross origin fetch requests are denied at the moment.
+        This leads to calling didFail in DocumentThreadableLoader::create call and DocumentThreadableLoader::create to return null.
+        Updated the ASSERT to ensures that either the load is finished or DocumentThreadableLoader::create does not return null.
+
+        Covered by rebased tests.
+
+        * Modules/fetch/DOMWindowFetch.cpp:
+        (WebCore::DOMWindowFetch::fetch):
+        * Modules/fetch/FetchResponse.cpp:
+        (WebCore::FetchResponse::startFetching):
+        (WebCore::FetchResponse::fetch):
+        * Modules/fetch/FetchResponse.h:
+        * Modules/fetch/WorkerGlobalScopeFetch.cpp:
+        (WebCore::WorkerGlobalScopeFetch::fetch):
+        * Modules/fetch/WorkerGlobalScopeFetch.h:
+        * loader/WorkerThreadableLoader.cpp:
+        (WebCore::WorkerThreadableLoader::MainThreadBridge::MainThreadBridge):
+        (WebCore::WorkerThreadableLoader::MainThreadBridge::didFinishLoading):
+        (WebCore::WorkerThreadableLoader::MainThreadBridge::didFail):
+        (WebCore::WorkerThreadableLoader::MainThreadBridge::didFailAccessControlCheck):
+        (WebCore::WorkerThreadableLoader::MainThreadBridge::didFailRedirectCheck):
+        * loader/WorkerThreadableLoader.h:
+
+2016-03-31  Youenn Fablet  <[email protected]>
+
         [Fetch API] Move isDisturbed handling to FetchBodyOwner
         https://bugs.webkit.org/show_bug.cgi?id=155968
 

Modified: trunk/Source/WebCore/Modules/fetch/DOMWindowFetch.cpp (198890 => 198891)


--- trunk/Source/WebCore/Modules/fetch/DOMWindowFetch.cpp	2016-03-31 10:31:28 UTC (rev 198890)
+++ trunk/Source/WebCore/Modules/fetch/DOMWindowFetch.cpp	2016-03-31 11:05:11 UTC (rev 198891)
@@ -41,32 +41,14 @@
 {
     if (!window.scriptExecutionContext())
         return;
-    ScriptExecutionContext& context = *window.scriptExecutionContext();
-
-    ExceptionCode ec = 0;
-    RefPtr<FetchRequest> fetchRequest = FetchRequest::create(context, input, dictionary, ec);
-    if (ec) {
-        promise.reject(ec);
-        return;
-    }
-    ASSERT(fetchRequest);
-    FetchResponse::fetch(context, *fetchRequest, WTFMove(promise));
+    FetchResponse::fetch(*window.scriptExecutionContext(), input, dictionary, WTFMove(promise));
 }
 
 void DOMWindowFetch::fetch(DOMWindow& window, const String& url, const Dictionary& dictionary, DeferredWrapper&& promise)
 {
     if (!window.scriptExecutionContext())
         return;
-    ScriptExecutionContext& context = *window.scriptExecutionContext();
-    
-    ExceptionCode ec = 0;
-    RefPtr<FetchRequest> fetchRequest = FetchRequest::create(context, url, dictionary, ec);
-    if (ec) {
-        promise.reject(ec);
-        return;
-    }
-    ASSERT(fetchRequest);
-    FetchResponse::fetch(context, *fetchRequest, WTFMove(promise));
+    FetchResponse::fetch(*window.scriptExecutionContext(), url, dictionary, WTFMove(promise));
 }
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/Modules/fetch/FetchResponse.cpp (198890 => 198891)


--- trunk/Source/WebCore/Modules/fetch/FetchResponse.cpp	2016-03-31 10:31:28 UTC (rev 198890)
+++ trunk/Source/WebCore/Modules/fetch/FetchResponse.cpp	2016-03-31 11:05:11 UTC (rev 198891)
@@ -33,6 +33,7 @@
 
 #include "Dictionary.h"
 #include "ExceptionCode.h"
+#include "FetchRequest.h"
 #include "JSFetchResponse.h"
 #include "ScriptExecutionContext.h"
 
@@ -153,7 +154,7 @@
     return JSC::jsNull();
 }
 
-void FetchResponse::fetch(ScriptExecutionContext& context, const FetchRequest& request, FetchPromise&& promise)
+void FetchResponse::startFetching(ScriptExecutionContext& context, const FetchRequest& request, FetchPromise&& promise)
 {
     Ref<FetchResponse> response = adoptRef(*new FetchResponse(context, Type::Basic, FetchBody::loadingBody(), FetchHeaders::create(FetchHeaders::Guard::Immutable), ResourceResponse()));
 
@@ -165,6 +166,30 @@
         response->m_bodyLoader = Nullopt;
 }
 
+void FetchResponse::fetch(ScriptExecutionContext& context, FetchRequest& input, const Dictionary& dictionary, FetchPromise&& promise)
+{
+    ExceptionCode ec = 0;
+    RefPtr<FetchRequest> fetchRequest = FetchRequest::create(context, input, dictionary, ec);
+    if (ec) {
+        promise.reject(ec);
+        return;
+    }
+    ASSERT(fetchRequest);
+    startFetching(context, *fetchRequest, WTFMove(promise));
+}
+
+void FetchResponse::fetch(ScriptExecutionContext& context, const String& url, const Dictionary& dictionary, FetchPromise&& promise)
+{
+    ExceptionCode ec = 0;
+    RefPtr<FetchRequest> fetchRequest = FetchRequest::create(context, url, dictionary, ec);
+    if (ec) {
+        promise.reject(ec);
+        return;
+    }
+    ASSERT(fetchRequest);
+    startFetching(context, *fetchRequest, WTFMove(promise));
+}
+
 void FetchResponse::BodyLoader::didSucceed()
 {
     m_response.m_bodyLoader = Nullopt;

Modified: trunk/Source/WebCore/Modules/fetch/FetchResponse.h (198890 => 198891)


--- trunk/Source/WebCore/Modules/fetch/FetchResponse.h	2016-03-31 10:31:28 UTC (rev 198890)
+++ trunk/Source/WebCore/Modules/fetch/FetchResponse.h	2016-03-31 11:05:11 UTC (rev 198891)
@@ -55,7 +55,8 @@
     static RefPtr<FetchResponse> redirect(ScriptExecutionContext& context, const String& url, ExceptionCode& ec) { return redirect(context, url, 302, ec); }
 
     using FetchPromise = DOMPromise<RefPtr<FetchResponse>, ExceptionCode>;
-    static void fetch(ScriptExecutionContext&, const FetchRequest&, FetchPromise&&);
+    static void fetch(ScriptExecutionContext&, FetchRequest&, const Dictionary&, FetchPromise&&);
+    static void fetch(ScriptExecutionContext&, const String&, const Dictionary&, FetchPromise&&);
 
     void initializeWith(const Dictionary&, ExceptionCode&);
 
@@ -74,6 +75,8 @@
 
     FetchResponse(ScriptExecutionContext&, Type, FetchBody&&, Ref<FetchHeaders>&&, ResourceResponse&&);
 
+    static void startFetching(ScriptExecutionContext&, const FetchRequest&, FetchPromise&&);
+
     // ActiveDOMObject API
     void stop() final;
     const char* activeDOMObjectName() const final;

Modified: trunk/Source/WebCore/Modules/fetch/WorkerGlobalScopeFetch.cpp (198890 => 198891)


--- trunk/Source/WebCore/Modules/fetch/WorkerGlobalScopeFetch.cpp	2016-03-31 10:31:28 UTC (rev 198890)
+++ trunk/Source/WebCore/Modules/fetch/WorkerGlobalScopeFetch.cpp	2016-03-31 11:05:11 UTC (rev 198891)
@@ -31,16 +31,23 @@
 
 #if ENABLE(FETCH_API)
 
+#include "FetchResponse.h"
+#include "WorkerGlobalScope.h"
+
 namespace WebCore {
 
-void WorkerGlobalScopeFetch::fetch(WorkerGlobalScope&, FetchRequest&, const Dictionary&, FetchPromise&& promise)
+void WorkerGlobalScopeFetch::fetch(WorkerGlobalScope& scope, FetchRequest& input, const Dictionary& dictionary, DeferredWrapper&& promise)
 {
-    promise.reject(ASCIILiteral("Fetch is not yet implemented"));
+    if (!scope.scriptExecutionContext())
+        return;
+    FetchResponse::fetch(*scope.scriptExecutionContext(), input, dictionary, WTFMove(promise));
 }
 
-void WorkerGlobalScopeFetch::fetch(WorkerGlobalScope&, const String&, const Dictionary&, FetchPromise&& promise)
+void WorkerGlobalScopeFetch::fetch(WorkerGlobalScope& scope, const String& url, const Dictionary& dictionary, DeferredWrapper&& promise)
 {
-    promise.reject(ASCIILiteral("Fetch is not yet implemented"));
+    if (!scope.scriptExecutionContext())
+        return;
+    FetchResponse::fetch(*scope.scriptExecutionContext(), url, dictionary, WTFMove(promise));
 }
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/Modules/fetch/WorkerGlobalScopeFetch.h (198890 => 198891)


--- trunk/Source/WebCore/Modules/fetch/WorkerGlobalScopeFetch.h	2016-03-31 10:31:28 UTC (rev 198890)
+++ trunk/Source/WebCore/Modules/fetch/WorkerGlobalScopeFetch.h	2016-03-31 11:05:11 UTC (rev 198891)
@@ -31,20 +31,19 @@
 #if ENABLE(FETCH_API)
 
 #include "JSDOMPromise.h"
+#include <wtf/Forward.h>
 
 namespace WebCore {
 
+class WorkerGlobalScope;
+class DeferredWrapper;
 class Dictionary;
 class FetchRequest;
-class FetchResponse;
-class ScriptExecutionContext;
-class WorkerGlobalScope;
 
 class WorkerGlobalScopeFetch {
 public:
-    using FetchPromise = DOMPromise<RefPtr<FetchResponse>, String>;
-    static void fetch(WorkerGlobalScope&, FetchRequest&, const Dictionary&, FetchPromise&&);
-    static void fetch(WorkerGlobalScope&, const String&, const Dictionary&, FetchPromise&&);
+    static void fetch(WorkerGlobalScope&, FetchRequest&, const Dictionary&, DeferredWrapper&&);
+    static void fetch(WorkerGlobalScope&, const String&, const Dictionary&, DeferredWrapper&&);
 };
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/loader/WorkerThreadableLoader.cpp (198890 => 198891)


--- trunk/Source/WebCore/loader/WorkerThreadableLoader.cpp	2016-03-31 10:31:28 UTC (rev 198890)
+++ trunk/Source/WebCore/loader/WorkerThreadableLoader.cpp	2016-03-31 11:05:11 UTC (rev 198891)
@@ -112,7 +112,7 @@
         // will return a 0 value. Either this should return 0 or the other code path should do a callback with
         // a failure.
         m_mainThreadLoader = DocumentThreadableLoader::create(document, *this, *request, *options, std::unique_ptr<ContentSecurityPolicy>(contentSecurityPolicyCopy));
-        ASSERT(m_mainThreadLoader);
+        ASSERT(m_mainThreadLoader || m_loadingFinished);
     });
 }
 
@@ -193,6 +193,7 @@
 
 void WorkerThreadableLoader::MainThreadBridge::didFinishLoading(unsigned long identifier, double finishTime)
 {
+    m_loadingFinished = true;
     RefPtr<ThreadableLoaderClientWrapper> workerClientWrapper = m_workerClientWrapper;
     m_loaderProxy.postTaskForModeToWorkerGlobalScope([workerClientWrapper, identifier, finishTime] (ScriptExecutionContext& context) {
         ASSERT_UNUSED(context, context.isWorkerGlobalScope());
@@ -202,6 +203,7 @@
 
 void WorkerThreadableLoader::MainThreadBridge::didFail(const ResourceError& error)
 {
+    m_loadingFinished = true;
     RefPtr<ThreadableLoaderClientWrapper> workerClientWrapper = m_workerClientWrapper;
     ResourceError* capturedError = new ResourceError(error.copy());
     if (!m_loaderProxy.postTaskForModeToWorkerGlobalScope([workerClientWrapper, capturedError] (ScriptExecutionContext& context) {
@@ -214,6 +216,7 @@
 
 void WorkerThreadableLoader::MainThreadBridge::didFailAccessControlCheck(const ResourceError& error)
 {
+    m_loadingFinished = true;
     RefPtr<ThreadableLoaderClientWrapper> workerClientWrapper = m_workerClientWrapper;
     ResourceError* capturedError = new ResourceError(error.copy());
     if (!m_loaderProxy.postTaskForModeToWorkerGlobalScope([workerClientWrapper, capturedError] (ScriptExecutionContext& context) {
@@ -226,6 +229,7 @@
 
 void WorkerThreadableLoader::MainThreadBridge::didFailRedirectCheck()
 {
+    m_loadingFinished = true;
     RefPtr<ThreadableLoaderClientWrapper> workerClientWrapper = m_workerClientWrapper;
     m_loaderProxy.postTaskForModeToWorkerGlobalScope([workerClientWrapper] (ScriptExecutionContext& context) {
         ASSERT_UNUSED(context, context.isWorkerGlobalScope());

Modified: trunk/Source/WebCore/loader/WorkerThreadableLoader.h (198890 => 198891)


--- trunk/Source/WebCore/loader/WorkerThreadableLoader.h	2016-03-31 10:31:28 UTC (rev 198890)
+++ trunk/Source/WebCore/loader/WorkerThreadableLoader.h	2016-03-31 11:05:11 UTC (rev 198891)
@@ -111,6 +111,7 @@
 
             // Only to be used on the main thread.
             RefPtr<ThreadableLoader> m_mainThreadLoader;
+            bool m_loadingFinished { false };
 
             // ThreadableLoaderClientWrapper is to be used on the worker context thread.
             // The ref counting is done on either thread.
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to