Title: [220050] trunk
Revision
220050
Author
wei...@apple.com
Date
2017-07-30 13:27:19 -0700 (Sun, 30 Jul 2017)

Log Message

[WebIDL] Remove JS builtin bindings for FetchRequest, DOMWindowFetch and WorkerGlobalScopeFetch
https://bugs.webkit.org/show_bug.cgi?id=174974

Reviewed by Darin Adler.

LayoutTests/imported/w3c:

* web-platform-tests/fetch/api/basic/mode-same-origin.any-expected.txt:
* web-platform-tests/fetch/api/basic/scheme-about.any-expected.txt:
* web-platform-tests/fetch/api/basic/scheme-blob-expected.txt:
* web-platform-tests/fetch/api/basic/scheme-others-expected.txt:
* web-platform-tests/fetch/api/cors/cors-cookies.any-expected.txt:
* web-platform-tests/fetch/api/policies/referrer-origin-when-cross-origin-expected.txt:
* web-platform-tests/fetch/api/request/request-bad-port-expected.txt:
Update results to have the correct line number for exceptions reported in the console.

Source/WebCore:

* CMakeLists.txt:
* DerivedSources.make:
* WebCore.xcodeproj/project.pbxproj:
* Modules/fetch/DOMWindowFetch.js: Removed.
* Modules/fetch/FetchRequest.js: Removed.
* Modules/fetch/WorkerGlobalScopeFetch.js: Removed.
Remove builtin files.

* Modules/fetch/DOMWindowFetch.cpp:
(WebCore::DOMWindowFetch::fetch):
* Modules/fetch/DOMWindowFetch.h:
* Modules/fetch/DOMWindowFetch.idl:
* Modules/fetch/WorkerGlobalScopeFetch.cpp:
(WebCore::WorkerGlobalScopeFetch::fetch):
* Modules/fetch/WorkerGlobalScopeFetch.h:
* Modules/fetch/WorkerGlobalScopeFetch.idl:
Remove builtin and instead create FetchRequest in the implementation.

* Modules/fetch/FetchBody.cpp:
(WebCore::FetchBody::extract):
* Modules/fetch/FetchBody.h:
* Modules/fetch/FetchBodyOwner.cpp:
(WebCore::FetchBodyOwner::extractBody):
* Modules/fetch/FetchBodyOwner.h:
* Modules/fetch/FetchResponse.cpp:
* Modules/fetch/FetchResponse.h:
Rename FetchBody::BindingDataType to FetchBody::Init to match its IDL naming.

* Modules/fetch/FetchHeaders.cpp:
(WebCore::appendToHeaderMap):
(WebCore::fillHeaderMap):
(WebCore::FetchHeaders::create):
(WebCore::FetchHeaders::fill):
* Modules/fetch/FetchHeaders.h:
Add helpers to implement the fill algorithm for various input types.
Leave the existing fill for now, as it is still used by the FetchResponse
builtin, but will eventually be removed.

* Modules/fetch/FetchRequest.cpp:
(WebCore::FetchRequest::initializeOptions):
(WebCore::FetchRequest::initializeWith):
(WebCore::FetchRequest::setBody):
(WebCore::FetchRequest::create):
(WebCore::FetchRequest::setBodyFromInputRequest): Deleted.
* Modules/fetch/FetchRequest.h:
Migrate builtin code to the implementation. This is 1-to-1 re-implementation,
so I did not attempt to fix any conformance issues. That will come in follow up.

* Modules/fetch/FetchRequest.idl:
Replace builtins with an IDL constructor.

* Modules/fetch/FetchRequestInit.h:
* Modules/fetch/FetchRequestInit.idl:
Add missing headers and body to FetchRequestInit.

LayoutTests:

* http/tests/inspector/network/fetch-network-data-expected.txt:
Update results to have the correct line number for exceptions reported in the console.

Modified Paths

Removed Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (220049 => 220050)


--- trunk/LayoutTests/ChangeLog	2017-07-30 17:36:26 UTC (rev 220049)
+++ trunk/LayoutTests/ChangeLog	2017-07-30 20:27:19 UTC (rev 220050)
@@ -1,3 +1,13 @@
+2017-07-30  Sam Weinig  <s...@webkit.org>
+
+        [WebIDL] Remove JS builtin bindings for FetchRequest, DOMWindowFetch and WorkerGlobalScopeFetch
+        https://bugs.webkit.org/show_bug.cgi?id=174974
+
+        Reviewed by Darin Adler.
+
+        * http/tests/inspector/network/fetch-network-data-expected.txt:
+        Update results to have the correct line number for exceptions reported in the console.
+
 2017-07-30  Said Abou-Hallawa  <sabouhall...@apple.com>
 
         RenderImageResourceStyleImage::image() should return the nullImage() if the image is not available

Modified: trunk/LayoutTests/http/tests/inspector/network/fetch-network-data-expected.txt (220049 => 220050)


--- trunk/LayoutTests/http/tests/inspector/network/fetch-network-data-expected.txt	2017-07-30 17:36:26 UTC (rev 220049)
+++ trunk/LayoutTests/http/tests/inspector/network/fetch-network-data-expected.txt	2017-07-30 20:27:19 UTC (rev 220050)
@@ -1,4 +1,4 @@
-CONSOLE MESSAGE: line 1: Fetch API cannot load http://localhost:8000/inspector/network/resources/cors-data.pl. Cross origin requests are not allowed when using same-origin fetch mode.
+CONSOLE MESSAGE: line 2: Fetch API cannot load http://localhost:8000/inspector/network/resources/cors-data.pl. Cross origin requests are not allowed when using same-origin fetch mode.
 Tests for Network data with different types of Fetch requests.
 
 

Modified: trunk/LayoutTests/imported/w3c/ChangeLog (220049 => 220050)


--- trunk/LayoutTests/imported/w3c/ChangeLog	2017-07-30 17:36:26 UTC (rev 220049)
+++ trunk/LayoutTests/imported/w3c/ChangeLog	2017-07-30 20:27:19 UTC (rev 220050)
@@ -1,3 +1,19 @@
+2017-07-30  Sam Weinig  <s...@webkit.org>
+
+        [WebIDL] Remove JS builtin bindings for FetchRequest, DOMWindowFetch and WorkerGlobalScopeFetch
+        https://bugs.webkit.org/show_bug.cgi?id=174974
+
+        Reviewed by Darin Adler.
+
+        * web-platform-tests/fetch/api/basic/mode-same-origin.any-expected.txt:
+        * web-platform-tests/fetch/api/basic/scheme-about.any-expected.txt:
+        * web-platform-tests/fetch/api/basic/scheme-blob-expected.txt:
+        * web-platform-tests/fetch/api/basic/scheme-others-expected.txt:
+        * web-platform-tests/fetch/api/cors/cors-cookies.any-expected.txt:
+        * web-platform-tests/fetch/api/policies/referrer-origin-when-cross-origin-expected.txt:
+        * web-platform-tests/fetch/api/request/request-bad-port-expected.txt:
+        Update results to have the correct line number for exceptions reported in the console.
+
 2017-07-28  Sam Weinig  <s...@webkit.org>
 
         [WebIDL] Remove JS builtin bindings for FetchHeaders

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


--- trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/basic/mode-same-origin.any-expected.txt	2017-07-30 17:36:26 UTC (rev 220049)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/basic/mode-same-origin.any-expected.txt	2017-07-30 20:27:19 UTC (rev 220050)
@@ -1,5 +1,5 @@
-CONSOLE MESSAGE: line 1: Fetch API cannot load https://localhost:9443/fetch/api/resources/top.txt. Cross origin requests are not allowed when using same-origin fetch mode.
-CONSOLE MESSAGE: line 1: Fetch API cannot load http://127.0.0.1:8800/fetch/api/resources/top.txt. Cross origin requests are not allowed when using same-origin fetch mode.
+CONSOLE MESSAGE: line 12: Fetch API cannot load https://localhost:9443/fetch/api/resources/top.txt. Cross origin requests are not allowed when using same-origin fetch mode.
+CONSOLE MESSAGE: line 12: Fetch API cannot load http://127.0.0.1:8800/fetch/api/resources/top.txt. Cross origin requests are not allowed when using same-origin fetch mode.
 CONSOLE MESSAGE: Unsafe attempt to load URL https://localhost:9443/fetch/api/resources/top.txt?location=https%3A%2F%2Flocalhost%3A9443%2Ffetch%2Fapi%2Fresources%2Ftop.txt&count=1 from frame with URL http://localhost:8800/fetch/api/basic/mode-same-origin.any.html. Domains, protocols and ports must match.
 
 CONSOLE MESSAGE: Unsafe attempt to load URL http://127.0.0.1:8800/fetch/api/resources/top.txt?location=http%3A%2F%2F127.0.0.1%3A8800%2Ffetch%2Fapi%2Fresources%2Ftop.txt&count=1 from frame with URL http://localhost:8800/fetch/api/basic/mode-same-origin.any.html. Domains, protocols and ports must match.

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/basic/scheme-about.any-expected.txt (220049 => 220050)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/basic/scheme-about.any-expected.txt	2017-07-30 17:36:26 UTC (rev 220049)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/basic/scheme-about.any-expected.txt	2017-07-30 20:27:19 UTC (rev 220050)
@@ -1,9 +1,9 @@
-CONSOLE MESSAGE: line 1: Fetch API cannot load about:blank. Cross origin requests are only supported for HTTP.
+CONSOLE MESSAGE: line 10: Fetch API cannot load about:blank. Cross origin requests are only supported for HTTP.
 CONSOLE MESSAGE: Fetch API cannot load about:blank. Preflight response is not successful
-CONSOLE MESSAGE: line 1: Fetch API cannot load about:blank. Cross origin requests are only supported for HTTP.
-CONSOLE MESSAGE: line 1: Fetch API cannot load about:invalid.com. Cross origin requests are only supported for HTTP.
-CONSOLE MESSAGE: line 1: Fetch API cannot load about:config. Cross origin requests are only supported for HTTP.
-CONSOLE MESSAGE: line 1: Fetch API cannot load about:unicorn. Cross origin requests are only supported for HTTP.
+CONSOLE MESSAGE: line 10: Fetch API cannot load about:blank. Cross origin requests are only supported for HTTP.
+CONSOLE MESSAGE: line 27: Fetch API cannot load about:invalid.com. Cross origin requests are only supported for HTTP.
+CONSOLE MESSAGE: line 27: Fetch API cannot load about:config. Cross origin requests are only supported for HTTP.
+CONSOLE MESSAGE: line 27: Fetch API cannot load about:unicorn. Cross origin requests are only supported for HTTP.
 
 FAIL Fetching about:blank (GET) is OK promise_test: Unhandled rejection with value: object "TypeError: Type error"
 FAIL Fetching about:blank (PUT) is OK promise_test: Unhandled rejection with value: object "TypeError: Type error"

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


--- trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/basic/scheme-blob-expected.txt	2017-07-30 17:36:26 UTC (rev 220049)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/basic/scheme-blob-expected.txt	2017-07-30 20:27:19 UTC (rev 220050)
@@ -1,4 +1,4 @@
-CONSOLE MESSAGE: line 1: Fetch API cannot load blob:http://www.localhost:8800/. Cross origin requests are only supported for HTTP.
+CONSOLE MESSAGE: line 27: Fetch API cannot load blob:http://www.localhost:8800/. Cross origin requests are only supported for HTTP.
 
 PASS Fetching [GET] URL.createObjectURL(blob) is OK 
 PASS Fetching [GET] blob:http://www.localhost:8800/ is KO 

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


--- trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/basic/scheme-others-expected.txt	2017-07-30 17:36:26 UTC (rev 220049)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/basic/scheme-others-expected.txt	2017-07-30 20:27:19 UTC (rev 220050)
@@ -1,19 +1,19 @@
-CONSOLE MESSAGE: line 1: Fetch API cannot load aaa://localhost:8800/. Cross origin requests are only supported for HTTP.
-CONSOLE MESSAGE: line 1: Fetch API cannot load cap://localhost:8800/. Cross origin requests are only supported for HTTP.
-CONSOLE MESSAGE: line 1: Fetch API cannot load cid://localhost:8800/. Cross origin requests are only supported for HTTP.
-CONSOLE MESSAGE: line 1: Fetch API cannot load dav://localhost:8800/. Cross origin requests are only supported for HTTP.
-CONSOLE MESSAGE: line 1: Fetch API cannot load dict://localhost:8800/. Cross origin requests are only supported for HTTP.
-CONSOLE MESSAGE: line 1: Fetch API cannot load dns://localhost:8800/. Cross origin requests are only supported for HTTP.
-CONSOLE MESSAGE: line 1: Fetch API cannot load geo://localhost:8800/. Cross origin requests are only supported for HTTP.
-CONSOLE MESSAGE: line 1: Fetch API cannot load im://localhost:8800/. Cross origin requests are only supported for HTTP.
-CONSOLE MESSAGE: line 1: Fetch API cannot load imap://localhost:8800/. Cross origin requests are only supported for HTTP.
-CONSOLE MESSAGE: line 1: Fetch API cannot load ipp://localhost:8800/. Cross origin requests are only supported for HTTP.
-CONSOLE MESSAGE: line 1: Fetch API cannot load ldap://localhost:8800/. Cross origin requests are only supported for HTTP.
-CONSOLE MESSAGE: line 1: Fetch API cannot load mailto://localhost:8800/. Cross origin requests are only supported for HTTP.
-CONSOLE MESSAGE: line 1: Fetch API cannot load nfs://localhost:8800/. Cross origin requests are only supported for HTTP.
-CONSOLE MESSAGE: line 1: Fetch API cannot load pop://localhost:8800/. Cross origin requests are only supported for HTTP.
-CONSOLE MESSAGE: line 1: Fetch API cannot load rtsp://localhost:8800/. Cross origin requests are only supported for HTTP.
-CONSOLE MESSAGE: line 1: Fetch API cannot load snmp://localhost:8800/. Cross origin requests are only supported for HTTP.
+CONSOLE MESSAGE: line 10: Fetch API cannot load aaa://localhost:8800/. Cross origin requests are only supported for HTTP.
+CONSOLE MESSAGE: line 10: Fetch API cannot load cap://localhost:8800/. Cross origin requests are only supported for HTTP.
+CONSOLE MESSAGE: line 10: Fetch API cannot load cid://localhost:8800/. Cross origin requests are only supported for HTTP.
+CONSOLE MESSAGE: line 10: Fetch API cannot load dav://localhost:8800/. Cross origin requests are only supported for HTTP.
+CONSOLE MESSAGE: line 10: Fetch API cannot load dict://localhost:8800/. Cross origin requests are only supported for HTTP.
+CONSOLE MESSAGE: line 10: Fetch API cannot load dns://localhost:8800/. Cross origin requests are only supported for HTTP.
+CONSOLE MESSAGE: line 10: Fetch API cannot load geo://localhost:8800/. Cross origin requests are only supported for HTTP.
+CONSOLE MESSAGE: line 10: Fetch API cannot load im://localhost:8800/. Cross origin requests are only supported for HTTP.
+CONSOLE MESSAGE: line 10: Fetch API cannot load imap://localhost:8800/. Cross origin requests are only supported for HTTP.
+CONSOLE MESSAGE: line 10: Fetch API cannot load ipp://localhost:8800/. Cross origin requests are only supported for HTTP.
+CONSOLE MESSAGE: line 10: Fetch API cannot load ldap://localhost:8800/. Cross origin requests are only supported for HTTP.
+CONSOLE MESSAGE: line 10: Fetch API cannot load mailto://localhost:8800/. Cross origin requests are only supported for HTTP.
+CONSOLE MESSAGE: line 10: Fetch API cannot load nfs://localhost:8800/. Cross origin requests are only supported for HTTP.
+CONSOLE MESSAGE: line 10: Fetch API cannot load pop://localhost:8800/. Cross origin requests are only supported for HTTP.
+CONSOLE MESSAGE: line 10: Fetch API cannot load rtsp://localhost:8800/. Cross origin requests are only supported for HTTP.
+CONSOLE MESSAGE: line 10: Fetch API cannot load snmp://localhost:8800/. Cross origin requests are only supported for HTTP.
 
 PASS Fetching aaa://localhost:8800/ is KO 
 PASS Fetching cap://localhost:8800/ is KO 

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/cors/cors-cookies.any-expected.txt (220049 => 220050)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/cors/cors-cookies.any-expected.txt	2017-07-30 17:36:26 UTC (rev 220049)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/cors/cors-cookies.any-expected.txt	2017-07-30 20:27:19 UTC (rev 220050)
@@ -1,5 +1,5 @@
 Blocked access to external URL http://www.localhost:8800/fetch/api/resources/inspect-headers.py?cors&headers=cookie
-CONSOLE MESSAGE: line 1: Fetch API cannot load http://www.localhost:8800/fetch/api/resources/inspect-headers.py?cors&headers=cookie due to access control checks.
+CONSOLE MESSAGE: line 26: Fetch API cannot load http://www.localhost:8800/fetch/api/resources/inspect-headers.py?cors&headers=cookie due to access control checks.
 
 PASS Omit mode: no cookie sent 
 FAIL Include mode: 1 cookie assert_equals: Request includes cookie(s) expected (string) "a=1" but got (object) null

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/policies/referrer-origin-when-cross-origin-expected.txt (220049 => 220050)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/policies/referrer-origin-when-cross-origin-expected.txt	2017-07-30 17:36:26 UTC (rev 220049)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/policies/referrer-origin-when-cross-origin-expected.txt	2017-07-30 20:27:19 UTC (rev 220050)
@@ -1,5 +1,5 @@
 Blocked access to external URL https://www.localhost:9443/fetch/api/resources/inspect-headers.py?cors&headers=referer
-CONSOLE MESSAGE: line 1: Fetch API cannot load https://www.localhost:9443/fetch/api/resources/inspect-headers.py?cors&headers=referer due to access control checks.
+CONSOLE MESSAGE: line 14: Fetch API cannot load https://www.localhost:9443/fetch/api/resources/inspect-headers.py?cors&headers=referer due to access control checks.
 
 FAIL Request's referrer is origin promise_test: Unhandled rejection with value: object "TypeError: Type error"
 

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/request/request-bad-port-expected.txt (220049 => 220050)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/request/request-bad-port-expected.txt	2017-07-30 17:36:26 UTC (rev 220049)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/request/request-bad-port-expected.txt	2017-07-30 20:27:19 UTC (rev 220050)
@@ -1,131 +1,131 @@
 Blocked access to external URL http://example.com:1/
-CONSOLE MESSAGE: line 1: Fetch API cannot load http://example.com:1/ due to access control checks.
+CONSOLE MESSAGE: line 79: Fetch API cannot load http://example.com:1/ due to access control checks.
 Blocked access to external URL http://example.com:7/
-CONSOLE MESSAGE: line 1: Fetch API cannot load http://example.com:7/ due to access control checks.
+CONSOLE MESSAGE: line 79: Fetch API cannot load http://example.com:7/ due to access control checks.
 Blocked access to external URL http://example.com:9/
-CONSOLE MESSAGE: line 1: Fetch API cannot load http://example.com:9/ due to access control checks.
+CONSOLE MESSAGE: line 79: Fetch API cannot load http://example.com:9/ due to access control checks.
 Blocked access to external URL http://example.com:11/
-CONSOLE MESSAGE: line 1: Fetch API cannot load http://example.com:11/ due to access control checks.
+CONSOLE MESSAGE: line 79: Fetch API cannot load http://example.com:11/ due to access control checks.
 Blocked access to external URL http://example.com:13/
-CONSOLE MESSAGE: line 1: Fetch API cannot load http://example.com:13/ due to access control checks.
+CONSOLE MESSAGE: line 79: Fetch API cannot load http://example.com:13/ due to access control checks.
 Blocked access to external URL http://example.com:15/
-CONSOLE MESSAGE: line 1: Fetch API cannot load http://example.com:15/ due to access control checks.
+CONSOLE MESSAGE: line 79: Fetch API cannot load http://example.com:15/ due to access control checks.
 Blocked access to external URL http://example.com:17/
-CONSOLE MESSAGE: line 1: Fetch API cannot load http://example.com:17/ due to access control checks.
+CONSOLE MESSAGE: line 79: Fetch API cannot load http://example.com:17/ due to access control checks.
 Blocked access to external URL http://example.com:19/
-CONSOLE MESSAGE: line 1: Fetch API cannot load http://example.com:19/ due to access control checks.
+CONSOLE MESSAGE: line 79: Fetch API cannot load http://example.com:19/ due to access control checks.
 Blocked access to external URL http://example.com:20/
-CONSOLE MESSAGE: line 1: Fetch API cannot load http://example.com:20/ due to access control checks.
+CONSOLE MESSAGE: line 79: Fetch API cannot load http://example.com:20/ due to access control checks.
 Blocked access to external URL http://example.com:21/
-CONSOLE MESSAGE: line 1: Fetch API cannot load http://example.com:21/ due to access control checks.
+CONSOLE MESSAGE: line 79: Fetch API cannot load http://example.com:21/ due to access control checks.
 Blocked access to external URL http://example.com:22/
-CONSOLE MESSAGE: line 1: Fetch API cannot load http://example.com:22/ due to access control checks.
+CONSOLE MESSAGE: line 79: Fetch API cannot load http://example.com:22/ due to access control checks.
 Blocked access to external URL http://example.com:23/
-CONSOLE MESSAGE: line 1: Fetch API cannot load http://example.com:23/ due to access control checks.
+CONSOLE MESSAGE: line 79: Fetch API cannot load http://example.com:23/ due to access control checks.
 Blocked access to external URL http://example.com:25/
-CONSOLE MESSAGE: line 1: Fetch API cannot load http://example.com:25/ due to access control checks.
+CONSOLE MESSAGE: line 79: Fetch API cannot load http://example.com:25/ due to access control checks.
 Blocked access to external URL http://example.com:37/
-CONSOLE MESSAGE: line 1: Fetch API cannot load http://example.com:37/ due to access control checks.
+CONSOLE MESSAGE: line 79: Fetch API cannot load http://example.com:37/ due to access control checks.
 Blocked access to external URL http://example.com:42/
-CONSOLE MESSAGE: line 1: Fetch API cannot load http://example.com:42/ due to access control checks.
+CONSOLE MESSAGE: line 79: Fetch API cannot load http://example.com:42/ due to access control checks.
 Blocked access to external URL http://example.com:43/
-CONSOLE MESSAGE: line 1: Fetch API cannot load http://example.com:43/ due to access control checks.
+CONSOLE MESSAGE: line 79: Fetch API cannot load http://example.com:43/ due to access control checks.
 Blocked access to external URL http://example.com:53/
-CONSOLE MESSAGE: line 1: Fetch API cannot load http://example.com:53/ due to access control checks.
+CONSOLE MESSAGE: line 79: Fetch API cannot load http://example.com:53/ due to access control checks.
 Blocked access to external URL http://example.com:77/
-CONSOLE MESSAGE: line 1: Fetch API cannot load http://example.com:77/ due to access control checks.
+CONSOLE MESSAGE: line 79: Fetch API cannot load http://example.com:77/ due to access control checks.
 Blocked access to external URL http://example.com:79/
-CONSOLE MESSAGE: line 1: Fetch API cannot load http://example.com:79/ due to access control checks.
+CONSOLE MESSAGE: line 79: Fetch API cannot load http://example.com:79/ due to access control checks.
 Blocked access to external URL http://example.com:87/
-CONSOLE MESSAGE: line 1: Fetch API cannot load http://example.com:87/ due to access control checks.
+CONSOLE MESSAGE: line 79: Fetch API cannot load http://example.com:87/ due to access control checks.
 Blocked access to external URL http://example.com:95/
-CONSOLE MESSAGE: line 1: Fetch API cannot load http://example.com:95/ due to access control checks.
+CONSOLE MESSAGE: line 79: Fetch API cannot load http://example.com:95/ due to access control checks.
 Blocked access to external URL http://example.com:101/
-CONSOLE MESSAGE: line 1: Fetch API cannot load http://example.com:101/ due to access control checks.
+CONSOLE MESSAGE: line 79: Fetch API cannot load http://example.com:101/ due to access control checks.
 Blocked access to external URL http://example.com:102/
-CONSOLE MESSAGE: line 1: Fetch API cannot load http://example.com:102/ due to access control checks.
+CONSOLE MESSAGE: line 79: Fetch API cannot load http://example.com:102/ due to access control checks.
 Blocked access to external URL http://example.com:103/
-CONSOLE MESSAGE: line 1: Fetch API cannot load http://example.com:103/ due to access control checks.
+CONSOLE MESSAGE: line 79: Fetch API cannot load http://example.com:103/ due to access control checks.
 Blocked access to external URL http://example.com:104/
-CONSOLE MESSAGE: line 1: Fetch API cannot load http://example.com:104/ due to access control checks.
+CONSOLE MESSAGE: line 79: Fetch API cannot load http://example.com:104/ due to access control checks.
 Blocked access to external URL http://example.com:109/
-CONSOLE MESSAGE: line 1: Fetch API cannot load http://example.com:109/ due to access control checks.
+CONSOLE MESSAGE: line 79: Fetch API cannot load http://example.com:109/ due to access control checks.
 Blocked access to external URL http://example.com:110/
-CONSOLE MESSAGE: line 1: Fetch API cannot load http://example.com:110/ due to access control checks.
+CONSOLE MESSAGE: line 79: Fetch API cannot load http://example.com:110/ due to access control checks.
 Blocked access to external URL http://example.com:111/
-CONSOLE MESSAGE: line 1: Fetch API cannot load http://example.com:111/ due to access control checks.
+CONSOLE MESSAGE: line 79: Fetch API cannot load http://example.com:111/ due to access control checks.
 Blocked access to external URL http://example.com:113/
-CONSOLE MESSAGE: line 1: Fetch API cannot load http://example.com:113/ due to access control checks.
+CONSOLE MESSAGE: line 79: Fetch API cannot load http://example.com:113/ due to access control checks.
 Blocked access to external URL http://example.com:115/
-CONSOLE MESSAGE: line 1: Fetch API cannot load http://example.com:115/ due to access control checks.
+CONSOLE MESSAGE: line 79: Fetch API cannot load http://example.com:115/ due to access control checks.
 Blocked access to external URL http://example.com:117/
-CONSOLE MESSAGE: line 1: Fetch API cannot load http://example.com:117/ due to access control checks.
+CONSOLE MESSAGE: line 79: Fetch API cannot load http://example.com:117/ due to access control checks.
 Blocked access to external URL http://example.com:119/
-CONSOLE MESSAGE: line 1: Fetch API cannot load http://example.com:119/ due to access control checks.
+CONSOLE MESSAGE: line 79: Fetch API cannot load http://example.com:119/ due to access control checks.
 Blocked access to external URL http://example.com:123/
-CONSOLE MESSAGE: line 1: Fetch API cannot load http://example.com:123/ due to access control checks.
+CONSOLE MESSAGE: line 79: Fetch API cannot load http://example.com:123/ due to access control checks.
 Blocked access to external URL http://example.com:135/
-CONSOLE MESSAGE: line 1: Fetch API cannot load http://example.com:135/ due to access control checks.
+CONSOLE MESSAGE: line 79: Fetch API cannot load http://example.com:135/ due to access control checks.
 Blocked access to external URL http://example.com:139/
-CONSOLE MESSAGE: line 1: Fetch API cannot load http://example.com:139/ due to access control checks.
+CONSOLE MESSAGE: line 79: Fetch API cannot load http://example.com:139/ due to access control checks.
 Blocked access to external URL http://example.com:143/
-CONSOLE MESSAGE: line 1: Fetch API cannot load http://example.com:143/ due to access control checks.
+CONSOLE MESSAGE: line 79: Fetch API cannot load http://example.com:143/ due to access control checks.
 Blocked access to external URL http://example.com:179/
-CONSOLE MESSAGE: line 1: Fetch API cannot load http://example.com:179/ due to access control checks.
+CONSOLE MESSAGE: line 79: Fetch API cannot load http://example.com:179/ due to access control checks.
 Blocked access to external URL http://example.com:389/
-CONSOLE MESSAGE: line 1: Fetch API cannot load http://example.com:389/ due to access control checks.
+CONSOLE MESSAGE: line 79: Fetch API cannot load http://example.com:389/ due to access control checks.
 Blocked access to external URL http://example.com:465/
-CONSOLE MESSAGE: line 1: Fetch API cannot load http://example.com:465/ due to access control checks.
+CONSOLE MESSAGE: line 79: Fetch API cannot load http://example.com:465/ due to access control checks.
 Blocked access to external URL http://example.com:512/
-CONSOLE MESSAGE: line 1: Fetch API cannot load http://example.com:512/ due to access control checks.
+CONSOLE MESSAGE: line 79: Fetch API cannot load http://example.com:512/ due to access control checks.
 Blocked access to external URL http://example.com:513/
-CONSOLE MESSAGE: line 1: Fetch API cannot load http://example.com:513/ due to access control checks.
+CONSOLE MESSAGE: line 79: Fetch API cannot load http://example.com:513/ due to access control checks.
 Blocked access to external URL http://example.com:514/
-CONSOLE MESSAGE: line 1: Fetch API cannot load http://example.com:514/ due to access control checks.
+CONSOLE MESSAGE: line 79: Fetch API cannot load http://example.com:514/ due to access control checks.
 Blocked access to external URL http://example.com:515/
-CONSOLE MESSAGE: line 1: Fetch API cannot load http://example.com:515/ due to access control checks.
+CONSOLE MESSAGE: line 79: Fetch API cannot load http://example.com:515/ due to access control checks.
 Blocked access to external URL http://example.com:526/
-CONSOLE MESSAGE: line 1: Fetch API cannot load http://example.com:526/ due to access control checks.
+CONSOLE MESSAGE: line 79: Fetch API cannot load http://example.com:526/ due to access control checks.
 Blocked access to external URL http://example.com:530/
-CONSOLE MESSAGE: line 1: Fetch API cannot load http://example.com:530/ due to access control checks.
+CONSOLE MESSAGE: line 79: Fetch API cannot load http://example.com:530/ due to access control checks.
 Blocked access to external URL http://example.com:531/
-CONSOLE MESSAGE: line 1: Fetch API cannot load http://example.com:531/ due to access control checks.
+CONSOLE MESSAGE: line 79: Fetch API cannot load http://example.com:531/ due to access control checks.
 Blocked access to external URL http://example.com:532/
-CONSOLE MESSAGE: line 1: Fetch API cannot load http://example.com:532/ due to access control checks.
+CONSOLE MESSAGE: line 79: Fetch API cannot load http://example.com:532/ due to access control checks.
 Blocked access to external URL http://example.com:540/
-CONSOLE MESSAGE: line 1: Fetch API cannot load http://example.com:540/ due to access control checks.
+CONSOLE MESSAGE: line 79: Fetch API cannot load http://example.com:540/ due to access control checks.
 Blocked access to external URL http://example.com:556/
-CONSOLE MESSAGE: line 1: Fetch API cannot load http://example.com:556/ due to access control checks.
+CONSOLE MESSAGE: line 79: Fetch API cannot load http://example.com:556/ due to access control checks.
 Blocked access to external URL http://example.com:563/
-CONSOLE MESSAGE: line 1: Fetch API cannot load http://example.com:563/ due to access control checks.
+CONSOLE MESSAGE: line 79: Fetch API cannot load http://example.com:563/ due to access control checks.
 Blocked access to external URL http://example.com:587/
-CONSOLE MESSAGE: line 1: Fetch API cannot load http://example.com:587/ due to access control checks.
+CONSOLE MESSAGE: line 79: Fetch API cannot load http://example.com:587/ due to access control checks.
 Blocked access to external URL http://example.com:601/
-CONSOLE MESSAGE: line 1: Fetch API cannot load http://example.com:601/ due to access control checks.
+CONSOLE MESSAGE: line 79: Fetch API cannot load http://example.com:601/ due to access control checks.
 Blocked access to external URL http://example.com:636/
-CONSOLE MESSAGE: line 1: Fetch API cannot load http://example.com:636/ due to access control checks.
+CONSOLE MESSAGE: line 79: Fetch API cannot load http://example.com:636/ due to access control checks.
 Blocked access to external URL http://example.com:993/
-CONSOLE MESSAGE: line 1: Fetch API cannot load http://example.com:993/ due to access control checks.
+CONSOLE MESSAGE: line 79: Fetch API cannot load http://example.com:993/ due to access control checks.
 Blocked access to external URL http://example.com:995/
-CONSOLE MESSAGE: line 1: Fetch API cannot load http://example.com:995/ due to access control checks.
+CONSOLE MESSAGE: line 79: Fetch API cannot load http://example.com:995/ due to access control checks.
 Blocked access to external URL http://example.com:2049/
-CONSOLE MESSAGE: line 1: Fetch API cannot load http://example.com:2049/ due to access control checks.
+CONSOLE MESSAGE: line 79: Fetch API cannot load http://example.com:2049/ due to access control checks.
 Blocked access to external URL http://example.com:3659/
-CONSOLE MESSAGE: line 1: Fetch API cannot load http://example.com:3659/ due to access control checks.
+CONSOLE MESSAGE: line 79: Fetch API cannot load http://example.com:3659/ due to access control checks.
 Blocked access to external URL http://example.com:4045/
-CONSOLE MESSAGE: line 1: Fetch API cannot load http://example.com:4045/ due to access control checks.
+CONSOLE MESSAGE: line 79: Fetch API cannot load http://example.com:4045/ due to access control checks.
 Blocked access to external URL http://example.com:6000/
-CONSOLE MESSAGE: line 1: Fetch API cannot load http://example.com:6000/ due to access control checks.
+CONSOLE MESSAGE: line 79: Fetch API cannot load http://example.com:6000/ due to access control checks.
 Blocked access to external URL http://example.com:6665/
-CONSOLE MESSAGE: line 1: Fetch API cannot load http://example.com:6665/ due to access control checks.
+CONSOLE MESSAGE: line 79: Fetch API cannot load http://example.com:6665/ due to access control checks.
 Blocked access to external URL http://example.com:6666/
-CONSOLE MESSAGE: line 1: Fetch API cannot load http://example.com:6666/ due to access control checks.
+CONSOLE MESSAGE: line 79: Fetch API cannot load http://example.com:6666/ due to access control checks.
 Blocked access to external URL http://example.com:6667/
-CONSOLE MESSAGE: line 1: Fetch API cannot load http://example.com:6667/ due to access control checks.
+CONSOLE MESSAGE: line 79: Fetch API cannot load http://example.com:6667/ due to access control checks.
 Blocked access to external URL http://example.com:6668/
-CONSOLE MESSAGE: line 1: Fetch API cannot load http://example.com:6668/ due to access control checks.
+CONSOLE MESSAGE: line 79: Fetch API cannot load http://example.com:6668/ due to access control checks.
 Blocked access to external URL http://example.com:6669/
-CONSOLE MESSAGE: line 1: Fetch API cannot load http://example.com:6669/ due to access control checks.
+CONSOLE MESSAGE: line 79: Fetch API cannot load http://example.com:6669/ due to access control checks.
 
 PASS Request on bad port 1 should throw TypeError. 
 PASS Request on bad port 7 should throw TypeError. 

Modified: trunk/Source/WebCore/CMakeLists.txt (220049 => 220050)


--- trunk/Source/WebCore/CMakeLists.txt	2017-07-30 17:36:26 UTC (rev 220049)
+++ trunk/Source/WebCore/CMakeLists.txt	2017-07-30 20:27:19 UTC (rev 220050)
@@ -3823,11 +3823,8 @@
 # WebCore JS Builtins
 
 set(WebCore_BUILTINS_SOURCES
-    ${WEBCORE_DIR}/Modules/fetch/DOMWindowFetch.js
     ${WEBCORE_DIR}/Modules/fetch/FetchInternals.js
-    ${WEBCORE_DIR}/Modules/fetch/FetchRequest.js
     ${WEBCORE_DIR}/Modules/fetch/FetchResponse.js
-    ${WEBCORE_DIR}/Modules/fetch/WorkerGlobalScopeFetch.js
     ${WEBCORE_DIR}/Modules/mediastream/NavigatorUserMedia.js
     ${WEBCORE_DIR}/Modules/mediastream/RTCPeerConnection.js
     ${WEBCORE_DIR}/Modules/mediastream/RTCPeerConnectionInternals.js

Modified: trunk/Source/WebCore/ChangeLog (220049 => 220050)


--- trunk/Source/WebCore/ChangeLog	2017-07-30 17:36:26 UTC (rev 220049)
+++ trunk/Source/WebCore/ChangeLog	2017-07-30 20:27:19 UTC (rev 220050)
@@ -1,3 +1,65 @@
+2017-07-30  Sam Weinig  <s...@webkit.org>
+
+        [WebIDL] Remove JS builtin bindings for FetchRequest, DOMWindowFetch and WorkerGlobalScopeFetch
+        https://bugs.webkit.org/show_bug.cgi?id=174974
+
+        Reviewed by Darin Adler.
+
+        * CMakeLists.txt:
+        * DerivedSources.make:
+        * WebCore.xcodeproj/project.pbxproj:
+        * Modules/fetch/DOMWindowFetch.js: Removed.
+        * Modules/fetch/FetchRequest.js: Removed.
+        * Modules/fetch/WorkerGlobalScopeFetch.js: Removed.
+        Remove builtin files.
+
+        * Modules/fetch/DOMWindowFetch.cpp:
+        (WebCore::DOMWindowFetch::fetch):
+        * Modules/fetch/DOMWindowFetch.h:
+        * Modules/fetch/DOMWindowFetch.idl:
+        * Modules/fetch/WorkerGlobalScopeFetch.cpp:
+        (WebCore::WorkerGlobalScopeFetch::fetch):
+        * Modules/fetch/WorkerGlobalScopeFetch.h:
+        * Modules/fetch/WorkerGlobalScopeFetch.idl:
+        Remove builtin and instead create FetchRequest in the implementation.
+
+        * Modules/fetch/FetchBody.cpp:
+        (WebCore::FetchBody::extract):
+        * Modules/fetch/FetchBody.h:
+        * Modules/fetch/FetchBodyOwner.cpp:
+        (WebCore::FetchBodyOwner::extractBody):
+        * Modules/fetch/FetchBodyOwner.h:
+        * Modules/fetch/FetchResponse.cpp:
+        * Modules/fetch/FetchResponse.h:
+        Rename FetchBody::BindingDataType to FetchBody::Init to match its IDL naming.
+
+        * Modules/fetch/FetchHeaders.cpp:
+        (WebCore::appendToHeaderMap):
+        (WebCore::fillHeaderMap):
+        (WebCore::FetchHeaders::create):
+        (WebCore::FetchHeaders::fill):
+        * Modules/fetch/FetchHeaders.h:
+        Add helpers to implement the fill algorithm for various input types.
+        Leave the existing fill for now, as it is still used by the FetchResponse
+        builtin, but will eventually be removed.
+
+        * Modules/fetch/FetchRequest.cpp:
+        (WebCore::FetchRequest::initializeOptions):
+        (WebCore::FetchRequest::initializeWith):
+        (WebCore::FetchRequest::setBody):
+        (WebCore::FetchRequest::create):
+        (WebCore::FetchRequest::setBodyFromInputRequest): Deleted.
+        * Modules/fetch/FetchRequest.h:
+        Migrate builtin code to the implementation. This is 1-to-1 re-implementation,
+        so I did not attempt to fix any conformance issues. That will come in follow up.
+
+        * Modules/fetch/FetchRequest.idl:
+        Replace builtins with an IDL constructor.
+
+        * Modules/fetch/FetchRequestInit.h:
+        * Modules/fetch/FetchRequestInit.idl:
+        Add missing headers and body to FetchRequestInit.
+
 2017-07-30  Said Abou-Hallawa  <sabouhall...@apple.com>
 
         RenderImageResourceStyleImage::image() should return the nullImage() if the image is not available

Modified: trunk/Source/WebCore/DerivedSources.make (220049 => 220050)


--- trunk/Source/WebCore/DerivedSources.make	2017-07-30 17:36:26 UTC (rev 220049)
+++ trunk/Source/WebCore/DerivedSources.make	2017-07-30 20:27:19 UTC (rev 220050)
@@ -1381,11 +1381,8 @@
 # WebCore JS Builtins
 
 WebCore_BUILTINS_SOURCES = \
-    ${WebCore}/Modules/fetch/DOMWindowFetch.js \
     $(WebCore)/Modules/fetch/FetchInternals.js \
-    $(WebCore)/Modules/fetch/FetchRequest.js \
     $(WebCore)/Modules/fetch/FetchResponse.js \
-    ${WebCore}/Modules/fetch/WorkerGlobalScopeFetch.js \
     $(WebCore)/Modules/mediastream/NavigatorUserMedia.js \
     $(WebCore)/Modules/mediastream/RTCPeerConnection.js \
     $(WebCore)/Modules/mediastream/RTCPeerConnectionInternals.js \

Modified: trunk/Source/WebCore/Modules/fetch/DOMWindowFetch.cpp (220049 => 220050)


--- trunk/Source/WebCore/Modules/fetch/DOMWindowFetch.cpp	2017-07-30 17:36:26 UTC (rev 220049)
+++ trunk/Source/WebCore/Modules/fetch/DOMWindowFetch.cpp	2017-07-30 20:27:19 UTC (rev 220050)
@@ -38,12 +38,21 @@
 
 namespace WebCore {
 
-void DOMWindowFetch::fetch(DOMWindow& window, FetchRequest& request, Ref<DeferredPromise>&& promise)
+void DOMWindowFetch::fetch(DOMWindow& window, FetchRequest::Info&& input, FetchRequest::Init&& init, Ref<DeferredPromise>&& promise)
 {
     auto* document = window.document();
-    if (!document)
+    if (!document) {
+        promise->reject(InvalidStateError);
         return;
-    FetchResponse::fetch(*document, request, WTFMove(promise));
+    }
+
+    auto request = FetchRequest::create(*document, WTFMove(input), WTFMove(init));
+    if (request.hasException()) {
+        promise->reject(request.releaseException());
+        return;
+    }
+
+    FetchResponse::fetch(*document, request.releaseReturnValue().get(), WTFMove(promise));
 }
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/Modules/fetch/DOMWindowFetch.h (220049 => 220050)


--- trunk/Source/WebCore/Modules/fetch/DOMWindowFetch.h	2017-07-30 17:36:26 UTC (rev 220049)
+++ trunk/Source/WebCore/Modules/fetch/DOMWindowFetch.h	2017-07-30 20:27:19 UTC (rev 220050)
@@ -30,6 +30,7 @@
 
 #if ENABLE(FETCH_API)
 
+#include "FetchRequest.h"
 #include "JSDOMPromiseDeferred.h"
 #include <wtf/Forward.h>
 
@@ -36,11 +37,10 @@
 namespace WebCore {
 
 class DOMWindow;
-class FetchRequest;
 
 class DOMWindowFetch {
 public:
-    static void fetch(DOMWindow&, FetchRequest&, Ref<DeferredPromise>&&);
+    static void fetch(DOMWindow&, FetchRequest::Info&&, FetchRequest::Init&&, Ref<DeferredPromise>&&);
 };
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/Modules/fetch/DOMWindowFetch.idl (220049 => 220050)


--- trunk/Source/WebCore/Modules/fetch/DOMWindowFetch.idl	2017-07-30 17:36:26 UTC (rev 220049)
+++ trunk/Source/WebCore/Modules/fetch/DOMWindowFetch.idl	2017-07-30 20:27:19 UTC (rev 220050)
@@ -32,6 +32,5 @@
     Conditional=FETCH_API,
     EnabledAtRuntime=FetchAPI,
 ] partial interface DOMWindow {
-    [JSBuiltin] Promise<FetchResponse> fetch(RequestInfo input, optional FetchRequestInit init);
-    [PrivateIdentifier, ImplementedAs=fetch] Promise<FetchResponse> fetchRequest(FetchRequest request);
+    Promise<FetchResponse> fetch(RequestInfo input, optional FetchRequestInit init);
 };

Deleted: trunk/Source/WebCore/Modules/fetch/DOMWindowFetch.js (220049 => 220050)


--- trunk/Source/WebCore/Modules/fetch/DOMWindowFetch.js	2017-07-30 17:36:26 UTC (rev 220049)
+++ trunk/Source/WebCore/Modules/fetch/DOMWindowFetch.js	2017-07-30 20:27:19 UTC (rev 220050)
@@ -1,37 +0,0 @@
-/*
- * Copyright (C) 2016 Apple Inc.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-// @conditional=ENABLE(FETCH_API)
-
-function fetch(input, init)
-{
-    "use strict";
-
-    try {
-        return @fetchRequest(new @Request(input, init));
-    } catch (e) {
-        return @Promise.@reject(e);
-    }
-}

Modified: trunk/Source/WebCore/Modules/fetch/FetchBody.cpp (220049 => 220050)


--- trunk/Source/WebCore/Modules/fetch/FetchBody.cpp	2017-07-30 17:36:26 UTC (rev 220049)
+++ trunk/Source/WebCore/Modules/fetch/FetchBody.cpp	2017-07-30 20:27:19 UTC (rev 220050)
@@ -42,7 +42,7 @@
 
 namespace WebCore {
 
-FetchBody FetchBody::extract(ScriptExecutionContext& context, BindingDataType&& value, String& contentType)
+FetchBody FetchBody::extract(ScriptExecutionContext& context, Init&& value, String& contentType)
 {
     if (WTF::holds_alternative<RefPtr<Blob>>(value)) {
         Ref<const Blob> blob = WTF::get<RefPtr<Blob>>(value).releaseNonNull();

Modified: trunk/Source/WebCore/Modules/fetch/FetchBody.h (220049 => 220050)


--- trunk/Source/WebCore/Modules/fetch/FetchBody.h	2017-07-30 17:36:26 UTC (rev 220049)
+++ trunk/Source/WebCore/Modules/fetch/FetchBody.h	2017-07-30 20:27:19 UTC (rev 220050)
@@ -63,8 +63,8 @@
     bool isText() const { return WTF::holds_alternative<String>(m_data); }
     bool isReadableStream() const { return m_isReadableStream; }
 
-    using BindingDataType = Variant<RefPtr<Blob>, RefPtr<ArrayBufferView>, RefPtr<ArrayBuffer>, RefPtr<DOMFormData>, RefPtr<URLSearchParams>, String>;
-    static FetchBody extract(ScriptExecutionContext&, BindingDataType&&, String&);
+    using Init = Variant<RefPtr<Blob>, RefPtr<ArrayBufferView>, RefPtr<ArrayBuffer>, RefPtr<DOMFormData>, RefPtr<URLSearchParams>, String>;
+    static FetchBody extract(ScriptExecutionContext&, Init&&, String&);
     static FetchBody loadingBody() { return { }; }
     static FetchBody readableStreamBody();
 

Modified: trunk/Source/WebCore/Modules/fetch/FetchBodyOwner.cpp (220049 => 220050)


--- trunk/Source/WebCore/Modules/fetch/FetchBodyOwner.cpp	2017-07-30 17:36:26 UTC (rev 220049)
+++ trunk/Source/WebCore/Modules/fetch/FetchBodyOwner.cpp	2017-07-30 20:27:19 UTC (rev 220050)
@@ -109,7 +109,7 @@
     m_body = owner.m_body->clone();
 }
 
-void FetchBodyOwner::extractBody(ScriptExecutionContext& context, FetchBody::BindingDataType&& value)
+void FetchBodyOwner::extractBody(ScriptExecutionContext& context, FetchBody::Init&& value)
 {
     m_body = FetchBody::extract(context, WTFMove(value), m_contentType);
 }

Modified: trunk/Source/WebCore/Modules/fetch/FetchBodyOwner.h (220049 => 220050)


--- trunk/Source/WebCore/Modules/fetch/FetchBodyOwner.h	2017-07-30 17:36:26 UTC (rev 220049)
+++ trunk/Source/WebCore/Modules/fetch/FetchBodyOwner.h	2017-07-30 20:27:19 UTC (rev 220050)
@@ -65,7 +65,7 @@
     bool isBodyNull() const { return !m_body; }
     void cloneBody(const FetchBodyOwner&);
 
-    void extractBody(ScriptExecutionContext&, FetchBody::BindingDataType&&);
+    void extractBody(ScriptExecutionContext&, FetchBody::Init&&);
     void updateContentType();
     void consumeOnceLoadingFinished(FetchBodyConsumer::Type, Ref<DeferredPromise>&&);
 

Modified: trunk/Source/WebCore/Modules/fetch/FetchHeaders.cpp (220049 => 220050)


--- trunk/Source/WebCore/Modules/fetch/FetchHeaders.cpp	2017-07-30 17:36:26 UTC (rev 220049)
+++ trunk/Source/WebCore/Modules/fetch/FetchHeaders.cpp	2017-07-30 20:27:19 UTC (rev 220050)
@@ -62,35 +62,73 @@
     return { };
 }
 
+static ExceptionOr<void> appendToHeaderMap(const HTTPHeaderMap::HTTPHeaderMapConstIterator::KeyValue& header, HTTPHeaderMap& headers, FetchHeaders::Guard guard)
+{
+    auto canWriteResult = canWriteHeader(header.key, header.value, guard);
+    if (canWriteResult.hasException())
+        return canWriteResult.releaseException();
+    if (!canWriteResult.releaseReturnValue())
+        return { };
+    if (header.keyAsHTTPHeaderName)
+        headers.add(header.keyAsHTTPHeaderName.value(), header.value);
+    else
+        headers.add(header.key, header.value);
+    return { };
+}
 
-ExceptionOr<Ref<FetchHeaders>> FetchHeaders::create(std::optional<HeadersInit>&& headersInit)
+// https://fetch.spec.whatwg.org/#concept-headers-fill
+static ExceptionOr<void> fillHeaderMap(HTTPHeaderMap& headers, const FetchHeaders::Init& headersInit, FetchHeaders::Guard guard)
 {
+    if (WTF::holds_alternative<Vector<Vector<String>>>(headersInit)) {
+        auto& sequence = WTF::get<Vector<Vector<String>>>(headersInit);
+        for (auto& header : sequence) {
+            if (header.size() != 2)
+                return Exception { TypeError, "Header sub-sequence must contain exactly two items" };
+            auto result = appendToHeaderMap(header[0], header[1], headers, guard);
+            if (result.hasException())
+                return result.releaseException();
+        }
+    } else {
+        auto& record = WTF::get<Vector<WTF::KeyValuePair<String, String>>>(headersInit);
+        for (auto& header : record) {
+            auto result = appendToHeaderMap(header.key, header.value, headers, guard);
+            if (result.hasException())
+                return result.releaseException();
+        }
+    }
+
+    return { };
+}
+
+ExceptionOr<Ref<FetchHeaders>> FetchHeaders::create(std::optional<Init>&& headersInit)
+{
     HTTPHeaderMap headers;
 
     if (headersInit) {
-        if (WTF::holds_alternative<Vector<Vector<String>>>(*headersInit)) {
-            auto& sequence = WTF::get<Vector<Vector<String>>>(*headersInit);
-            for (auto& header : sequence) {
-                if (header.size() != 2)
-                    return Exception { TypeError, "Header sub-sequence must contain exactly two items" };
-                auto result = appendToHeaderMap(header[0], header[1], headers, Guard::None);
-                if (result.hasException())
-                    return result.releaseException();
-            }
-        } else {
-            auto& record = WTF::get<Vector<WTF::KeyValuePair<String, String>>>(*headersInit);
-            for (auto& header : record) {
-                auto result = appendToHeaderMap(header.key, header.value, headers, Guard::None);
-                if (result.hasException())
-                    return result.releaseException();
-            }
-        }
+        auto result = fillHeaderMap(headers, *headersInit, Guard::None);
+        if (result.hasException())
+            return result.releaseException();
     }
 
     return adoptRef(*new FetchHeaders { Guard::None, WTFMove(headers) });
 }
 
+ExceptionOr<void> FetchHeaders::fill(const Init& headerInit)
+{
+    return fillHeaderMap(m_headers, headerInit, m_guard);
+}
 
+ExceptionOr<void> FetchHeaders::fill(const FetchHeaders& otherHeaders)
+{
+    for (auto& header : otherHeaders.m_headers) {
+        auto result = appendToHeaderMap(header, m_headers, m_guard);
+        if (result.hasException())
+            return result.releaseException();
+    }
+
+    return { };
+}
+
 ExceptionOr<void> FetchHeaders::append(const String& name, const String& value)
 {
     return appendToHeaderMap(name, value, m_headers, m_guard);

Modified: trunk/Source/WebCore/Modules/fetch/FetchHeaders.h (220049 => 220050)


--- trunk/Source/WebCore/Modules/fetch/FetchHeaders.h	2017-07-30 17:36:26 UTC (rev 220049)
+++ trunk/Source/WebCore/Modules/fetch/FetchHeaders.h	2017-07-30 20:27:19 UTC (rev 220050)
@@ -49,10 +49,8 @@
     };
 
     using Init = Variant<Vector<Vector<String>>, Vector<WTF::KeyValuePair<String, String>>>;
+    static ExceptionOr<Ref<FetchHeaders>> create(std::optional<Init>&&);
 
-    using HeadersInit = Variant<Vector<Vector<String>>, Vector<WTF::KeyValuePair<String, String>>>;
-    static ExceptionOr<Ref<FetchHeaders>> create(std::optional<HeadersInit>&&);
-
     static Ref<FetchHeaders> create(Guard guard = Guard::None) { return adoptRef(*new FetchHeaders { guard }); }
     static Ref<FetchHeaders> create(const FetchHeaders& headers) { return adoptRef(*new FetchHeaders { headers }); }
 
@@ -62,6 +60,9 @@
     ExceptionOr<bool> has(const String&) const;
     ExceptionOr<void> set(const String& name, const String& value);
 
+    ExceptionOr<void> fill(const Init&);
+    ExceptionOr<void> fill(const FetchHeaders&);
+
     void fill(const FetchHeaders*);
     void filterAndFill(const HTTPHeaderMap&, Guard);
 
@@ -85,12 +86,7 @@
     void setGuard(Guard);
 
 private:
-    FetchHeaders(Guard guard, HTTPHeaderMap&& headers = { })
-        : m_guard(guard)
-        , m_headers(WTFMove(headers))
-    {
-    }
-
+    explicit FetchHeaders(Guard guard, HTTPHeaderMap&& headers = { });
     FetchHeaders(const FetchHeaders&);
 
     Guard m_guard;
@@ -97,6 +93,12 @@
     HTTPHeaderMap m_headers;
 };
 
+inline FetchHeaders::FetchHeaders(Guard guard, HTTPHeaderMap&& headers)
+    : m_guard(guard)
+    , m_headers(WTFMove(headers))
+{
+}
+
 inline FetchHeaders::FetchHeaders(const FetchHeaders& other)
     : m_guard(other.m_guard)
     , m_headers(other.m_headers)

Modified: trunk/Source/WebCore/Modules/fetch/FetchRequest.cpp (220049 => 220050)


--- trunk/Source/WebCore/Modules/fetch/FetchRequest.cpp	2017-07-30 17:36:26 UTC (rev 220049)
+++ trunk/Source/WebCore/Modules/fetch/FetchRequest.cpp	2017-07-30 20:27:19 UTC (rev 220050)
@@ -119,7 +119,7 @@
     return internalRequest.request.httpMethod() != "GET" && internalRequest.request.httpMethod() != "HEAD";
 }
 
-ExceptionOr<FetchHeaders&> FetchRequest::initializeOptions(const Init& init)
+ExceptionOr<void> FetchRequest::initializeOptions(const Init& init)
 {
     ASSERT(scriptExecutionContext());
 
@@ -135,10 +135,11 @@
             return Exception { TypeError, ASCIILiteral("There cannot be an integrity in no-cors mode.") };
         m_headers->setGuard(FetchHeaders::Guard::RequestNoCors);
     }
-    return m_headers.get();
+    
+    return { };
 }
 
-ExceptionOr<FetchHeaders&> FetchRequest::initializeWith(const String& url, const Init& init)
+ExceptionOr<void> FetchRequest::initializeWith(const String& url, Init&& init)
 {
     ASSERT(scriptExecutionContext());
     // FIXME: Tighten the URL parsing algorithm according https://url.spec.whatwg.org/#concept-url-parser.
@@ -153,10 +154,27 @@
     m_internalRequest.request.setRequester(ResourceRequest::Requester::Fetch);
     m_internalRequest.request.setInitiatorIdentifier(scriptExecutionContext()->resourceRequestIdentifier());
 
-    return initializeOptions(init);
+    auto optionsResult = initializeOptions(init);
+    if (optionsResult.hasException())
+        return optionsResult.releaseException();
+
+    if (init.headers) {
+        auto fillResult = m_headers->fill(*init.headers);
+        if (fillResult.hasException())
+            return fillResult.releaseException();
+    }
+
+    if (init.body) {
+        auto setBodyResult = setBody(WTFMove(*init.body));
+        if (setBodyResult.hasException())
+            return setBodyResult.releaseException();
+    }
+
+    updateContentType();
+    return { };
 }
 
-ExceptionOr<FetchHeaders&> FetchRequest::initializeWith(FetchRequest& input, const Init& init)
+ExceptionOr<void> FetchRequest::initializeWith(FetchRequest& input, Init&& init)
 {
     if (input.isDisturbedOrLocked())
         return Exception {TypeError, ASCIILiteral("Request input is disturbed or locked.") };
@@ -163,10 +181,35 @@
 
     m_internalRequest = input.m_internalRequest;
 
-    return initializeOptions(init);
+    auto optionsResult = initializeOptions(init);
+    if (optionsResult.hasException())
+        return optionsResult.releaseException();
+
+    if (init.headers) {
+        auto fillResult = m_headers->fill(*init.headers);
+        if (fillResult.hasException())
+            return fillResult.releaseException();
+    } else {
+        auto fillResult = m_headers->fill(input.headers());
+        if (fillResult.hasException())
+            return fillResult.releaseException();
+    }
+
+    if (init.body) {
+        auto setBodyResult = setBody(WTFMove(*init.body));
+        if (setBodyResult.hasException())
+            return setBodyResult.releaseException();
+    } else {
+        auto setBodyResult = setBody(input);
+        if (setBodyResult.hasException())
+            return setBodyResult.releaseException();
+    }
+
+    updateContentType();
+    return { };
 }
 
-ExceptionOr<void> FetchRequest::setBody(FetchBody::BindingDataType&& body)
+ExceptionOr<void> FetchRequest::setBody(FetchBody::Init&& body)
 {
     if (!methodCanHaveBody(m_internalRequest))
         return Exception { TypeError };
@@ -173,22 +216,37 @@
 
     ASSERT(scriptExecutionContext());
     extractBody(*scriptExecutionContext(), WTFMove(body));
-    updateContentType();
     return { };
 }
 
-ExceptionOr<void> FetchRequest::setBodyFromInputRequest(FetchRequest* request)
+ExceptionOr<void> FetchRequest::setBody(FetchRequest& request)
 {
-    if (request && !request->isBodyNull()) {
+    if (!request.isBodyNull()) {
         if (!methodCanHaveBody(m_internalRequest))
             return Exception { TypeError };
-        m_body = WTFMove(request->m_body);
-        request->setDisturbed();
+        m_body = WTFMove(request.m_body);
+        request.setDisturbed();
     }
-    updateContentType();
     return { };
 }
 
+ExceptionOr<Ref<FetchRequest>> FetchRequest::create(ScriptExecutionContext& context, Info&& input, Init&& init)
+{
+    auto request = adoptRef(*new FetchRequest(context, std::nullopt, FetchHeaders::create(FetchHeaders::Guard::Request), { }));
+
+    if (WTF::holds_alternative<String>(input)) {
+        auto result = request->initializeWith(WTF::get<String>(input), WTFMove(init));
+        if (result.hasException())
+            return result.releaseException();
+    } else {
+        auto result = request->initializeWith(*WTF::get<RefPtr<FetchRequest>>(input), WTFMove(init));
+        if (result.hasException())
+            return result.releaseException();
+    }
+
+    return WTFMove(request);
+}
+
 String FetchRequest::referrer() const
 {
     if (m_internalRequest.referrer == "no-referrer")

Modified: trunk/Source/WebCore/Modules/fetch/FetchRequest.h (220049 => 220050)


--- trunk/Source/WebCore/Modules/fetch/FetchRequest.h	2017-07-30 17:36:26 UTC (rev 220049)
+++ trunk/Source/WebCore/Modules/fetch/FetchRequest.h	2017-07-30 20:27:19 UTC (rev 220050)
@@ -45,6 +45,9 @@
 
 class FetchRequest final : public FetchBodyOwner {
 public:
+    using Init = FetchRequestInit;
+    using Info = Variant<RefPtr<FetchRequest>, String>;
+
     using Cache = FetchOptions::Cache;
     using Credentials = FetchOptions::Credentials;
     using Destination = FetchOptions::Destination;
@@ -52,15 +55,9 @@
     using Redirect = FetchOptions::Redirect;
     using ReferrerPolicy = FetchOptions::ReferrerPolicy;
     using Type = FetchOptions::Type;
-    using Init = FetchRequestInit;
 
-    static Ref<FetchRequest> create(ScriptExecutionContext& context) { return adoptRef(*new FetchRequest(context, std::nullopt, FetchHeaders::create(FetchHeaders::Guard::Request), { })); }
+    static ExceptionOr<Ref<FetchRequest>> create(ScriptExecutionContext&, Info&&, Init&&);
 
-    ExceptionOr<FetchHeaders&> initializeWith(FetchRequest&, const Init&);
-    ExceptionOr<FetchHeaders&> initializeWith(const String&, const Init&);
-    ExceptionOr<void> setBody(FetchBody::BindingDataType&&);
-    ExceptionOr<void> setBodyFromInputRequest(FetchRequest*);
-
     const String& method() const { return m_internalRequest.request.httpMethod(); }
     const String& url() const;
     FetchHeaders& headers() { return m_headers.get(); }
@@ -93,7 +90,11 @@
 private:
     FetchRequest(ScriptExecutionContext&, std::optional<FetchBody>&&, Ref<FetchHeaders>&&, InternalRequest&&);
 
-    ExceptionOr<FetchHeaders&> initializeOptions(const Init&);
+    ExceptionOr<void> initializeOptions(const Init&);
+    ExceptionOr<void> initializeWith(FetchRequest&, Init&&);
+    ExceptionOr<void> initializeWith(const String&, Init&&);
+    ExceptionOr<void> setBody(FetchBody::Init&&);
+    ExceptionOr<void> setBody(FetchRequest&);
 
     const char* activeDOMObjectName() const final;
     bool canSuspendForDocumentSuspension() const final;

Modified: trunk/Source/WebCore/Modules/fetch/FetchRequest.idl (220049 => 220050)


--- trunk/Source/WebCore/Modules/fetch/FetchRequest.idl	2017-07-30 17:36:26 UTC (rev 220049)
+++ trunk/Source/WebCore/Modules/fetch/FetchRequest.idl	2017-07-30 20:27:19 UTC (rev 220050)
@@ -29,7 +29,7 @@
 enum FetchRequestType { "", "audio", "font", "image", "script", "style", "track", "video" };
 enum FetchRequestDestination { "", "document", "sharedworker", "subresource", "unknown", "worker" };
 
-typedef (Request or USVString) RequestInfo;
+typedef (FetchRequest or USVString) RequestInfo;
 
 // FIXME: Should include ReadableStream
 typedef (Blob or BufferSource or DOMFormData or URLSearchParams or USVString) BodyInit;
@@ -38,12 +38,11 @@
     ActiveDOMObject,
     Conditional=FETCH_API,
     Constructor(RequestInfo input, optional FetchRequestInit init),
+    ConstructorMayThrowException,
+    ConstructorCallWith=ScriptExecutionContext,
     EnabledAtRuntime=FetchAPI,
     Exposed=(Window,Worker),
     InterfaceName=Request,
-    JSBuiltinConstructor,
-    PrivateIdentifier,
-    PublicIdentifier,
 ] interface FetchRequest {
     readonly attribute ByteString method;
     readonly attribute USVString url;
@@ -62,11 +61,6 @@
     // readonly attribute boolean keepalive;
 
     [CallWith=ScriptExecutionContext, MayThrowException, NewObject] FetchRequest clone();
-
-    [MayThrowException, NewObject, PrivateIdentifier] FetchHeaders initializeWith(FetchRequest input, FetchRequestInit init);
-    [MayThrowException, NewObject, PrivateIdentifier] FetchHeaders initializeWith(DOMString input, FetchRequestInit init);
-    [MayThrowException, PrivateIdentifier] void setBody(BodyInit body);
-    [MayThrowException, PrivateIdentifier] void setBodyFromInputRequest(FetchRequest? request);
 };
 
 FetchRequest implements FetchBody;

Deleted: trunk/Source/WebCore/Modules/fetch/FetchRequest.js (220049 => 220050)


--- trunk/Source/WebCore/Modules/fetch/FetchRequest.js	2017-07-30 17:36:26 UTC (rev 220049)
+++ trunk/Source/WebCore/Modules/fetch/FetchRequest.js	2017-07-30 20:27:19 UTC (rev 220050)
@@ -1,53 +0,0 @@
-/*
- * Copyright (C) 2016 Apple Inc.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-// @conditional=ENABLE(FETCH_API)
-
-function initializeFetchRequest(input, init)
-{
-    "use strict";
-
-    if (init === @undefined)
-        init = { };
-    else if (!@isObject(init))
-        @throwTypeError("Request init must be an object");
-
-    const headers = this.@initializeWith(input, init);
-    @assert(headers instanceof @Headers);
-
-    const inputIsRequest = input instanceof @Request;
-    if ("headers" in init)
-        @fillFetchHeaders(headers, init.headers)
-    else if (inputIsRequest)
-        @fillFetchHeaders(headers, input.headers)
-
-    const hasInitBody = init.body !== @undefined && init.body !== null;
-    if (hasInitBody)
-        this.@setBody(init.body)
-    else
-        this.@setBodyFromInputRequest(inputIsRequest ? input : null);
-
-    return this;
-}

Modified: trunk/Source/WebCore/Modules/fetch/FetchRequestInit.h (220049 => 220050)


--- trunk/Source/WebCore/Modules/fetch/FetchRequestInit.h	2017-07-30 17:36:26 UTC (rev 220049)
+++ trunk/Source/WebCore/Modules/fetch/FetchRequestInit.h	2017-07-30 20:27:19 UTC (rev 220050)
@@ -25,6 +25,8 @@
 
 #pragma once
 
+#include "FetchBody.h"
+#include "FetchHeaders.h"
 #include "FetchOptions.h"
 #include <runtime/JSCJSValue.h>
 #include <wtf/Optional.h>
@@ -34,8 +36,8 @@
 
 struct FetchRequestInit {
     String method;
-    // FIXME: Should add: HeadersInit headers;
-    // FIXME: Should add: BodyInit? body;
+    std::optional<FetchHeaders::Init> headers;
+    std::optional<FetchBody::Init> body;
     String referrer;
     std::optional<FetchOptions::ReferrerPolicy> referrerPolicy;
     std::optional<FetchOptions::Mode> mode;

Modified: trunk/Source/WebCore/Modules/fetch/FetchRequestInit.idl (220049 => 220050)


--- trunk/Source/WebCore/Modules/fetch/FetchRequestInit.idl	2017-07-30 17:36:26 UTC (rev 220049)
+++ trunk/Source/WebCore/Modules/fetch/FetchRequestInit.idl	2017-07-30 20:27:19 UTC (rev 220050)
@@ -30,8 +30,8 @@
 
 dictionary FetchRequestInit {
     ByteString method;
-    // HeadersInit headers;
-    // BodyInit? body;
+    HeadersInit headers;
+    BodyInit? body;
     USVString referrer;
     FetchReferrerPolicy referrerPolicy;
     FetchRequestMode mode;

Modified: trunk/Source/WebCore/Modules/fetch/FetchResponse.cpp (220049 => 220050)


--- trunk/Source/WebCore/Modules/fetch/FetchResponse.cpp	2017-07-30 17:36:26 UTC (rev 220049)
+++ trunk/Source/WebCore/Modules/fetch/FetchResponse.cpp	2017-07-30 20:27:19 UTC (rev 220050)
@@ -74,7 +74,7 @@
     return { };
 }
 
-void FetchResponse::initializeWith(FetchBody::BindingDataType&& body)
+void FetchResponse::initializeWith(FetchBody::Init&& body)
 {
     ASSERT(scriptExecutionContext());
     extractBody(*scriptExecutionContext(), WTFMove(body));

Modified: trunk/Source/WebCore/Modules/fetch/FetchResponse.h (220049 => 220050)


--- trunk/Source/WebCore/Modules/fetch/FetchResponse.h	2017-07-30 17:36:26 UTC (rev 220049)
+++ trunk/Source/WebCore/Modules/fetch/FetchResponse.h	2017-07-30 20:27:19 UTC (rev 220050)
@@ -70,7 +70,7 @@
 #endif
 
     ExceptionOr<void> setStatus(int status, const String& statusText);
-    void initializeWith(FetchBody::BindingDataType&&);
+    void initializeWith(FetchBody::Init&&);
     void setBodyAsReadableStream();
 
     Type type() const { return m_response.type(); }

Modified: trunk/Source/WebCore/Modules/fetch/WorkerGlobalScopeFetch.cpp (220049 => 220050)


--- trunk/Source/WebCore/Modules/fetch/WorkerGlobalScopeFetch.cpp	2017-07-30 17:36:26 UTC (rev 220049)
+++ trunk/Source/WebCore/Modules/fetch/WorkerGlobalScopeFetch.cpp	2017-07-30 20:27:19 UTC (rev 220050)
@@ -36,9 +36,15 @@
 
 namespace WebCore {
 
-void WorkerGlobalScopeFetch::fetch(WorkerGlobalScope& scope, FetchRequest& request, Ref<DeferredPromise>&& promise)
+void WorkerGlobalScopeFetch::fetch(WorkerGlobalScope& scope, FetchRequest::Info&& input, FetchRequest::Init&& init, Ref<DeferredPromise>&& promise)
 {
-    FetchResponse::fetch(scope, request, WTFMove(promise));
+    auto request = FetchRequest::create(scope, WTFMove(input), WTFMove(init));
+    if (request.hasException()) {
+        promise->reject(request.releaseException());
+        return;
+    }
+
+    FetchResponse::fetch(scope, request.releaseReturnValue().get(), WTFMove(promise));
 }
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/Modules/fetch/WorkerGlobalScopeFetch.h (220049 => 220050)


--- trunk/Source/WebCore/Modules/fetch/WorkerGlobalScopeFetch.h	2017-07-30 17:36:26 UTC (rev 220049)
+++ trunk/Source/WebCore/Modules/fetch/WorkerGlobalScopeFetch.h	2017-07-30 20:27:19 UTC (rev 220050)
@@ -30,16 +30,16 @@
 
 #if ENABLE(FETCH_API)
 
+#include "FetchRequest.h"
 #include "JSDOMPromiseDeferred.h"
 
 namespace WebCore {
 
-class FetchRequest;
 class WorkerGlobalScope;
 
 class WorkerGlobalScopeFetch {
 public:
-    static void fetch(WorkerGlobalScope&, FetchRequest&, Ref<DeferredPromise>&&);
+    static void fetch(WorkerGlobalScope&, FetchRequest::Info&&, FetchRequest::Init&&, Ref<DeferredPromise>&&);
 };
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/Modules/fetch/WorkerGlobalScopeFetch.idl (220049 => 220050)


--- trunk/Source/WebCore/Modules/fetch/WorkerGlobalScopeFetch.idl	2017-07-30 17:36:26 UTC (rev 220049)
+++ trunk/Source/WebCore/Modules/fetch/WorkerGlobalScopeFetch.idl	2017-07-30 20:27:19 UTC (rev 220050)
@@ -32,6 +32,5 @@
     Conditional=FETCH_API,
     EnabledAtRuntime=FetchAPI,
 ] partial interface WorkerGlobalScope {
-    [JSBuiltin] Promise<FetchResponse> fetch(RequestInfo input, optional FetchRequestInit init);
-    [PrivateIdentifier, ImplementedAs=fetch] Promise<FetchResponse> fetchRequest(FetchRequest request);
+    Promise<FetchResponse> fetch(RequestInfo input, optional FetchRequestInit init);
 };

Deleted: trunk/Source/WebCore/Modules/fetch/WorkerGlobalScopeFetch.js (220049 => 220050)


--- trunk/Source/WebCore/Modules/fetch/WorkerGlobalScopeFetch.js	2017-07-30 17:36:26 UTC (rev 220049)
+++ trunk/Source/WebCore/Modules/fetch/WorkerGlobalScopeFetch.js	2017-07-30 20:27:19 UTC (rev 220050)
@@ -1,37 +0,0 @@
-/*
- * Copyright (C) 2016 Apple Inc.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-// @conditional=ENABLE(FETCH_API)
-
-function fetch(input, init)
-{
-    "use strict";
-
-    try {
-        return @fetchRequest(new @Request(input, init));
-    } catch (e) {
-        return @Promise.@reject(e);
-    }
-}

Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (220049 => 220050)


--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2017-07-30 17:36:26 UTC (rev 220049)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2017-07-30 20:27:19 UTC (rev 220050)
@@ -1700,9 +1700,6 @@
 		41103AAE1E39791000769F03 /* RealtimeIncomingAudioSource.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 41103AAA1E39790A00769F03 /* RealtimeIncomingAudioSource.cpp */; };
 		4123081B138C429700BCCFCA /* WebCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 93F19B1A08245E5A001E9ABC /* WebCore.framework */; };
 		41230913138C42FF00BCCFCA /* _javascript_Core.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F8216299029F4FB501000131 /* _javascript_Core.framework */; };
-		412455341EF442C500F11809 /* FetchRequest.js in Resources */ = {isa = PBXBuildFile; fileRef = 412455331EF442C400F11809 /* FetchRequest.js */; };
-		412455361EF442D000F11809 /* DOMWindowFetch.js in Resources */ = {isa = PBXBuildFile; fileRef = 412455351EF442CE00F11809 /* DOMWindowFetch.js */; };
-		412455381EF442DB00F11809 /* WorkerGlobalScopeFetch.js in Resources */ = {isa = PBXBuildFile; fileRef = 412455371EF442DA00F11809 /* WorkerGlobalScopeFetch.js */; };
 		4127D5370F8AAB1D00E424F5 /* ScriptState.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4127D5360F8AAB1D00E424F5 /* ScriptState.cpp */; };
 		4129DF851BB5B80700322A16 /* JSReadableStreamPrivateConstructors.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4129DF831BB5B7F700322A16 /* JSReadableStreamPrivateConstructors.cpp */; };
 		4129DF861BB5B80C00322A16 /* JSReadableStreamPrivateConstructors.h in Headers */ = {isa = PBXBuildFile; fileRef = 4129DF841BB5B7F700322A16 /* JSReadableStreamPrivateConstructors.h */; settings = {ATTRIBUTES = (Private, ); }; };
@@ -9327,9 +9324,6 @@
 		41189EF71AD8232800B90A0D /* ReadableStreamDefaultController.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = ReadableStreamDefaultController.idl; sourceTree = "<group>"; };
 		41189EF71AD8232800B93F64 /* ReadableByteStreamController.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = ReadableByteStreamController.idl; sourceTree = "<group>"; };
 		41189EF71AD8232800B95672 /* ReadableStreamBYOBRequest.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = ReadableStreamBYOBRequest.idl; sourceTree = "<group>"; };
-		412455331EF442C400F11809 /* FetchRequest.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode._javascript_; path = FetchRequest.js; sourceTree = "<group>"; };
-		412455351EF442CE00F11809 /* DOMWindowFetch.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode._javascript_; path = DOMWindowFetch.js; sourceTree = "<group>"; };
-		412455371EF442DA00F11809 /* WorkerGlobalScopeFetch.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode._javascript_; path = WorkerGlobalScopeFetch.js; sourceTree = "<group>"; };
 		4127D5360F8AAB1D00E424F5 /* ScriptState.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ScriptState.cpp; sourceTree = "<group>"; };
 		4129DF831BB5B7F700322A16 /* JSReadableStreamPrivateConstructors.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSReadableStreamPrivateConstructors.cpp; sourceTree = "<group>"; };
 		4129DF841BB5B7F700322A16 /* JSReadableStreamPrivateConstructors.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSReadableStreamPrivateConstructors.h; sourceTree = "<group>"; };
@@ -17794,7 +17788,6 @@
 				418C39521C8DAC7B0051C8A3 /* DOMWindowFetch.cpp */,
 				418C39531C8DAC7B0051C8A3 /* DOMWindowFetch.h */,
 				418C39541C8DAC7B0051C8A3 /* DOMWindowFetch.idl */,
-				412455351EF442CE00F11809 /* DOMWindowFetch.js */,
 				41F54F7D1C50C4F600338488 /* FetchBody.cpp */,
 				41F54F7E1C50C4F600338488 /* FetchBody.h */,
 				41F54F7F1C50C4F600338488 /* FetchBody.idl */,
@@ -17812,7 +17805,6 @@
 				41F54F871C50C4F600338488 /* FetchRequest.cpp */,
 				41F54F881C50C4F600338488 /* FetchRequest.h */,
 				41F54F891C50C4F600338488 /* FetchRequest.idl */,
-				412455331EF442C400F11809 /* FetchRequest.js */,
 				7CE1914B1F2A9AFB00272F78 /* FetchReferrerPolicy.h */,
 				7CE1914C1F2A9AFB00272F78 /* FetchReferrerPolicy.idl */,
 				7CE1914F1F2A9B0A00272F78 /* FetchRequestMode.h */,
@@ -17834,7 +17826,6 @@
 				418C39571C8DD6960051C8A3 /* WorkerGlobalScopeFetch.cpp */,
 				418C39581C8DD6960051C8A3 /* WorkerGlobalScopeFetch.h */,
 				418C39591C8DD6960051C8A3 /* WorkerGlobalScopeFetch.idl */,
-				412455371EF442DA00F11809 /* WorkerGlobalScopeFetch.js */,
 			);
 			path = fetch;
 			sourceTree = "<group>";
@@ -30346,8 +30337,6 @@
 				A11E8C051B1E28F40003A7C7 /* copyCursor.png in Resources */,
 				D02B64B214089E56006EFA21 /* DictationPhraseWithAlternativesDot.png in Resources */,
 				D02B64B314089E56006EFA21 /* dictationphrasewithalternatives...@2x.png in Resources */,
-				412455361EF442D000F11809 /* DOMWindowFetch.js in Resources */,
-				412455341EF442C500F11809 /* FetchRequest.js in Resources */,
 				7CC7E3D717208C0F003C5277 /* IDNScriptWhiteList.txt in Resources */,
 				2D9F0E1314FF1CBF00BA0FF7 /* linearSRGB.icc in Resources */,
 				BCAD180A131C7A0D00990406 /* Localizable.strings in Resources */,
@@ -30371,7 +30360,6 @@
 				1C2417BA1992C04100EF9938 /* spelling...@3x.png in Resources */,
 				93153BDC141959BC00FCF5BE /* textAreaResizeCorner.png in Resources */,
 				9370918D1416D86B00477333 /* textarearesizecor...@2x.png in Resources */,
-				412455381EF442DB00F11809 /* WorkerGlobalScopeFetch.js in Resources */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to