<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[203675] trunk</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/203675">203675</a></dd>
<dt>Author</dt> <dd>commit-queue@webkit.org</dd>
<dt>Date</dt> <dd>2016-07-24 23:28:35 -0700 (Sun, 24 Jul 2016)</dd>
</dl>
<h3>Log Message</h3>
<pre>[Fetch API] Request should be created with any HeadersInit data
https://bugs.webkit.org/show_bug.cgi?id=159672
Patch by Youenn Fablet <youenn@apple.com> on 2016-07-24
Reviewed by Sam Weinig.
LayoutTests/imported/w3c:
* imported/w3c/web-platform-tests/fetch/api/credentials/authentication-basic-expected.txt: Test was previously
failing due to lack of support for HeadersInit data in Request constructor.
* platform/mac-wk1/imported/w3c/web-platform-tests/fetch/api/credentials/authentication-basic-expected.txt: Removed.
* web-platform-tests/fetch/api/request/request-headers-expected.txt:
* web-platform-tests/fetch/api/request/request-headers.html: Adding new test.
Source/JavaScriptCore:
* Scripts/builtins/builtins_generator.py:
(WK_lcfirst): Synchronized with CodeGenerator.pm version.
Source/WebCore:
Made Request use JSBuiltinConstructor.
This allows initializing newly created Request with a JS built-in function, initializeFetchRequest.
initializeFetchRequest can call @fillFetchHeaders internal built-in to handle any HeadersInit data.
Future effort should be made to migrate more initialization code in initializeFetchRequest.
Made window and worker fetch function as a JS built-in.
This becomes more handy as these new functions can construct the Request object.
They can then call a single private function that takes a Request object as input.
Updated DOMWindowFetch and WorkerGlobalScopeFetch code accordingly.
To enable this, the binding generator is updated to support runtime-enabled JS built-in functions and
private functions atttached to global objects.
Covered by existing and modified tests.
Binding generator test covered by updated binding tests.
* CMakeLists.txt: Adding DOMWindowFetch.js, FetchRequest.js and WorkerGlobalScopeFetch.js built-in files.
* DerivedSources.make: Ditto.
* Modules/fetch/DOMWindowFetch.cpp: Removed overloaded fetch and updated according new signature.
(WebCore::DOMWindowFetch::fetch):
* Modules/fetch/DOMWindowFetch.h: Ditto.
* Modules/fetch/DOMWindowFetch.idl: Making fetch a JS built-in and adding a @fetchRequest private function.
* Modules/fetch/DOMWindowFetch.js: Added.
(fetch):
* Modules/fetch/FetchHeaders.h:
(WebCore::FetchHeaders::setGuard): Used by FetchRequest when initializing headers.
* Modules/fetch/FetchRequest.cpp:
(WebCore::buildHeaders): Removed as implemented in JS.
(WebCore::FetchRequest::initializeOptions): Added to handle most of the dictionary initialization.
(WebCore::FetchRequest::initializeWith): Method called from built-in constructor function.
(WebCore::FetchRequest::setBody): Corresponding to @setBody private method.
(WebCore::buildBody): Deleted.
* Modules/fetch/FetchRequest.h:
* Modules/fetch/FetchRequest.idl:
* Modules/fetch/FetchRequest.js: Added.
(initializeFetchRequest): Implements fetch Request(input, init) constructor.
* Modules/fetch/FetchResponse.cpp:
(WebCore::FetchResponse::fetch): Removed the construction of FetchRequest in fetch method since it is done by JS built-in code.
* Modules/fetch/FetchResponse.h:
* Modules/fetch/WorkerGlobalScopeFetch.cpp: Removed overloaded fetch and updated according new signature.
(WebCore::WorkerGlobalScopeFetch::fetch):
* Modules/fetch/WorkerGlobalScopeFetch.h: Ditto.
* Modules/fetch/WorkerGlobalScopeFetch.idl: Making fetch a JS built-in and adding a @fetchRequest private function.
* Modules/fetch/WorkerGlobalScopeFetch.js: Added.
(fetch):
* bindings/js/WebCoreBuiltinNames.h: Adding fetchRequest, setBody and Request private identifiers.
* bindings/scripts/CodeGenerator.pm:
(WK_lcfirst): Replacing dOM by dom.
* bindings/scripts/CodeGeneratorJS.pm:
(GenerateImplementation): Adding support for runtime-enabled built-in methods and private methods.
* bindings/scripts/test/JS/JSTestGlobalObject.cpp:
(WebCore::JSTestGlobalObject::finishCreation):
(WebCore::jsTestGlobalObjectInstanceFunctionTestPrivateFunction):
* bindings/scripts/test/ObjC/DOMTestGlobalObject.mm:
(-[DOMTestGlobalObject testJSBuiltinFunction]):
* bindings/scripts/test/TestGlobalObject.idl: Adding tests for runtime-enabled global built-in methods and private methods.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsimportedw3cChangeLog">trunk/LayoutTests/imported/w3c/ChangeLog</a></li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestsfetchapicredentialsauthenticationbasicexpectedtxt">trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/credentials/authentication-basic-expected.txt</a></li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestsfetchapirequestrequestheadersexpectedtxt">trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/request/request-headers-expected.txt</a></li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestsfetchapirequestrequestheadershtml">trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/request/request-headers.html</a></li>
<li><a href="#trunkSourceJavaScriptCoreChangeLog">trunk/Source/JavaScriptCore/ChangeLog</a></li>
<li><a href="#trunkSourceJavaScriptCoreScriptsbuiltinsbuiltins_generatorpy">trunk/Source/JavaScriptCore/Scripts/builtins/builtins_generator.py</a></li>
<li><a href="#trunkSourceWebCoreCMakeListstxt">trunk/Source/WebCore/CMakeLists.txt</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreDerivedSourcesmake">trunk/Source/WebCore/DerivedSources.make</a></li>
<li><a href="#trunkSourceWebCoreModulesfetchDOMWindowFetchcpp">trunk/Source/WebCore/Modules/fetch/DOMWindowFetch.cpp</a></li>
<li><a href="#trunkSourceWebCoreModulesfetchDOMWindowFetchh">trunk/Source/WebCore/Modules/fetch/DOMWindowFetch.h</a></li>
<li><a href="#trunkSourceWebCoreModulesfetchDOMWindowFetchidl">trunk/Source/WebCore/Modules/fetch/DOMWindowFetch.idl</a></li>
<li><a href="#trunkSourceWebCoreModulesfetchFetchHeadersh">trunk/Source/WebCore/Modules/fetch/FetchHeaders.h</a></li>
<li><a href="#trunkSourceWebCoreModulesfetchFetchRequestcpp">trunk/Source/WebCore/Modules/fetch/FetchRequest.cpp</a></li>
<li><a href="#trunkSourceWebCoreModulesfetchFetchRequesth">trunk/Source/WebCore/Modules/fetch/FetchRequest.h</a></li>
<li><a href="#trunkSourceWebCoreModulesfetchFetchRequestidl">trunk/Source/WebCore/Modules/fetch/FetchRequest.idl</a></li>
<li><a href="#trunkSourceWebCoreModulesfetchFetchResponsecpp">trunk/Source/WebCore/Modules/fetch/FetchResponse.cpp</a></li>
<li><a href="#trunkSourceWebCoreModulesfetchFetchResponseh">trunk/Source/WebCore/Modules/fetch/FetchResponse.h</a></li>
<li><a href="#trunkSourceWebCoreModulesfetchWorkerGlobalScopeFetchcpp">trunk/Source/WebCore/Modules/fetch/WorkerGlobalScopeFetch.cpp</a></li>
<li><a href="#trunkSourceWebCoreModulesfetchWorkerGlobalScopeFetchh">trunk/Source/WebCore/Modules/fetch/WorkerGlobalScopeFetch.h</a></li>
<li><a href="#trunkSourceWebCoreModulesfetchWorkerGlobalScopeFetchidl">trunk/Source/WebCore/Modules/fetch/WorkerGlobalScopeFetch.idl</a></li>
<li><a href="#trunkSourceWebCorebindingsjsWebCoreBuiltinNamesh">trunk/Source/WebCore/bindings/js/WebCoreBuiltinNames.h</a></li>
<li><a href="#trunkSourceWebCorebindingsscriptsCodeGeneratorpm">trunk/Source/WebCore/bindings/scripts/CodeGenerator.pm</a></li>
<li><a href="#trunkSourceWebCorebindingsscriptsCodeGeneratorJSpm">trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm</a></li>
<li><a href="#trunkSourceWebCorebindingsscriptstestJSJSTestGlobalObjectcpp">trunk/Source/WebCore/bindings/scripts/test/JS/JSTestGlobalObject.cpp</a></li>
<li><a href="#trunkSourceWebCorebindingsscriptstestObjCDOMTestGlobalObjectmm">trunk/Source/WebCore/bindings/scripts/test/ObjC/DOMTestGlobalObject.mm</a></li>
<li><a href="#trunkSourceWebCorebindingsscriptstestTestGlobalObjectidl">trunk/Source/WebCore/bindings/scripts/test/TestGlobalObject.idl</a></li>
</ul>
<h3>Added Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreModulesfetchDOMWindowFetchjs">trunk/Source/WebCore/Modules/fetch/DOMWindowFetch.js</a></li>
<li><a href="#trunkSourceWebCoreModulesfetchFetchRequestjs">trunk/Source/WebCore/Modules/fetch/FetchRequest.js</a></li>
<li><a href="#trunkSourceWebCoreModulesfetchWorkerGlobalScopeFetchjs">trunk/Source/WebCore/Modules/fetch/WorkerGlobalScopeFetch.js</a></li>
</ul>
<h3>Removed Paths</h3>
<ul>
<li>trunk/LayoutTests/platform/mac-wk1/imported/</li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsimportedw3cChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/imported/w3c/ChangeLog (203674 => 203675)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/ChangeLog        2016-07-25 06:07:40 UTC (rev 203674)
+++ trunk/LayoutTests/imported/w3c/ChangeLog        2016-07-25 06:28:35 UTC (rev 203675)
</span><span class="lines">@@ -1,3 +1,16 @@
</span><ins>+2016-07-24 Youenn Fablet <youenn@apple.com>
+
+ [Fetch API] Request should be created with any HeadersInit data
+ https://bugs.webkit.org/show_bug.cgi?id=159672
+
+ Reviewed by Sam Weinig.
+
+ * imported/w3c/web-platform-tests/fetch/api/credentials/authentication-basic-expected.txt: Test was previously
+ failing due to lack of support for HeadersInit data in Request constructor.
+ * platform/mac-wk1/imported/w3c/web-platform-tests/fetch/api/credentials/authentication-basic-expected.txt: Removed.
+ * web-platform-tests/fetch/api/request/request-headers-expected.txt:
+ * web-platform-tests/fetch/api/request/request-headers.html: Adding new test.
+
</ins><span class="cx"> 2016-07-23 Commit Queue <commit-queue@webkit.org>
</span><span class="cx">
</span><span class="cx"> Unreviewed, rolling out r203641.
</span></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestsfetchapicredentialsauthenticationbasicexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/credentials/authentication-basic-expected.txt (203674 => 203675)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/credentials/authentication-basic-expected.txt        2016-07-25 06:07:40 UTC (rev 203674)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/credentials/authentication-basic-expected.txt        2016-07-25 06:28:35 UTC (rev 203675)
</span><span class="lines">@@ -1,8 +1,5 @@
</span><del>-localhost:8800 - didReceiveAuthenticationChallenge - Simulating cancelled authentication sheet
-localhost:8800 - didReceiveAuthenticationChallenge - Simulating cancelled authentication sheet
-localhost:8800 - didReceiveAuthenticationChallenge - Simulating cancelled authentication sheet
</del><span class="cx">
</span><del>-FAIL User-added Authorization header with include mode assert_equals: HTTP status is 200 expected 200 but got 401
-FAIL User-added Authorization header with same-origin mode assert_equals: HTTP status is 200 expected 200 but got 401
-FAIL User-added Authorization header with omit mode assert_equals: HTTP status is 200 expected 200 but got 401
</del><ins>+PASS User-added Authorization header with include mode
+PASS User-added Authorization header with same-origin mode
+PASS User-added Authorization header with omit mode
</ins><span class="cx">
</span></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestsfetchapirequestrequestheadersexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/request/request-headers-expected.txt (203674 => 203675)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/request/request-headers-expected.txt        2016-07-25 06:07:40 UTC (rev 203674)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/request/request-headers-expected.txt        2016-07-25 06:28:35 UTC (rev 203675)
</span><span class="lines">@@ -53,4 +53,5 @@
</span><span class="cx"> PASS Request should not get its content-type from the init request if init headers are provided
</span><span class="cx"> PASS Request should get its content-type from the body if none is provided
</span><span class="cx"> PASS Request should get its content-type from init headers if one is provided
</span><ins>+PASS Testing request header creations with various objects
</ins><span class="cx">
</span></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestsfetchapirequestrequestheadershtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/request/request-headers.html (203674 => 203675)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/request/request-headers.html        2016-07-25 06:07:40 UTC (rev 203674)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/request/request-headers.html        2016-07-25 06:28:35 UTC (rev 203675)
</span><span class="lines">@@ -145,6 +145,22 @@
</span><span class="cx"> assert_equals(request.headers.get("Content-Type"), "potato");
</span><span class="cx"> }, "Request should get its content-type from init headers if one is provided");
</span><span class="cx">
</span><ins>+ test(function() {
+ var array = [["hello", "worldAHH"]];
+ var object = {"hello": 'worldOOH'};
+ var headers = new Headers(array);
+
+ assert_equals(headers.get("hello"), "worldAHH");
+
+ var request1 = new Request("", {"headers": headers});
+ var request2 = new Request("", {"headers": array});
+ var request3 = new Request("", {"headers": object});
+
+ assert_equals(request1.headers.get("hello"), "worldAHH");
+ assert_equals(request2.headers.get("hello"), "worldAHH");
+ assert_equals(request3.headers.get("hello"), "worldOOH");
+ }, "Testing request header creations with various objects");
+
</ins><span class="cx"> </script>
</span><span class="cx"> </body>
</span><span class="cx"> </html>
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/ChangeLog (203674 => 203675)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/ChangeLog        2016-07-25 06:07:40 UTC (rev 203674)
+++ trunk/Source/JavaScriptCore/ChangeLog        2016-07-25 06:28:35 UTC (rev 203675)
</span><span class="lines">@@ -1,3 +1,13 @@
</span><ins>+2016-07-24 Youenn Fablet <youenn@apple.com>
+
+ [Fetch API] Request should be created with any HeadersInit data
+ https://bugs.webkit.org/show_bug.cgi?id=159672
+
+ Reviewed by Sam Weinig.
+
+ * Scripts/builtins/builtins_generator.py:
+ (WK_lcfirst): Synchronized with CodeGenerator.pm version.
+
</ins><span class="cx"> 2016-07-24 Filip Pizlo <fpizlo@apple.com>
</span><span class="cx">
</span><span class="cx"> B3 should support multiple entrypoints
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreScriptsbuiltinsbuiltins_generatorpy"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/Scripts/builtins/builtins_generator.py (203674 => 203675)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/Scripts/builtins/builtins_generator.py        2016-07-25 06:07:40 UTC (rev 203674)
+++ trunk/Source/JavaScriptCore/Scripts/builtins/builtins_generator.py        2016-07-25 06:28:35 UTC (rev 203675)
</span><span class="lines">@@ -38,7 +38,7 @@
</span><span class="cx"> # These match WK_lcfirst and WK_ucfirst defined in CodeGenerator.pm.
</span><span class="cx"> def WK_lcfirst(str):
</span><span class="cx"> str = str[:1].lower() + str[1:]
</span><del>- str = str.replace('hTML', 'html')
</del><ins>+ str = str.replace('dOM', 'dom')
</ins><span class="cx"> str = str.replace('uRL', 'url')
</span><span class="cx"> str = str.replace('jS', 'js')
</span><span class="cx"> str = str.replace('xML', 'xml')
</span></span></pre></div>
<a id="trunkSourceWebCoreCMakeListstxt"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/CMakeLists.txt (203674 => 203675)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/CMakeLists.txt        2016-07-25 06:07:40 UTC (rev 203674)
+++ trunk/Source/WebCore/CMakeLists.txt        2016-07-25 06:28:35 UTC (rev 203675)
</span><span class="lines">@@ -3710,9 +3710,12 @@
</span><span class="cx"> # WebCore JS Builtins
</span><span class="cx">
</span><span class="cx"> set(WebCore_BUILTINS_SOURCES
</span><ins>+ ${WEBCORE_DIR}/Modules/fetch/DOMWindowFetch.js
</ins><span class="cx"> ${WEBCORE_DIR}/Modules/fetch/FetchHeaders.js
</span><span class="cx"> ${WEBCORE_DIR}/Modules/fetch/FetchInternals.js
</span><ins>+ ${WEBCORE_DIR}/Modules/fetch/FetchRequest.js
</ins><span class="cx"> ${WEBCORE_DIR}/Modules/fetch/FetchResponse.js
</span><ins>+ ${WEBCORE_DIR}/Modules/fetch/WorkerGlobalScopeFetch.js
</ins><span class="cx"> ${WEBCORE_DIR}/Modules/mediastream/MediaDevices.js
</span><span class="cx"> ${WEBCORE_DIR}/Modules/mediastream/NavigatorUserMedia.js
</span><span class="cx"> ${WEBCORE_DIR}/Modules/mediastream/RTCPeerConnection.js
</span></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (203674 => 203675)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2016-07-25 06:07:40 UTC (rev 203674)
+++ trunk/Source/WebCore/ChangeLog        2016-07-25 06:28:35 UTC (rev 203675)
</span><span class="lines">@@ -1,3 +1,67 @@
</span><ins>+2016-07-24 Youenn Fablet <youenn@apple.com>
+
+ [Fetch API] Request should be created with any HeadersInit data
+ https://bugs.webkit.org/show_bug.cgi?id=159672
+
+ Reviewed by Sam Weinig.
+
+ Made Request use JSBuiltinConstructor.
+ This allows initializing newly created Request with a JS built-in function, initializeFetchRequest.
+ initializeFetchRequest can call @fillFetchHeaders internal built-in to handle any HeadersInit data.
+ Future effort should be made to migrate more initialization code in initializeFetchRequest.
+
+ Made window and worker fetch function as a JS built-in.
+ This becomes more handy as these new functions can construct the Request object.
+ They can then call a single private function that takes a Request object as input.
+ Updated DOMWindowFetch and WorkerGlobalScopeFetch code accordingly.
+
+ To enable this, the binding generator is updated to support runtime-enabled JS built-in functions and
+ private functions atttached to global objects.
+
+ Covered by existing and modified tests.
+ Binding generator test covered by updated binding tests.
+
+ * CMakeLists.txt: Adding DOMWindowFetch.js, FetchRequest.js and WorkerGlobalScopeFetch.js built-in files.
+ * DerivedSources.make: Ditto.
+ * Modules/fetch/DOMWindowFetch.cpp: Removed overloaded fetch and updated according new signature.
+ (WebCore::DOMWindowFetch::fetch):
+ * Modules/fetch/DOMWindowFetch.h: Ditto.
+ * Modules/fetch/DOMWindowFetch.idl: Making fetch a JS built-in and adding a @fetchRequest private function.
+ * Modules/fetch/DOMWindowFetch.js: Added.
+ (fetch):
+ * Modules/fetch/FetchHeaders.h:
+ (WebCore::FetchHeaders::setGuard): Used by FetchRequest when initializing headers.
+ * Modules/fetch/FetchRequest.cpp:
+ (WebCore::buildHeaders): Removed as implemented in JS.
+ (WebCore::FetchRequest::initializeOptions): Added to handle most of the dictionary initialization.
+ (WebCore::FetchRequest::initializeWith): Method called from built-in constructor function.
+ (WebCore::FetchRequest::setBody): Corresponding to @setBody private method.
+ (WebCore::buildBody): Deleted.
+ * Modules/fetch/FetchRequest.h:
+ * Modules/fetch/FetchRequest.idl:
+ * Modules/fetch/FetchRequest.js: Added.
+ (initializeFetchRequest): Implements fetch Request(input, init) constructor.
+ * Modules/fetch/FetchResponse.cpp:
+ (WebCore::FetchResponse::fetch): Removed the construction of FetchRequest in fetch method since it is done by JS built-in code.
+ * Modules/fetch/FetchResponse.h:
+ * Modules/fetch/WorkerGlobalScopeFetch.cpp: Removed overloaded fetch and updated according new signature.
+ (WebCore::WorkerGlobalScopeFetch::fetch):
+ * Modules/fetch/WorkerGlobalScopeFetch.h: Ditto.
+ * Modules/fetch/WorkerGlobalScopeFetch.idl: Making fetch a JS built-in and adding a @fetchRequest private function.
+ * Modules/fetch/WorkerGlobalScopeFetch.js: Added.
+ (fetch):
+ * bindings/js/WebCoreBuiltinNames.h: Adding fetchRequest, setBody and Request private identifiers.
+ * bindings/scripts/CodeGenerator.pm:
+ (WK_lcfirst): Replacing dOM by dom.
+ * bindings/scripts/CodeGeneratorJS.pm:
+ (GenerateImplementation): Adding support for runtime-enabled built-in methods and private methods.
+ * bindings/scripts/test/JS/JSTestGlobalObject.cpp:
+ (WebCore::JSTestGlobalObject::finishCreation):
+ (WebCore::jsTestGlobalObjectInstanceFunctionTestPrivateFunction):
+ * bindings/scripts/test/ObjC/DOMTestGlobalObject.mm:
+ (-[DOMTestGlobalObject testJSBuiltinFunction]):
+ * bindings/scripts/test/TestGlobalObject.idl: Adding tests for runtime-enabled global built-in methods and private methods.
+
</ins><span class="cx"> 2016-07-24 Nan Wang <n_wang@apple.com>
</span><span class="cx">
</span><span class="cx"> AX: Video Controls: Volume cannot be adjusted using VO.
</span></span></pre></div>
<a id="trunkSourceWebCoreDerivedSourcesmake"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/DerivedSources.make (203674 => 203675)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/DerivedSources.make        2016-07-25 06:07:40 UTC (rev 203674)
+++ trunk/Source/WebCore/DerivedSources.make        2016-07-25 06:28:35 UTC (rev 203675)
</span><span class="lines">@@ -1283,9 +1283,12 @@
</span><span class="cx"> # WebCore JS Builtins
</span><span class="cx">
</span><span class="cx"> WebCore_BUILTINS_SOURCES = \
</span><ins>+ ${WebCore}/Modules/fetch/DOMWindowFetch.js \
</ins><span class="cx"> $(WebCore)/Modules/fetch/FetchHeaders.js \
</span><span class="cx"> $(WebCore)/Modules/fetch/FetchInternals.js \
</span><ins>+ $(WebCore)/Modules/fetch/FetchRequest.js \
</ins><span class="cx"> $(WebCore)/Modules/fetch/FetchResponse.js \
</span><ins>+ ${WebCore}/Modules/fetch/WorkerGlobalScopeFetch.js \
</ins><span class="cx"> $(WebCore)/Modules/mediastream/MediaDevices.js \
</span><span class="cx"> $(WebCore)/Modules/mediastream/NavigatorUserMedia.js \
</span><span class="cx"> $(WebCore)/Modules/mediastream/RTCPeerConnection.js \
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesfetchDOMWindowFetchcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/fetch/DOMWindowFetch.cpp (203674 => 203675)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/fetch/DOMWindowFetch.cpp        2016-07-25 06:07:40 UTC (rev 203674)
+++ trunk/Source/WebCore/Modules/fetch/DOMWindowFetch.cpp        2016-07-25 06:28:35 UTC (rev 203675)
</span><span class="lines">@@ -37,20 +37,13 @@
</span><span class="cx">
</span><span class="cx"> namespace WebCore {
</span><span class="cx">
</span><del>-void DOMWindowFetch::fetch(DOMWindow& window, FetchRequest& input, const Dictionary& dictionary, DeferredWrapper&& promise)
</del><ins>+void DOMWindowFetch::fetch(DOMWindow& window, FetchRequest& request, DeferredWrapper&& promise)
</ins><span class="cx"> {
</span><span class="cx"> if (!window.scriptExecutionContext())
</span><span class="cx"> return;
</span><del>- FetchResponse::fetch(*window.scriptExecutionContext(), input, dictionary, WTFMove(promise));
</del><ins>+ FetchResponse::fetch(*window.scriptExecutionContext(), request, WTFMove(promise));
</ins><span class="cx"> }
</span><span class="cx">
</span><del>-void DOMWindowFetch::fetch(DOMWindow& window, const String& url, const Dictionary& dictionary, DeferredWrapper&& promise)
-{
- if (!window.scriptExecutionContext())
- return;
- FetchResponse::fetch(*window.scriptExecutionContext(), url, dictionary, WTFMove(promise));
-}
-
</del><span class="cx"> } // namespace WebCore
</span><span class="cx">
</span><span class="cx"> #endif // ENABLE(FETCH_API)
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesfetchDOMWindowFetchh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/fetch/DOMWindowFetch.h (203674 => 203675)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/fetch/DOMWindowFetch.h        2016-07-25 06:07:40 UTC (rev 203674)
+++ trunk/Source/WebCore/Modules/fetch/DOMWindowFetch.h        2016-07-25 06:28:35 UTC (rev 203675)
</span><span class="lines">@@ -25,9 +25,9 @@
</span><span class="cx"> * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
</span><span class="cx"> * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
</span><span class="cx"> */
</span><del>-#ifndef DOMWindowFetch_h
-#define DOMWindowFetch_h
</del><span class="cx">
</span><ins>+#pragma once
+
</ins><span class="cx"> #if ENABLE(FETCH_API)
</span><span class="cx">
</span><span class="cx"> #include <wtf/Forward.h>
</span><span class="lines">@@ -41,12 +41,9 @@
</span><span class="cx">
</span><span class="cx"> class DOMWindowFetch {
</span><span class="cx"> public:
</span><del>- static void fetch(DOMWindow&, FetchRequest&, const Dictionary&, DeferredWrapper&&);
- static void fetch(DOMWindow&, const String&, const Dictionary&, DeferredWrapper&&);
</del><ins>+ static void fetch(DOMWindow&, FetchRequest&, DeferredWrapper&&);
</ins><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> } // namespace WebCore
</span><span class="cx">
</span><span class="cx"> #endif // ENABLE(FETCH_API)
</span><del>-
-#endif // DOMWindowFetch_h
</del></span></pre></div>
<a id="trunkSourceWebCoreModulesfetchDOMWindowFetchidl"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/fetch/DOMWindowFetch.idl (203674 => 203675)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/fetch/DOMWindowFetch.idl        2016-07-25 06:07:40 UTC (rev 203674)
+++ trunk/Source/WebCore/Modules/fetch/DOMWindowFetch.idl        2016-07-25 06:28:35 UTC (rev 203675)
</span><span class="lines">@@ -30,6 +30,7 @@
</span><span class="cx"> Conditional=FETCH_API,
</span><span class="cx"> EnabledAtRuntime=FetchAPI,
</span><span class="cx"> ] partial interface DOMWindow {
</span><del>- Promise fetch(FetchRequest input, optional Dictionary init);
- Promise fetch(DOMString input, optional Dictionary init);
</del><ins>+ [JSBuiltin] Promise fetch(any input, optional Dictionary init);
+
+ [PrivateIdentifier, ImplementedAs=fetch] Promise fetchRequest(FetchRequest request);
</ins><span class="cx"> };
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesfetchDOMWindowFetchjsfromrev203674trunkSourceWebCorebindingsscriptstestTestGlobalObjectidl"></a>
<div class="copfile"><h4>Copied: trunk/Source/WebCore/Modules/fetch/DOMWindowFetch.js (from rev 203674, trunk/Source/WebCore/bindings/scripts/test/TestGlobalObject.idl) (0 => 203675)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/fetch/DOMWindowFetch.js         (rev 0)
+++ trunk/Source/WebCore/Modules/fetch/DOMWindowFetch.js        2016-07-25 06:28:35 UTC (rev 203675)
</span><span class="lines">@@ -0,0 +1,37 @@
</span><ins>+/*
+ * 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);
+ }
+}
</ins></span></pre></div>
<a id="trunkSourceWebCoreModulesfetchFetchHeadersh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/fetch/FetchHeaders.h (203674 => 203675)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/fetch/FetchHeaders.h        2016-07-25 06:07:40 UTC (rev 203674)
+++ trunk/Source/WebCore/Modules/fetch/FetchHeaders.h        2016-07-25 06:28:35 UTC (rev 203675)
</span><span class="lines">@@ -26,8 +26,7 @@
</span><span class="cx"> * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
</span><span class="cx"> */
</span><span class="cx">
</span><del>-#ifndef FetchHeaders_h
-#define FetchHeaders_h
</del><ins>+#pragma once
</ins><span class="cx">
</span><span class="cx"> #if ENABLE(FETCH_API)
</span><span class="cx">
</span><span class="lines">@@ -79,6 +78,8 @@
</span><span class="cx">
</span><span class="cx"> const HTTPHeaderMap& internalHeaders() const { return m_headers; }
</span><span class="cx">
</span><ins>+ void setGuard(Guard);
+
</ins><span class="cx"> private:
</span><span class="cx"> FetchHeaders(Guard guard) : m_guard(guard) { }
</span><span class="cx"> FetchHeaders(Guard guard, const HTTPHeaderMap& headers) : m_guard(guard), m_headers(headers) { }
</span><span class="lines">@@ -87,8 +88,12 @@
</span><span class="cx"> HTTPHeaderMap m_headers;
</span><span class="cx"> };
</span><span class="cx">
</span><ins>+inline void FetchHeaders::setGuard(Guard guard)
+{
+ ASSERT(!m_headers.size());
+ m_guard = guard;
+}
+
</ins><span class="cx"> } // namespace WebCore
</span><span class="cx">
</span><span class="cx"> #endif // ENABLE(FETCH_API)
</span><del>-
-#endif // FetchHeaders_h
</del></span></pre></div>
<a id="trunkSourceWebCoreModulesfetchFetchRequestcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/fetch/FetchRequest.cpp (203674 => 203675)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/fetch/FetchRequest.cpp        2016-07-25 06:07:40 UTC (rev 203674)
+++ trunk/Source/WebCore/Modules/fetch/FetchRequest.cpp        2016-07-25 06:28:35 UTC (rev 203675)
</span><span class="lines">@@ -193,40 +193,6 @@
</span><span class="cx"> return true;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-static RefPtr<FetchHeaders> buildHeaders(const Dictionary& init, const FetchRequest::InternalRequest& request, const FetchHeaders* inputHeaders = nullptr)
-{
- FetchHeaders::Guard guard = FetchHeaders::Guard::Request;
- if (request.options.mode == FetchOptions::Mode::NoCors) {
- const String& method = request.request.httpMethod();
- if (method != "GET" && method != "POST" && method != "HEAD")
- return nullptr;
- if (!request.integrity.isEmpty())
- return nullptr;
- guard = FetchHeaders::Guard::RequestNoCors;
- }
-
- RefPtr<FetchHeaders> initialHeaders;
- RefPtr<FetchHeaders> headers = FetchHeaders::create(guard);
- headers->fill(init.get("headers", initialHeaders) ? initialHeaders.get() : inputHeaders);
-
- return headers;
-}
-
-static FetchBody buildBody(const Dictionary& init, FetchHeaders& headers, FetchBody* inputBody = nullptr)
-{
- JSC::JSValue value;
- bool hasInitBody = init.get("body", value);
- FetchBody body = hasInitBody ? FetchBody::extract(*init.execState(), value) : FetchBody::extractFromBody(inputBody);
-
- String type = headers.fastGet(HTTPHeaderName::ContentType);
- if (hasInitBody && type.isEmpty() && !body.mimeType().isEmpty()) {
- type = body.mimeType();
- headers.fastSet(HTTPHeaderName::ContentType, type);
- }
- body.setMimeType(type);
- return body;
-}
-
</del><span class="cx"> static bool validateBodyAndMethod(const FetchBody& body, const FetchRequest::InternalRequest& internalRequest)
</span><span class="cx"> {
</span><span class="cx"> if (body.isEmpty())
</span><span class="lines">@@ -234,42 +200,48 @@
</span><span class="cx"> return internalRequest.request.httpMethod() != "GET" && internalRequest.request.httpMethod() != "HEAD";
</span><span class="cx"> }
</span><span class="cx">
</span><del>-RefPtr<FetchRequest> FetchRequest::create(ScriptExecutionContext& context, const String& url, const Dictionary& init, ExceptionCode& ec)
</del><ins>+void FetchRequest::initializeOptions(const Dictionary& init, ExceptionCode& ec)
</ins><span class="cx"> {
</span><del>- // FIXME: Tighten the URL parsing algorithm according https://url.spec.whatwg.org/#concept-url-parser.
- URL requestURL = context.completeURL(url);
- if (!requestURL.isValid() || !requestURL.user().isEmpty() || !requestURL.pass().isEmpty()) {
</del><ins>+ ASSERT(scriptExecutionContext());
+ if (!buildOptions(m_internalRequest, *scriptExecutionContext(), init)) {
</ins><span class="cx"> ec = TypeError;
</span><del>- return nullptr;
</del><ins>+ return;
</ins><span class="cx"> }
</span><span class="cx">
</span><del>- FetchRequest::InternalRequest internalRequest;
- internalRequest.options.mode = Mode::Cors;
- internalRequest.options.credentials = Credentials::Omit;
- internalRequest.referrer = ASCIILiteral("client");
- internalRequest.request.setURL(requestURL);
-
- if (!buildOptions(internalRequest, context, init)) {
- ec = TypeError;
- return nullptr;
</del><ins>+ if (m_internalRequest.options.mode == FetchOptions::Mode::NoCors) {
+ const String& method = m_internalRequest.request.httpMethod();
+ if (method != "GET" && method != "POST" && method != "HEAD") {
+ ec = TypeError;
+ return;
+ }
+ if (!m_internalRequest.integrity.isEmpty()) {
+ ec = TypeError;
+ return;
+ }
+ m_headers->setGuard(FetchHeaders::Guard::RequestNoCors);
</ins><span class="cx"> }
</span><ins>+}
</ins><span class="cx">
</span><del>- RefPtr<FetchHeaders> headers = buildHeaders(init, internalRequest);
- if (!headers) {
</del><ins>+FetchHeaders* FetchRequest::initializeWith(const String& url, const Dictionary& init, ExceptionCode& ec)
+{
+ ASSERT(scriptExecutionContext());
+ // FIXME: Tighten the URL parsing algorithm according https://url.spec.whatwg.org/#concept-url-parser.
+ URL requestURL = scriptExecutionContext()->completeURL(url);
+ if (!requestURL.isValid() || !requestURL.user().isEmpty() || !requestURL.pass().isEmpty()) {
</ins><span class="cx"> ec = TypeError;
</span><span class="cx"> return nullptr;
</span><span class="cx"> }
</span><span class="cx">
</span><del>- FetchBody body = buildBody(init, *headers);
- if (!validateBodyAndMethod(body, internalRequest)) {
- ec = TypeError;
- return nullptr;
- }
</del><ins>+ m_internalRequest.options.mode = Mode::Cors;
+ m_internalRequest.options.credentials = Credentials::Omit;
+ m_internalRequest.referrer = ASCIILiteral("client");
+ m_internalRequest.request.setURL(requestURL);
</ins><span class="cx">
</span><del>- return adoptRef(*new FetchRequest(context, WTFMove(body), headers.releaseNonNull(), WTFMove(internalRequest)));
</del><ins>+ initializeOptions(init, ec);
+ return m_headers.ptr();
</ins><span class="cx"> }
</span><span class="cx">
</span><del>-RefPtr<FetchRequest> FetchRequest::create(ScriptExecutionContext& context, FetchRequest& input, const Dictionary& init, ExceptionCode& ec)
</del><ins>+FetchHeaders* FetchRequest::initializeWith(FetchRequest& input, const Dictionary& init, ExceptionCode& ec)
</ins><span class="cx"> {
</span><span class="cx"> if (input.isDisturbed()) {
</span><span class="cx"> ec = TypeError;
</span><span class="lines">@@ -276,29 +248,29 @@
</span><span class="cx"> return nullptr;
</span><span class="cx"> }
</span><span class="cx">
</span><del>- FetchRequest::InternalRequest internalRequest(input.m_internalRequest);
</del><ins>+ m_internalRequest = input.m_internalRequest;
</ins><span class="cx">
</span><del>- if (!buildOptions(internalRequest, context, init)) {
- ec = TypeError;
- return nullptr;
</del><ins>+ initializeOptions(init, ec);
+ return m_headers.ptr();
+}
+
+void FetchRequest::setBody(JSC::ExecState& execState, JSC::JSValue body, FetchRequest* request, ExceptionCode& ec)
+{
+ if (!body.isNull())
+ m_body = FetchBody::extract(execState, body);
+ else if (request && !request->m_body.isEmpty()) {
+ m_body = FetchBody::extractFromBody(&request->m_body);
+ request->setDisturbed();
</ins><span class="cx"> }
</span><span class="cx">
</span><del>- RefPtr<FetchHeaders> headers = buildHeaders(init, internalRequest, input.m_headers.ptr());
- if (!headers) {
- ec = TypeError;
- return nullptr;
</del><ins>+ String type = m_headers->fastGet(HTTPHeaderName::ContentType);
+ if (!body.isUndefined() && type.isEmpty() && !m_body.mimeType().isEmpty()) {
+ type = m_body.mimeType();
+ m_headers->fastSet(HTTPHeaderName::ContentType, type);
</ins><span class="cx"> }
</span><del>-
- FetchBody body = buildBody(init, *headers, &input.m_body);
- if (!validateBodyAndMethod(body, internalRequest)) {
</del><ins>+ m_body.setMimeType(type);
+ if (!validateBodyAndMethod(m_body, m_internalRequest))
</ins><span class="cx"> ec = TypeError;
</span><del>- return nullptr;
- }
-
- if (!input.m_body.isEmpty())
- input.setDisturbed();
-
- return adoptRef(*new FetchRequest(context, WTFMove(body), headers.releaseNonNull(), WTFMove(internalRequest)));
</del><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> String FetchRequest::referrer() const
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesfetchFetchRequesth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/fetch/FetchRequest.h (203674 => 203675)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/fetch/FetchRequest.h        2016-07-25 06:07:40 UTC (rev 203674)
+++ trunk/Source/WebCore/Modules/fetch/FetchRequest.h        2016-07-25 06:28:35 UTC (rev 203675)
</span><span class="lines">@@ -45,9 +45,12 @@
</span><span class="cx">
</span><span class="cx"> class FetchRequest final : public FetchBodyOwner {
</span><span class="cx"> public:
</span><del>- static RefPtr<FetchRequest> create(ScriptExecutionContext&, FetchRequest&, const Dictionary&, ExceptionCode&);
- static RefPtr<FetchRequest> create(ScriptExecutionContext&, const String&, const Dictionary&, ExceptionCode&);
</del><ins>+ static Ref<FetchRequest> create(ScriptExecutionContext& context) { return adoptRef(*new FetchRequest(context, { }, FetchHeaders::create(FetchHeaders::Guard::Request), { })); }
</ins><span class="cx">
</span><ins>+ FetchHeaders* initializeWith(FetchRequest&, const Dictionary&, ExceptionCode&);
+ FetchHeaders* initializeWith(const String&, const Dictionary&, ExceptionCode&);
+ void setBody(JSC::ExecState&, JSC::JSValue, FetchRequest*, ExceptionCode&);
+
</ins><span class="cx"> const String& method() const { return m_internalRequest.request.httpMethod(); }
</span><span class="cx"> const String& url() const;
</span><span class="cx"> FetchHeaders& headers() { return m_headers.get(); }
</span><span class="lines">@@ -92,6 +95,8 @@
</span><span class="cx"> private:
</span><span class="cx"> FetchRequest(ScriptExecutionContext&, FetchBody&&, Ref<FetchHeaders>&&, InternalRequest&&);
</span><span class="cx">
</span><ins>+ void initializeOptions(const Dictionary&, ExceptionCode&);
+
</ins><span class="cx"> // ActiveDOMObject API.
</span><span class="cx"> const char* activeDOMObjectName() const final;
</span><span class="cx"> bool canSuspendForDocumentSuspension() const final;
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesfetchFetchRequestidl"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/fetch/FetchRequest.idl (203674 => 203675)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/fetch/FetchRequest.idl        2016-07-25 06:07:40 UTC (rev 203674)
+++ trunk/Source/WebCore/Modules/fetch/FetchRequest.idl        2016-07-25 06:28:35 UTC (rev 203675)
</span><span class="lines">@@ -37,13 +37,13 @@
</span><span class="cx"> [
</span><span class="cx"> ActiveDOMObject,
</span><span class="cx"> Conditional=FETCH_API,
</span><ins>+ Constructor(any input, optional Dictionary init),
</ins><span class="cx"> EnabledAtRuntime=FetchAPI,
</span><del>- ConstructorCallWith=ScriptExecutionContext,
- ConstructorRaisesException,
- Constructor(FetchRequest input, optional Dictionary init),
- Constructor(DOMString input, optional Dictionary init),
</del><span class="cx"> Exposed=(Window,Worker),
</span><del>- InterfaceName=Request
</del><ins>+ InterfaceName=Request,
+ JSBuiltinConstructor,
+ PrivateIdentifier,
+ PublicIdentifier,
</ins><span class="cx"> ]
</span><span class="cx"> interface FetchRequest {
</span><span class="cx"> readonly attribute DOMString method;
</span><span class="lines">@@ -61,5 +61,9 @@
</span><span class="cx"> readonly attribute DOMString integrity;
</span><span class="cx">
</span><span class="cx"> [NewObject, CallWith=ScriptExecutionContext, RaisesException] FetchRequest clone();
</span><ins>+
+ [PrivateIdentifier, RaisesException] FetchHeaders initializeWith(FetchRequest input, Dictionary init);
+ [PrivateIdentifier, RaisesException] FetchHeaders initializeWith(DOMString input, Dictionary init);
+ [PrivateIdentifier, RaisesException, CallWith=ScriptState] void setBody(any body, FetchRequest? request);
</ins><span class="cx"> };
</span><span class="cx"> FetchRequest implements FetchBody;
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesfetchFetchRequestjsfromrev203674trunkSourceWebCorebindingsscriptstestTestGlobalObjectidl"></a>
<div class="copfile"><h4>Copied: trunk/Source/WebCore/Modules/fetch/FetchRequest.js (from rev 203674, trunk/Source/WebCore/bindings/scripts/test/TestGlobalObject.idl) (0 => 203675)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/fetch/FetchRequest.js         (rev 0)
+++ trunk/Source/WebCore/Modules/fetch/FetchRequest.js        2016-07-25 06:28:35 UTC (rev 203675)
</span><span class="lines">@@ -0,0 +1,50 @@
</span><ins>+/*
+ * 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))
+ throw new @TypeError("Request init must be an object");
+
+ let headers = this.@initializeWith(input, init);
+ @assert(headers instanceof @Headers);
+
+ let inputIsRequest = input instanceof @Request;
+ if ("headers" in init)
+ @fillFetchHeaders(headers, init.headers)
+ else if (inputIsRequest)
+ @fillFetchHeaders(headers, input.headers)
+
+ let hasInitBody = init.body !== @undefined && init.body !== null;
+ this.@setBody(hasInitBody ? init.body : null, inputIsRequest ? input : null);
+
+ return this;
+}
</ins></span></pre></div>
<a id="trunkSourceWebCoreModulesfetchFetchResponsecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/fetch/FetchResponse.cpp (203674 => 203675)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/fetch/FetchResponse.cpp        2016-07-25 06:07:40 UTC (rev 203674)
+++ trunk/Source/WebCore/Modules/fetch/FetchResponse.cpp        2016-07-25 06:28:35 UTC (rev 203675)
</span><span class="lines">@@ -102,7 +102,7 @@
</span><span class="cx"> return adoptRef(*new FetchResponse(context, FetchBody(m_body), FetchHeaders::create(headers()), ResourceResponse(m_response)));
</span><span class="cx"> }
</span><span class="cx">
</span><del>-void FetchResponse::startFetching(ScriptExecutionContext& context, const FetchRequest& request, FetchPromise&& promise)
</del><ins>+void FetchResponse::fetch(ScriptExecutionContext& context, FetchRequest& request, FetchPromise&& promise)
</ins><span class="cx"> {
</span><span class="cx"> auto response = adoptRef(*new FetchResponse(context, FetchBody::loadingBody(), FetchHeaders::create(FetchHeaders::Guard::Immutable), { }));
</span><span class="cx">
</span><span class="lines">@@ -114,18 +114,6 @@
</span><span class="cx"> response->m_bodyLoader = Nullopt;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-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));
-}
-
</del><span class="cx"> const String& FetchResponse::url() const
</span><span class="cx"> {
</span><span class="cx"> if (m_responseURL.isNull())
</span><span class="lines">@@ -133,18 +121,6 @@
</span><span class="cx"> return m_responseURL;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-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));
-}
-
</del><span class="cx"> void FetchResponse::BodyLoader::didSucceed()
</span><span class="cx"> {
</span><span class="cx"> ASSERT(m_response.hasPendingActivity());
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesfetchFetchResponseh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/fetch/FetchResponse.h (203674 => 203675)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/fetch/FetchResponse.h        2016-07-25 06:07:40 UTC (rev 203674)
+++ trunk/Source/WebCore/Modules/fetch/FetchResponse.h        2016-07-25 06:28:35 UTC (rev 203675)
</span><span class="lines">@@ -57,10 +57,8 @@
</span><span class="cx"> static RefPtr<FetchResponse> redirect(ScriptExecutionContext&, const String&, int, ExceptionCode&);
</span><span class="cx">
</span><span class="cx"> using FetchPromise = DOMPromise<FetchResponse>;
</span><del>- static void fetch(ScriptExecutionContext&, FetchRequest&, const Dictionary&, FetchPromise&&);
- static void fetch(ScriptExecutionContext&, const String&, const Dictionary&, FetchPromise&&);
</del><ins>+ static void fetch(ScriptExecutionContext&, FetchRequest&, FetchPromise&&);
</ins><span class="cx">
</span><del>-
</del><span class="cx"> void setStatus(int, const String&, ExceptionCode&);
</span><span class="cx"> void initializeWith(JSC::ExecState&, JSC::JSValue);
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesfetchWorkerGlobalScopeFetchcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/fetch/WorkerGlobalScopeFetch.cpp (203674 => 203675)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/fetch/WorkerGlobalScopeFetch.cpp        2016-07-25 06:07:40 UTC (rev 203674)
+++ trunk/Source/WebCore/Modules/fetch/WorkerGlobalScopeFetch.cpp        2016-07-25 06:28:35 UTC (rev 203675)
</span><span class="lines">@@ -36,20 +36,13 @@
</span><span class="cx">
</span><span class="cx"> namespace WebCore {
</span><span class="cx">
</span><del>-void WorkerGlobalScopeFetch::fetch(WorkerGlobalScope& scope, FetchRequest& input, const Dictionary& dictionary, DeferredWrapper&& promise)
</del><ins>+void WorkerGlobalScopeFetch::fetch(WorkerGlobalScope& scope, FetchRequest& request, DeferredWrapper&& promise)
</ins><span class="cx"> {
</span><span class="cx"> if (!scope.scriptExecutionContext())
</span><span class="cx"> return;
</span><del>- FetchResponse::fetch(*scope.scriptExecutionContext(), input, dictionary, WTFMove(promise));
</del><ins>+ FetchResponse::fetch(*scope.scriptExecutionContext(), request, WTFMove(promise));
</ins><span class="cx"> }
</span><span class="cx">
</span><del>-void WorkerGlobalScopeFetch::fetch(WorkerGlobalScope& scope, const String& url, const Dictionary& dictionary, DeferredWrapper&& promise)
-{
- if (!scope.scriptExecutionContext())
- return;
- FetchResponse::fetch(*scope.scriptExecutionContext(), url, dictionary, WTFMove(promise));
-}
-
</del><span class="cx"> } // namespace WebCore
</span><span class="cx">
</span><span class="cx"> #endif // ENABLE(FETCH_API)
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesfetchWorkerGlobalScopeFetchh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/fetch/WorkerGlobalScopeFetch.h (203674 => 203675)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/fetch/WorkerGlobalScopeFetch.h        2016-07-25 06:07:40 UTC (rev 203674)
+++ trunk/Source/WebCore/Modules/fetch/WorkerGlobalScopeFetch.h        2016-07-25 06:28:35 UTC (rev 203675)
</span><span class="lines">@@ -25,9 +25,9 @@
</span><span class="cx"> * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
</span><span class="cx"> * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
</span><span class="cx"> */
</span><del>-#ifndef WorkerGlobalScopeFetch_h
-#define WorkerGlobalScopeFetch_h
</del><span class="cx">
</span><ins>+#pragma once
+
</ins><span class="cx"> #if ENABLE(FETCH_API)
</span><span class="cx">
</span><span class="cx"> #include "JSDOMPromise.h"
</span><span class="lines">@@ -37,17 +37,13 @@
</span><span class="cx">
</span><span class="cx"> class WorkerGlobalScope;
</span><span class="cx"> class DeferredWrapper;
</span><del>-class Dictionary;
</del><span class="cx"> class FetchRequest;
</span><span class="cx">
</span><span class="cx"> class WorkerGlobalScopeFetch {
</span><span class="cx"> public:
</span><del>- static void fetch(WorkerGlobalScope&, FetchRequest&, const Dictionary&, DeferredWrapper&&);
- static void fetch(WorkerGlobalScope&, const String&, const Dictionary&, DeferredWrapper&&);
</del><ins>+ static void fetch(WorkerGlobalScope&, FetchRequest&, DeferredWrapper&&);
</ins><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> } // namespace WebCore
</span><span class="cx">
</span><span class="cx"> #endif // ENABLE(FETCH_API)
</span><del>-
-#endif // WorkerGlobalScopeFetch_h
</del></span></pre></div>
<a id="trunkSourceWebCoreModulesfetchWorkerGlobalScopeFetchidl"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/fetch/WorkerGlobalScopeFetch.idl (203674 => 203675)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/fetch/WorkerGlobalScopeFetch.idl        2016-07-25 06:07:40 UTC (rev 203674)
+++ trunk/Source/WebCore/Modules/fetch/WorkerGlobalScopeFetch.idl        2016-07-25 06:28:35 UTC (rev 203675)
</span><span class="lines">@@ -30,6 +30,7 @@
</span><span class="cx"> Conditional=FETCH_API,
</span><span class="cx"> EnabledAtRuntime=FetchAPI,
</span><span class="cx"> ] partial interface WorkerGlobalScope {
</span><del>- Promise fetch(DOMString input, optional Dictionary init);
- Promise fetch(FetchRequest input, optional Dictionary init);
</del><ins>+ [JSBuiltin] Promise fetch(any input, optional Dictionary init);
+
+ [PrivateIdentifier, ImplementedAs=fetch] Promise fetchRequest(FetchRequest request);
</ins><span class="cx"> };
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesfetchWorkerGlobalScopeFetchjsfromrev203674trunkSourceWebCorebindingsscriptstestTestGlobalObjectidl"></a>
<div class="copfile"><h4>Copied: trunk/Source/WebCore/Modules/fetch/WorkerGlobalScopeFetch.js (from rev 203674, trunk/Source/WebCore/bindings/scripts/test/TestGlobalObject.idl) (0 => 203675)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/fetch/WorkerGlobalScopeFetch.js         (rev 0)
+++ trunk/Source/WebCore/Modules/fetch/WorkerGlobalScopeFetch.js        2016-07-25 06:28:35 UTC (rev 203675)
</span><span class="lines">@@ -0,0 +1,37 @@
</span><ins>+/*
+ * 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);
+ }
+}
</ins></span></pre></div>
<a id="trunkSourceWebCorebindingsjsWebCoreBuiltinNamesh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/js/WebCoreBuiltinNames.h (203674 => 203675)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/js/WebCoreBuiltinNames.h        2016-07-25 06:07:40 UTC (rev 203674)
+++ trunk/Source/WebCore/bindings/js/WebCoreBuiltinNames.h        2016-07-25 06:28:35 UTC (rev 203675)
</span><span class="lines">@@ -41,6 +41,7 @@
</span><span class="cx"> macro(controller) \
</span><span class="cx"> macro(createReadableStreamSource) \
</span><span class="cx"> macro(disturbed) \
</span><ins>+ macro(fetchRequest) \
</ins><span class="cx"> macro(fillFromJS) \
</span><span class="cx"> macro(firstReadCallback) \
</span><span class="cx"> macro(getUserMediaFromJS) \
</span><span class="lines">@@ -68,6 +69,7 @@
</span><span class="cx"> macro(responseCacheIsValid) \
</span><span class="cx"> macro(retrieveResponse) \
</span><span class="cx"> macro(response) \
</span><ins>+ macro(setBody) \
</ins><span class="cx"> macro(setStatus) \
</span><span class="cx"> macro(state) \
</span><span class="cx"> macro(started) \
</span><span class="lines">@@ -89,6 +91,7 @@
</span><span class="cx"> macro(ReadableStream) \
</span><span class="cx"> macro(ReadableStreamReader) \
</span><span class="cx"> macro(ReadableStreamController) \
</span><ins>+ macro(Request) \
</ins><span class="cx"> macro(Response) \
</span><span class="cx"> macro(RTCIceCandidate) \
</span><span class="cx"> macro(RTCSessionDescription) \
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsscriptsCodeGeneratorpm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/scripts/CodeGenerator.pm (203674 => 203675)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/scripts/CodeGenerator.pm        2016-07-25 06:07:40 UTC (rev 203674)
+++ trunk/Source/WebCore/bindings/scripts/CodeGenerator.pm        2016-07-25 06:28:35 UTC (rev 203675)
</span><span class="lines">@@ -559,6 +559,7 @@
</span><span class="cx"> {
</span><span class="cx"> my ($object, $param) = @_;
</span><span class="cx"> my $ret = lcfirst($param);
</span><ins>+ $ret =~ s/dOM/dom/ if $ret =~ /^dOM/;
</ins><span class="cx"> $ret =~ s/hTML/html/ if $ret =~ /^hTML/;
</span><span class="cx"> $ret =~ s/uRL/url/ if $ret =~ /^uRL/;
</span><span class="cx"> $ret =~ s/jS/js/ if $ret =~ /^jS/;
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsscriptsCodeGeneratorJSpm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm (203674 => 203675)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm        2016-07-25 06:07:40 UTC (rev 203674)
+++ trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm        2016-07-25 06:28:35 UTC (rev 203675)
</span><span class="lines">@@ -2419,12 +2419,21 @@
</span><span class="cx"> my $functionLength = GetFunctionLength($function);
</span><span class="cx"> my $jsAttributes = ComputeFunctionSpecial($interface, $function);
</span><span class="cx"> push(@implContent, " if (${enable_function}())\n");
</span><del>- push(@implContent, " putDirectNativeFunction(vm, this, vm.propertyNames->$functionName, $functionLength, $implementationFunction, NoIntrinsic, attributesForStructure($jsAttributes));\n");
</del><ins>+
+ my $propertyName = "vm.propertyNames->$functionName";
+ if ($function->signature->extendedAttributes->{"PrivateIdentifier"}) {
+ $propertyName = "static_cast<JSVMClientData*>(vm.clientData)->builtinNames()." . $functionName . "PrivateName()";
+ }
+ if (IsJSBuiltin($interface, $function)) {
+ push(@implContent, " putDirectBuiltinFunction(vm, this, $propertyName, $implementationFunction(vm), attributesForStructure($jsAttributes));\n");
+ } else {
+ push(@implContent, " putDirectNativeFunction(vm, this, $propertyName, $functionLength, $implementationFunction, NoIntrinsic, attributesForStructure($jsAttributes));\n");
+ }
</ins><span class="cx"> push(@implContent, "#endif\n") if $conditionalString;
</span><span class="cx"> }
</span><span class="cx"> push(@implContent, "}\n\n");
</span><span class="cx"> }
</span><del>-
</del><ins>+
</ins><span class="cx"> unless (ShouldUseGlobalObjectPrototype($interface)) {
</span><span class="cx"> push(@implContent, "JSObject* ${className}::createPrototype(VM& vm, JSGlobalObject* globalObject)\n");
</span><span class="cx"> push(@implContent, "{\n");
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsscriptstestJSJSTestGlobalObjectcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/scripts/test/JS/JSTestGlobalObject.cpp (203674 => 203675)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/scripts/test/JS/JSTestGlobalObject.cpp        2016-07-25 06:07:40 UTC (rev 203674)
+++ trunk/Source/WebCore/bindings/scripts/test/JS/JSTestGlobalObject.cpp        2016-07-25 06:28:35 UTC (rev 203675)
</span><span class="lines">@@ -33,6 +33,10 @@
</span><span class="cx"> #include <runtime/JSString.h>
</span><span class="cx"> #include <wtf/GetPtr.h>
</span><span class="cx">
</span><ins>+#if ENABLE(TEST_FEATURE)
+#include "TestGlobalObjectBuiltins.h"
+#endif
+
</ins><span class="cx"> using namespace JSC;
</span><span class="cx">
</span><span class="cx"> namespace WebCore {
</span><span class="lines">@@ -43,6 +47,9 @@
</span><span class="cx"> #if ENABLE(TEST_FEATURE)
</span><span class="cx"> JSC::EncodedJSValue JSC_HOST_CALL jsTestGlobalObjectInstanceFunctionEnabledAtRuntimeOperation(JSC::ExecState*);
</span><span class="cx"> #endif
</span><ins>+#if ENABLE(TEST_FEATURE)
+JSC::EncodedJSValue JSC_HOST_CALL jsTestGlobalObjectInstanceFunctionTestPrivateFunction(JSC::ExecState*);
+#endif
</ins><span class="cx">
</span><span class="cx"> // Attributes
</span><span class="cx">
</span><span class="lines">@@ -154,6 +161,14 @@
</span><span class="cx"> if (RuntimeEnabledFeatures::sharedFeatures().testFeatureEnabled())
</span><span class="cx"> putDirectNativeFunction(vm, this, vm.propertyNames->enabledAtRuntimeOperation, 1, jsTestGlobalObjectInstanceFunctionEnabledAtRuntimeOperation, NoIntrinsic, attributesForStructure(JSC::Function));
</span><span class="cx"> #endif
</span><ins>+#if ENABLE(TEST_FEATURE)
+ if (RuntimeEnabledFeatures::sharedFeatures().testFeatureEnabled())
+ putDirectNativeFunction(vm, this, static_cast<JSVMClientData*>(vm.clientData)->builtinNames().testPrivateFunctionPrivateName(), 0, jsTestGlobalObjectInstanceFunctionTestPrivateFunction, NoIntrinsic, attributesForStructure(JSC::Function));
+#endif
+#if ENABLE(TEST_FEATURE)
+ if (RuntimeEnabledFeatures::sharedFeatures().testFeatureEnabled())
+ putDirectBuiltinFunction(vm, this, vm.propertyNames->testJSBuiltinFunction, testGlobalObjectTestJSBuiltinFunctionCodeGenerator(vm), attributesForStructure(JSC::Builtin));
+#endif
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> void JSTestGlobalObject::destroy(JSC::JSCell* cell)
</span><span class="lines">@@ -398,6 +413,21 @@
</span><span class="cx"> return throwVMTypeError(state);
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+#if ENABLE(TEST_FEATURE)
+EncodedJSValue JSC_HOST_CALL jsTestGlobalObjectInstanceFunctionTestPrivateFunction(ExecState* state)
+{
+ JSValue thisValue = state->thisValue();
+ auto castedThis = jsDynamicCast<JSTestGlobalObject*>(thisValue);
+ if (UNLIKELY(!castedThis))
+ return throwThisTypeError(*state, "TestGlobalObject", "testPrivateFunction");
+ ASSERT_GC_OBJECT_INHERITS(castedThis, JSTestGlobalObject::info());
+ auto& impl = castedThis->wrapped();
+ impl.testPrivateFunction();
+ return JSValue::encode(jsUndefined());
+}
+
+#endif
+
</ins><span class="cx"> bool JSTestGlobalObjectOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor)
</span><span class="cx"> {
</span><span class="cx"> UNUSED_PARAM(handle);
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsscriptstestObjCDOMTestGlobalObjectmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/scripts/test/ObjC/DOMTestGlobalObject.mm (203674 => 203675)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/scripts/test/ObjC/DOMTestGlobalObject.mm        2016-07-25 06:07:40 UTC (rev 203674)
+++ trunk/Source/WebCore/bindings/scripts/test/ObjC/DOMTestGlobalObject.mm        2016-07-25 06:28:35 UTC (rev 203675)
</span><span class="lines">@@ -132,6 +132,16 @@
</span><span class="cx">
</span><span class="cx"> #endif
</span><span class="cx">
</span><ins>+
+#if ENABLE(TEST_FEATURE)
+- (void)testJSBuiltinFunction
+{
+ WebCore::JSMainThreadNullState state;
+ IMPL->testJSBuiltinFunction();
+}
+
+#endif
+
</ins><span class="cx"> @end
</span><span class="cx">
</span><span class="cx"> WebCore::TestGlobalObject* core(DOMTestGlobalObject *wrapper)
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsscriptstestTestGlobalObjectidl"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/scripts/test/TestGlobalObject.idl (203674 => 203675)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/scripts/test/TestGlobalObject.idl        2016-07-25 06:07:40 UTC (rev 203674)
+++ trunk/Source/WebCore/bindings/scripts/test/TestGlobalObject.idl        2016-07-25 06:28:35 UTC (rev 203675)
</span><span class="lines">@@ -32,4 +32,7 @@
</span><span class="cx"> void regularOperation(DOMString testParam);
</span><span class="cx"> [Conditional=TEST_FEATURE, EnabledAtRuntime=TestFeature] void enabledAtRuntimeOperation(DOMString testParam);
</span><span class="cx"> [Conditional=TEST_FEATURE, EnabledAtRuntime=TestFeature] void enabledAtRuntimeOperation(long testParam);
</span><ins>+
+ [PrivateIdentifier, Conditional=TEST_FEATURE, EnabledAtRuntime=TestFeature] void testPrivateFunction();
+ [JSBuiltin, Conditional=TEST_FEATURE, EnabledAtRuntime=TestFeature] void testJSBuiltinFunction();
</ins><span class="cx"> };
</span></span></pre>
</div>
</div>
</body>
</html>