<!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>[206632] 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/206632">206632</a></dd>
<dt>Author</dt> <dd>commit-queue@webkit.org</dd>
<dt>Date</dt> <dd>2016-09-30 01:04:52 -0700 (Fri, 30 Sep 2016)</dd>
</dl>

<h3>Log Message</h3>
<pre>[Fetch API] Add support for URLSearchParams body
https://bugs.webkit.org/show_bug.cgi?id=162667

Patch by Youenn Fablet &lt;youennf@gmail.com&gt; on 2016-09-30
Reviewed by Alex Christensen.

LayoutTests/imported/w3c:

Adding new tests to consume, stream and upload URLSearchParams bodies.

* web-platform-tests/fetch/api/basic/request-headers-expected.txt:
* web-platform-tests/fetch/api/basic/request-headers-worker-expected.txt:
* web-platform-tests/fetch/api/basic/request-headers.js:
(checkContentType):
(requestHeaders):
* web-platform-tests/fetch/api/basic/request-upload-expected.txt: Added.
* web-platform-tests/fetch/api/basic/request-upload-worker-expected.txt: Added.
* web-platform-tests/fetch/api/basic/request-upload-worker.html: Added.
* web-platform-tests/fetch/api/basic/request-upload.html: Added.
* web-platform-tests/fetch/api/basic/request-upload.js: Added.
(testUpload):
* web-platform-tests/fetch/api/request/request-consume-empty-expected.txt:
* web-platform-tests/fetch/api/request/request-consume-empty.html:
* web-platform-tests/fetch/api/request/request-init-002-expected.txt:
* web-platform-tests/fetch/api/resources/echo-content.py: Added.
(main):
* web-platform-tests/fetch/api/response/response-consume-empty-expected.txt:
* web-platform-tests/fetch/api/response/response-consume-empty.html:
* web-platform-tests/fetch/api/response/response-consume-expected.txt:
* web-platform-tests/fetch/api/response/response-consume-stream-expected.txt:
* web-platform-tests/fetch/api/response/response-consume-stream.html:
* web-platform-tests/fetch/api/response/response-consume.html:
* web-platform-tests/fetch/api/response/response-init-002-expected.txt:

Source/WebCore:

Tests: imported/w3c/web-platform-tests/fetch/api/basic/request-upload-worker.html
       imported/w3c/web-platform-tests/fetch/api/basic/request-upload.html

* Modules/fetch/FetchBody.cpp:
(WebCore::extractBytesFromText): Moving to a static function that should be moved to a String method.
(WebCore::FetchBody::FetchBody): Adding constructor for URLSearchParams.
(WebCore::FetchBody::extract): Adding URLSearchParams body initialization.
(WebCore::FetchBody::consume): Consuming URLSearchParams bodies.
(WebCore::FetchBody::consumeAsStream): Ditto.
(WebCore::FetchBody::consumeText): Updated to take a parameter to handle both text and URLSearchParams bodies.
(WebCore::FetchBody::bodyForInternalRequest): Add URLSearchParams body upload.
(WebCore::FetchBody::clone): Add URLSearchParams body cloning
* Modules/fetch/FetchBody.h:
(WebCore::FetchBody::urlSearchParamsBody):
* html/URLSearchParams.cpp:
(WebCore::URLSearchParams::toString):
* html/URLSearchParams.h:</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsimportedw3cChangeLog">trunk/LayoutTests/imported/w3c/ChangeLog</a></li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestsfetchapibasicrequestheadersexpectedtxt">trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/basic/request-headers-expected.txt</a></li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestsfetchapibasicrequestheadersworkerexpectedtxt">trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/basic/request-headers-worker-expected.txt</a></li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestsfetchapibasicrequestheadersjs">trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/basic/request-headers.js</a></li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestsfetchapirequestrequestconsumeemptyexpectedtxt">trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/request/request-consume-empty-expected.txt</a></li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestsfetchapirequestrequestconsumeemptyhtml">trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/request/request-consume-empty.html</a></li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestsfetchapirequestrequestinit002expectedtxt">trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/request/request-init-002-expected.txt</a></li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestsfetchapiresponseresponseconsumeemptyexpectedtxt">trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-consume-empty-expected.txt</a></li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestsfetchapiresponseresponseconsumeemptyhtml">trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-consume-empty.html</a></li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestsfetchapiresponseresponseconsumeexpectedtxt">trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-consume-expected.txt</a></li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestsfetchapiresponseresponseconsumestreamexpectedtxt">trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-consume-stream-expected.txt</a></li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestsfetchapiresponseresponseconsumestreamhtml">trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-consume-stream.html</a></li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestsfetchapiresponseresponseconsumehtml">trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-consume.html</a></li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestsfetchapiresponseresponseinit002expectedtxt">trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-init-002-expected.txt</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreModulesfetchFetchBodycpp">trunk/Source/WebCore/Modules/fetch/FetchBody.cpp</a></li>
<li><a href="#trunkSourceWebCoreModulesfetchFetchBodyh">trunk/Source/WebCore/Modules/fetch/FetchBody.h</a></li>
<li><a href="#trunkSourceWebCorehtmlURLSearchParamscpp">trunk/Source/WebCore/html/URLSearchParams.cpp</a></li>
<li><a href="#trunkSourceWebCorehtmlURLSearchParamsh">trunk/Source/WebCore/html/URLSearchParams.h</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestsfetchapibasicrequestuploadexpectedtxt">trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/basic/request-upload-expected.txt</a></li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestsfetchapibasicrequestuploadworkerexpectedtxt">trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/basic/request-upload-worker-expected.txt</a></li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestsfetchapibasicrequestuploadworkerhtml">trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/basic/request-upload-worker.html</a></li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestsfetchapibasicrequestuploadhtml">trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/basic/request-upload.html</a></li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestsfetchapibasicrequestuploadjs">trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/basic/request-upload.js</a></li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestsfetchapiresourcesechocontentpy">trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/resources/echo-content.py</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsimportedw3cChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/imported/w3c/ChangeLog (206631 => 206632)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/ChangeLog        2016-09-30 06:41:08 UTC (rev 206631)
+++ trunk/LayoutTests/imported/w3c/ChangeLog        2016-09-30 08:04:52 UTC (rev 206632)
</span><span class="lines">@@ -1,3 +1,36 @@
</span><ins>+2016-09-30  Youenn Fablet  &lt;youennf@gmail.com&gt;
+
+        [Fetch API] Add support for URLSearchParams body
+        https://bugs.webkit.org/show_bug.cgi?id=162667
+
+        Reviewed by Alex Christensen.
+
+        Adding new tests to consume, stream and upload URLSearchParams bodies.
+
+        * web-platform-tests/fetch/api/basic/request-headers-expected.txt:
+        * web-platform-tests/fetch/api/basic/request-headers-worker-expected.txt:
+        * web-platform-tests/fetch/api/basic/request-headers.js:
+        (checkContentType):
+        (requestHeaders):
+        * web-platform-tests/fetch/api/basic/request-upload-expected.txt: Added.
+        * web-platform-tests/fetch/api/basic/request-upload-worker-expected.txt: Added.
+        * web-platform-tests/fetch/api/basic/request-upload-worker.html: Added.
+        * web-platform-tests/fetch/api/basic/request-upload.html: Added.
+        * web-platform-tests/fetch/api/basic/request-upload.js: Added.
+        (testUpload):
+        * web-platform-tests/fetch/api/request/request-consume-empty-expected.txt:
+        * web-platform-tests/fetch/api/request/request-consume-empty.html:
+        * web-platform-tests/fetch/api/request/request-init-002-expected.txt:
+        * web-platform-tests/fetch/api/resources/echo-content.py: Added.
+        (main):
+        * web-platform-tests/fetch/api/response/response-consume-empty-expected.txt:
+        * web-platform-tests/fetch/api/response/response-consume-empty.html:
+        * web-platform-tests/fetch/api/response/response-consume-expected.txt:
+        * web-platform-tests/fetch/api/response/response-consume-stream-expected.txt:
+        * web-platform-tests/fetch/api/response/response-consume-stream.html:
+        * web-platform-tests/fetch/api/response/response-consume.html:
+        * web-platform-tests/fetch/api/response/response-init-002-expected.txt:
+
</ins><span class="cx"> 2016-09-29  Chris Dumez  &lt;cdumez@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Add support for download attribute on area elements
</span></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestsfetchapibasicrequestheadersexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/basic/request-headers-expected.txt (206631 => 206632)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/basic/request-headers-expected.txt        2016-09-30 06:41:08 UTC (rev 206631)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/basic/request-headers-expected.txt        2016-09-30 08:04:52 UTC (rev 206632)
</span><span class="lines">@@ -6,6 +6,7 @@
</span><span class="cx"> PASS Fetch with POST without body 
</span><span class="cx"> PASS Fetch with POST with text body 
</span><span class="cx"> PASS Fetch with POST with FormData body 
</span><ins>+PASS Fetch with POST with URLSearchParams body 
</ins><span class="cx"> FAIL Fetch with POST with Blob body assert_equals: Request should have header content-type: null expected (object) null but got (string) &quot;application/x-www-form-urlencoded&quot;
</span><span class="cx"> FAIL Fetch with POST with ArrayBuffer body assert_equals: Request should have header content-type: null expected (object) null but got (string) &quot;application/x-www-form-urlencoded&quot;
</span><span class="cx"> FAIL Fetch with POST with Uint8Array body assert_equals: Request should have header content-type: null expected (object) null but got (string) &quot;application/x-www-form-urlencoded&quot;
</span></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestsfetchapibasicrequestheadersworkerexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/basic/request-headers-worker-expected.txt (206631 => 206632)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/basic/request-headers-worker-expected.txt        2016-09-30 06:41:08 UTC (rev 206631)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/basic/request-headers-worker-expected.txt        2016-09-30 08:04:52 UTC (rev 206632)
</span><span class="lines">@@ -6,6 +6,7 @@
</span><span class="cx"> PASS Fetch with POST without body 
</span><span class="cx"> PASS Fetch with POST with text body 
</span><span class="cx"> FAIL Fetch with POST with FormData body Can't find variable: FormData
</span><ins>+PASS Fetch with POST with URLSearchParams body 
</ins><span class="cx"> FAIL Fetch with POST with Blob body assert_equals: Request should have header content-type: null expected (object) null but got (string) &quot;application/x-www-form-urlencoded&quot;
</span><span class="cx"> FAIL Fetch with POST with ArrayBuffer body assert_equals: Request should have header content-type: null expected (object) null but got (string) &quot;application/x-www-form-urlencoded&quot;
</span><span class="cx"> FAIL Fetch with POST with Uint8Array body assert_equals: Request should have header content-type: null expected (object) null but got (string) &quot;application/x-www-form-urlencoded&quot;
</span></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestsfetchapibasicrequestheadersjs"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/basic/request-headers.js (206631 => 206632)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/basic/request-headers.js        2016-09-30 06:41:08 UTC (rev 206631)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/basic/request-headers.js        2016-09-30 08:04:52 UTC (rev 206632)
</span><span class="lines">@@ -15,6 +15,8 @@
</span><span class="cx">         expectedContentType = null;
</span><span class="cx">     else if (body instanceof Blob)
</span><span class="cx">         expectedContentType = body.type ? body.type : null;
</span><ins>+    else if (body instanceof URLSearchParams)
+        expectedContentType = &quot;application/x-www-form-urlencoded;charset=UTF-8&quot;;
</ins><span class="cx"> 
</span><span class="cx">     assert_equals(contentType , expectedContentType, &quot;Request should have header content-type: &quot; + expectedContentType);
</span><span class="cx"> }
</span><span class="lines">@@ -49,6 +51,7 @@
</span><span class="cx"> requestHeaders(&quot;Fetch with POST without body&quot;, url, &quot;POST&quot;, null, location.origin, &quot;0&quot;);
</span><span class="cx"> requestHeaders(&quot;Fetch with POST with text body&quot;, url, &quot;POST&quot;, &quot;Request's body&quot;, location.origin, &quot;14&quot;);
</span><span class="cx"> requestHeaders(&quot;Fetch with POST with FormData body&quot;, url, &quot;POST&quot;, function() { return new FormData(); }, location.origin);
</span><ins>+requestHeaders(&quot;Fetch with POST with URLSearchParams body&quot;, url, &quot;POST&quot;, function() { return new URLSearchParams(&quot;name=value&quot;); }, location.origin, &quot;10&quot;);
</ins><span class="cx"> requestHeaders(&quot;Fetch with POST with Blob body&quot;, url, &quot;POST&quot;, new Blob([&quot;Test&quot;]), location.origin, &quot;4&quot;);
</span><span class="cx"> requestHeaders(&quot;Fetch with POST with ArrayBuffer body&quot;, url, &quot;POST&quot;, new ArrayBuffer(4), location.origin, &quot;4&quot;);
</span><span class="cx"> requestHeaders(&quot;Fetch with POST with Uint8Array body&quot;, url, &quot;POST&quot;, new Uint8Array(4), location.origin, &quot;4&quot;);
</span></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestsfetchapibasicrequestuploadexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/basic/request-upload-expected.txt (0 => 206632)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/basic/request-upload-expected.txt                                (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/basic/request-upload-expected.txt        2016-09-30 08:04:52 UTC (rev 206632)
</span><span class="lines">@@ -0,0 +1,13 @@
</span><ins>+
+PASS Fetch with PUT with body 
+PASS Fetch with POST with text body 
+PASS Fetch with POST with URLSearchParams body 
+PASS Fetch with POST with Blob body 
+PASS Fetch with POST with ArrayBuffer body 
+PASS Fetch with POST with Uint8Array body 
+PASS Fetch with POST with Int8Array body 
+PASS Fetch with POST with Float32Array body 
+PASS Fetch with POST with Float64Array body 
+PASS Fetch with POST with DataView body 
+PASS Fetch with POST with Blob body with mime type 
+
</ins></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestsfetchapibasicrequestuploadworkerexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/basic/request-upload-worker-expected.txt (0 => 206632)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/basic/request-upload-worker-expected.txt                                (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/basic/request-upload-worker-expected.txt        2016-09-30 08:04:52 UTC (rev 206632)
</span><span class="lines">@@ -0,0 +1,13 @@
</span><ins>+
+PASS Fetch with PUT with body 
+PASS Fetch with POST with text body 
+PASS Fetch with POST with URLSearchParams body 
+PASS Fetch with POST with Blob body 
+PASS Fetch with POST with ArrayBuffer body 
+PASS Fetch with POST with Uint8Array body 
+PASS Fetch with POST with Int8Array body 
+PASS Fetch with POST with Float32Array body 
+PASS Fetch with POST with Float64Array body 
+PASS Fetch with POST with DataView body 
+PASS Fetch with POST with Blob body with mime type 
+
</ins></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestsfetchapibasicrequestuploadworkerhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/basic/request-upload-worker.html (0 => 206632)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/basic/request-upload-worker.html                                (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/basic/request-upload-worker.html        2016-09-30 08:04:52 UTC (rev 206632)
</span><span class="lines">@@ -0,0 +1,14 @@
</span><ins>+&lt;!doctype html&gt;
+&lt;html&gt;
+  &lt;head&gt;
+    &lt;meta charset=&quot;utf-8&quot;&gt;
+    &lt;title&gt;Fetch in worker: Upload&lt;/title&gt;
+    &lt;script src=&quot;/resources/testharness.js&quot;&gt;&lt;/script&gt;
+    &lt;script src=&quot;/resources/testharnessreport.js&quot;&gt;&lt;/script&gt;
+  &lt;/head&gt;
+  &lt;body&gt;
+    &lt;script&gt;
+      fetch_tests_from_worker(new Worker(&quot;request-upload.js&quot;));
+    &lt;/script&gt;
+  &lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestsfetchapibasicrequestuploadhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/basic/request-upload.html (0 => 206632)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/basic/request-upload.html                                (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/basic/request-upload.html        2016-09-30 08:04:52 UTC (rev 206632)
</span><span class="lines">@@ -0,0 +1,13 @@
</span><ins>+&lt;!doctype html&gt;
+&lt;html&gt;
+  &lt;head&gt;
+    &lt;meta charset=&quot;utf-8&quot;&gt;
+    &lt;title&gt;Fetch: Uploading content&lt;/title&gt;
+    &lt;script src=&quot;/resources/testharness.js&quot;&gt;&lt;/script&gt;
+    &lt;script src=&quot;/resources/testharnessreport.js&quot;&gt;&lt;/script&gt;
+    &lt;script src=&quot;../resources/utils.js&quot;&gt;&lt;/script&gt;
+  &lt;/head&gt;
+  &lt;body&gt;
+    &lt;script src=&quot;request-upload.js&quot;&gt;&lt;/script&gt;
+  &lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestsfetchapibasicrequestuploadjs"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/basic/request-upload.js (0 => 206632)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/basic/request-upload.js                                (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/basic/request-upload.js        2016-09-30 08:04:52 UTC (rev 206632)
</span><span class="lines">@@ -0,0 +1,35 @@
</span><ins>+if (this.document === undefined) {
+  importScripts(&quot;/resources/testharness.js&quot;);
+  importScripts(&quot;../resources/utils.js&quot;);
+}
+
+function testUpload(desc, url, method, body, expectedBody) {
+  var requestInit = {&quot;method&quot;: method}
+  promise_test(function(test){
+    if (typeof body === &quot;function&quot;)
+      body = body();
+    if (body)
+      requestInit[&quot;body&quot;] = body;
+    return fetch(url, requestInit).then(function(resp) {
+      return resp.text().then((text)=&gt; {
+        assert_equals(text, expectedBody);
+      });
+    });
+  }, desc);
+}
+
+var url = RESOURCES_DIR + &quot;echo-content.py&quot;
+
+testUpload(&quot;Fetch with PUT with body&quot;, url, &quot;PUT&quot;, &quot;Request's body&quot;, &quot;Request's body&quot;);
+testUpload(&quot;Fetch with POST with text body&quot;, url, &quot;POST&quot;, &quot;Request's body&quot;, &quot;Request's body&quot;);
+testUpload(&quot;Fetch with POST with URLSearchParams body&quot;, url, &quot;POST&quot;, function() { return new URLSearchParams(&quot;name=value&quot;); }, &quot;name=value&quot;);
+testUpload(&quot;Fetch with POST with Blob body&quot;, url, &quot;POST&quot;, new Blob([&quot;Test&quot;]), &quot;Test&quot;);
+testUpload(&quot;Fetch with POST with ArrayBuffer body&quot;, url, &quot;POST&quot;, new ArrayBuffer(4), &quot;\0\0\0\0&quot;);
+testUpload(&quot;Fetch with POST with Uint8Array body&quot;, url, &quot;POST&quot;, new Uint8Array(4), &quot;\0\0\0\0&quot;);
+testUpload(&quot;Fetch with POST with Int8Array body&quot;, url, &quot;POST&quot;, new Int8Array(4), &quot;\0\0\0\0&quot;);
+testUpload(&quot;Fetch with POST with Float32Array body&quot;, url, &quot;POST&quot;, new Float32Array(1), &quot;\0\0\0\0&quot;);
+testUpload(&quot;Fetch with POST with Float64Array body&quot;, url, &quot;POST&quot;, new Float64Array(1), &quot;\0\0\0\0\0\0\0\0&quot;);
+testUpload(&quot;Fetch with POST with DataView body&quot;, url, &quot;POST&quot;, new DataView(new ArrayBuffer(8), 0, 4), &quot;\0\0\0\0&quot;);
+testUpload(&quot;Fetch with POST with Blob body with mime type&quot;, url, &quot;POST&quot;, new Blob([&quot;Test&quot;], { type: &quot;text/maybe&quot; }), &quot;Test&quot;);
+
+done();
</ins></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestsfetchapirequestrequestconsumeemptyexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/request/request-consume-empty-expected.txt (206631 => 206632)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/request/request-consume-empty-expected.txt        2016-09-30 06:41:08 UTC (rev 206631)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/request/request-consume-empty-expected.txt        2016-09-30 08:04:52 UTC (rev 206632)
</span><span class="lines">@@ -8,4 +8,7 @@
</span><span class="cx"> PASS Consume empty text request body as arrayBuffer 
</span><span class="cx"> PASS Consume empty blob request body as text 
</span><span class="cx"> PASS Consume empty text request body as text 
</span><ins>+PASS Consume empty URLSearchParams request body as text 
+FAIL Consume empty FormData request body as text promise_test: Unhandled rejection with value: undefined
+PASS Consume empty ArrayBuffer request body as text 
</ins><span class="cx"> 
</span></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestsfetchapirequestrequestconsumeemptyhtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/request/request-consume-empty.html (206631 => 206632)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/request/request-consume-empty.html        2016-09-30 06:41:08 UTC (rev 206631)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/request/request-consume-empty.html        2016-09-30 08:04:52 UTC (rev 206632)
</span><span class="lines">@@ -98,6 +98,9 @@
</span><span class="cx">     checkRequestWithEmptyBody(&quot;text&quot;, &quot;&quot;, false);
</span><span class="cx">     checkRequestWithEmptyBody(&quot;blob&quot;, new Blob([], { &quot;type&quot; : &quot;text/plain&quot; }), true);
</span><span class="cx">     checkRequestWithEmptyBody(&quot;text&quot;, &quot;&quot;, true);
</span><ins>+    checkRequestWithEmptyBody(&quot;URLSearchParams&quot;, new URLSearchParams(&quot;&quot;), true);
+    checkRequestWithEmptyBody(&quot;FormData&quot;, new FormData(), true);
+    checkRequestWithEmptyBody(&quot;ArrayBuffer&quot;, new ArrayBuffer(), true);
</ins><span class="cx">     &lt;/script&gt;
</span><span class="cx">   &lt;/body&gt;
</span><span class="cx"> &lt;/html&gt;
</span></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestsfetchapirequestrequestinit002expectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/request/request-init-002-expected.txt (206631 => 206632)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/request/request-init-002-expected.txt        2016-09-30 06:41:08 UTC (rev 206631)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/request/request-init-002-expected.txt        2016-09-30 08:04:52 UTC (rev 206632)
</span><span class="lines">@@ -5,5 +5,5 @@
</span><span class="cx"> PASS Initialize Request's body with application/octet-binary 
</span><span class="cx"> FAIL Initialize Request's body with multipart/form-data promise_test: Unhandled rejection with value: undefined
</span><span class="cx"> PASS Initialize Request's body with text/plain;charset=UTF-8 
</span><del>-FAIL Initialize Request's body with application/x-www-form-urlencoded;charset=UTF-8 Type error
</del><ins>+PASS Initialize Request's body with application/x-www-form-urlencoded;charset=UTF-8 
</ins><span class="cx"> 
</span></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestsfetchapiresourcesechocontentpy"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/resources/echo-content.py (0 => 206632)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/resources/echo-content.py                                (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/resources/echo-content.py        2016-09-30 08:04:52 UTC (rev 206632)
</span><span class="lines">@@ -0,0 +1,9 @@
</span><ins>+def main(request, response):
+
+    headers = [(&quot;X-Request-Method&quot;, request.method),
+               (&quot;X-Request-Content-Length&quot;, request.headers.get(&quot;Content-Length&quot;, &quot;NO&quot;)),
+               (&quot;X-Request-Content-Type&quot;, request.headers.get(&quot;Content-Type&quot;, &quot;NO&quot;))]
+
+    content = request.body
+
+    return headers, content
</ins></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestsfetchapiresponseresponseconsumeemptyexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-consume-empty-expected.txt (206631 => 206632)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-consume-empty-expected.txt        2016-09-30 06:41:08 UTC (rev 206631)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-consume-empty-expected.txt        2016-09-30 08:04:52 UTC (rev 206632)
</span><span class="lines">@@ -8,4 +8,7 @@
</span><span class="cx"> PASS Consume empty text response body as arrayBuffer 
</span><span class="cx"> PASS Consume empty blob response body as text 
</span><span class="cx"> PASS Consume empty text response body as text 
</span><ins>+PASS Consume empty URLSearchParams response body as text 
+FAIL Consume empty FormData response body as text promise_test: Unhandled rejection with value: undefined
+PASS Consume empty ArrayBuffer response body as text 
</ins><span class="cx"> 
</span></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestsfetchapiresponseresponseconsumeemptyhtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-consume-empty.html (206631 => 206632)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-consume-empty.html        2016-09-30 06:41:08 UTC (rev 206631)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-consume-empty.html        2016-09-30 08:04:52 UTC (rev 206632)
</span><span class="lines">@@ -93,11 +93,13 @@
</span><span class="cx">       }, &quot;Consume empty &quot; + bodyType + &quot; response body as &quot; + (asText ? &quot;text&quot; : &quot;arrayBuffer&quot;));
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    // FIXME: Add BufferSource, FormData and URLSearchParams.
</del><span class="cx">     checkResponseWithEmptyBody(&quot;blob&quot;, new Blob([], { &quot;type&quot; : &quot;text/plain&quot; }), false);
</span><span class="cx">     checkResponseWithEmptyBody(&quot;text&quot;, &quot;&quot;, false);
</span><span class="cx">     checkResponseWithEmptyBody(&quot;blob&quot;, new Blob([], { &quot;type&quot; : &quot;text/plain&quot; }), true);
</span><span class="cx">     checkResponseWithEmptyBody(&quot;text&quot;, &quot;&quot;, true);
</span><ins>+    checkResponseWithEmptyBody(&quot;URLSearchParams&quot;, new URLSearchParams(&quot;&quot;), true);
+    checkResponseWithEmptyBody(&quot;FormData&quot;, new FormData(), true);
+    checkResponseWithEmptyBody(&quot;ArrayBuffer&quot;, new ArrayBuffer(), true);
</ins><span class="cx">     &lt;/script&gt;
</span><span class="cx">   &lt;/body&gt;
</span><span class="cx"> &lt;/html&gt;
</span></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestsfetchapiresponseresponseconsumeexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-consume-expected.txt (206631 => 206632)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-consume-expected.txt        2016-09-30 06:41:08 UTC (rev 206631)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-consume-expected.txt        2016-09-30 08:04:52 UTC (rev 206632)
</span><span class="lines">@@ -1,9 +1,12 @@
</span><span class="cx"> 
</span><del>-PASS Consume response's body as text 
-PASS Consume response's body as blob 
-PASS Consume response's body as arrayBuffer 
-PASS Consume response's body as json 
-FAIL Consume response's body as formData promise_test: Unhandled rejection with value: &quot;Not implemented&quot;
</del><ins>+PASS Consume text response's body as text 
+PASS Consume text response's body as blob 
+PASS Consume text response's body as arrayBuffer 
+PASS Consume text response's body as json 
+FAIL Consume formdata response's body as formData promise_test: Unhandled rejection with value: &quot;Not implemented&quot;
+PASS Consume URLSearchParams response's body as text 
+PASS Consume URLSearchParams response's body as blob 
+PASS Consume URLSearchParams response's body as arrayBuffer 
</ins><span class="cx"> PASS Consume blob response's body as blob 
</span><span class="cx"> PASS Consume blob response's body as text 
</span><span class="cx"> PASS Consume blob response's body as json 
</span></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestsfetchapiresponseresponseconsumestreamexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-consume-stream-expected.txt (206631 => 206632)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-consume-stream-expected.txt        2016-09-30 06:41:08 UTC (rev 206631)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-consume-stream-expected.txt        2016-09-30 08:04:52 UTC (rev 206632)
</span><span class="lines">@@ -3,6 +3,7 @@
</span><span class="cx"> PASS Read empty blob response's body as readableStream 
</span><span class="cx"> PASS Read blob response's body as readableStream 
</span><span class="cx"> PASS Read text response's body as readableStream 
</span><ins>+PASS Read text response's body as readableStream 
</ins><span class="cx"> PASS Read array buffer response's body as readableStream 
</span><span class="cx"> FAIL Read form data response's body as readableStream promise_test: Unhandled rejection with value: &quot;not implemented&quot;
</span><span class="cx"> PASS Getting an error Response stream 
</span></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestsfetchapiresponseresponseconsumestreamhtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-consume-stream.html (206631 => 206632)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-consume-stream.html        2016-09-30 06:41:08 UTC (rev 206631)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-consume-stream.html        2016-09-30 08:04:52 UTC (rev 206632)
</span><span class="lines">@@ -28,6 +28,8 @@
</span><span class="cx"> formData.append(&quot;name&quot;, &quot;value&quot;);
</span><span class="cx"> var textData = JSON.stringify(&quot;This is response's body&quot;);
</span><span class="cx"> var blob = new Blob([textData], { &quot;type&quot; : &quot;text/plain&quot; });
</span><ins>+var urlSearchParamsData = &quot;name=value&quot;;
+var urlSearchParams = new URLSearchParams(urlSearchParamsData);
</ins><span class="cx"> 
</span><span class="cx"> promise_test(function(test) {
</span><span class="cx">     var response = new Response(blob);
</span><span class="lines">@@ -40,6 +42,11 @@
</span><span class="cx"> }, &quot;Read text response's body as readableStream&quot;);
</span><span class="cx"> 
</span><span class="cx"> promise_test(function(test) {
</span><ins>+    var response = new Response(urlSearchParams);
+    return validateStreamFromString(response.body.getReader(), urlSearchParamsData);
+}, &quot;Read text response's body as readableStream&quot;);
+
+promise_test(function(test) {
</ins><span class="cx">     var arrayBuffer = new ArrayBuffer(textData.length);
</span><span class="cx">     var int8Array = new Int8Array(arrayBuffer);
</span><span class="cx">     for (var cptr = 0; cptr &lt; textData.length; cptr++)
</span></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestsfetchapiresponseresponseconsumehtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-consume.html (206631 => 206632)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-consume.html        2016-09-30 06:41:08 UTC (rev 206631)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-consume.html        2016-09-30 08:04:52 UTC (rev 206632)
</span><span class="lines">@@ -63,12 +63,12 @@
</span><span class="cx">      });
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    function checkResponseBody(body, bodyType, checkFunction) {
</del><ins>+    function checkResponseBody(body, bodyType, bodyConsumingType, checkFunction) {
</ins><span class="cx">       promise_test(function(test) {
</span><span class="cx">         var response = new Response(body, { &quot;headers&quot;: [[&quot;Content-Type&quot;, &quot;text/PLAIN&quot;]] });
</span><span class="cx">         assert_false(response.bodyUsed, &quot;bodyUsed is false at init&quot;);
</span><span class="cx">         return checkFunction(response, body);
</span><del>-      }, &quot;Consume response's body as &quot; + bodyType);
</del><ins>+      }, &quot;Consume &quot; + bodyType + &quot; response's body as &quot; + bodyConsumingType);
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     var formData = new FormData();
</span><span class="lines">@@ -75,12 +75,17 @@
</span><span class="cx">     formData.append(&quot;name&quot;, &quot;value&quot;);
</span><span class="cx">     var textData = JSON.stringify(&quot;This is response's body&quot;);
</span><span class="cx">     var blob = new Blob([textData], { &quot;type&quot; : &quot;text/plain&quot; });
</span><ins>+    var urlSearchParamsData = &quot;name=value&quot;;
+    var urlSearchParams = new URLSearchParams(urlSearchParamsData);
</ins><span class="cx"> 
</span><del>-    checkResponseBody(textData, &quot;text&quot;, checkBodyText);
-    checkResponseBody(textData, &quot;blob&quot;, function(response, body) { checkBodyBlob(response, body, true); });
-    checkResponseBody(textData, &quot;arrayBuffer&quot;, checkBodyArrayBuffer);
-    checkResponseBody(textData, &quot;json&quot;, checkBodyJSON);
-    checkResponseBody(formData, &quot;formData&quot;, checkBodyFormData);
</del><ins>+    checkResponseBody(textData, &quot;text&quot;, &quot;text&quot;, checkBodyText);
+    checkResponseBody(textData, &quot;text&quot;, &quot;blob&quot;, function(response, body) { checkBodyBlob(response, body, true); });
+    checkResponseBody(textData, &quot;text&quot;, &quot;arrayBuffer&quot;, checkBodyArrayBuffer);
+    checkResponseBody(textData, &quot;text&quot;, &quot;json&quot;, checkBodyJSON);
+    checkResponseBody(formData, &quot;formdata&quot;, &quot;formData&quot;, checkBodyFormData);
+    checkResponseBody(urlSearchParams, &quot;URLSearchParams&quot;, &quot;text&quot;, function(response) { checkBodyText(response, urlSearchParams); });
+    checkResponseBody(urlSearchParams, &quot;URLSearchParams&quot;, &quot;blob&quot;, function(response, body) { checkBodyBlob(response, urlSearchParamsData, false); });
+    checkResponseBody(urlSearchParams, &quot;URLSearchParams&quot;, &quot;arrayBuffer&quot;, function(response) { checkBodyArrayBuffer(response, urlSearchParamsData); });
</ins><span class="cx"> 
</span><span class="cx">     function checkBlobResponseBody(blobBody, blobData, bodyType, checkFunction) {
</span><span class="cx">       promise_test(function(test) {
</span></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestsfetchapiresponseresponseinit002expectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-init-002-expected.txt (206631 => 206632)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-init-002-expected.txt        2016-09-30 06:41:08 UTC (rev 206631)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-init-002-expected.txt        2016-09-30 08:04:52 UTC (rev 206632)
</span><span class="lines">@@ -2,7 +2,7 @@
</span><span class="cx"> PASS Initialize Response with headers values 
</span><span class="cx"> PASS Initialize Response's body with application/octet-binary 
</span><span class="cx"> FAIL Initialize Response's body with multipart/form-data promise_test: Unhandled rejection with value: undefined
</span><del>-FAIL Initialize Response's body with application/x-www-form-urlencoded;charset=UTF-8 assert_true: Content-Type header should be &quot;application/x-www-form-urlencoded;charset=UTF-8&quot;  expected true got null
</del><ins>+PASS Initialize Response's body with application/x-www-form-urlencoded;charset=UTF-8 
</ins><span class="cx"> PASS Initialize Response's body with text/plain;charset=UTF-8 
</span><span class="cx"> PASS Read Response's body as readableStream 
</span><span class="cx"> PASS Testing empty Response Content-Type header 
</span></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (206631 => 206632)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2016-09-30 06:41:08 UTC (rev 206631)
+++ trunk/Source/WebCore/ChangeLog        2016-09-30 08:04:52 UTC (rev 206632)
</span><span class="lines">@@ -1,3 +1,28 @@
</span><ins>+2016-09-30  Youenn Fablet  &lt;youennf@gmail.com&gt;
+
+        [Fetch API] Add support for URLSearchParams body
+        https://bugs.webkit.org/show_bug.cgi?id=162667
+
+        Reviewed by Alex Christensen.
+
+        Tests: imported/w3c/web-platform-tests/fetch/api/basic/request-upload-worker.html
+               imported/w3c/web-platform-tests/fetch/api/basic/request-upload.html
+
+        * Modules/fetch/FetchBody.cpp:
+        (WebCore::extractBytesFromText): Moving to a static function that should be moved to a String method.
+        (WebCore::FetchBody::FetchBody): Adding constructor for URLSearchParams.
+        (WebCore::FetchBody::extract): Adding URLSearchParams body initialization.
+        (WebCore::FetchBody::consume): Consuming URLSearchParams bodies.
+        (WebCore::FetchBody::consumeAsStream): Ditto.
+        (WebCore::FetchBody::consumeText): Updated to take a parameter to handle both text and URLSearchParams bodies.
+        (WebCore::FetchBody::bodyForInternalRequest): Add URLSearchParams body upload.
+        (WebCore::FetchBody::clone): Add URLSearchParams body cloning
+        * Modules/fetch/FetchBody.h:
+        (WebCore::FetchBody::urlSearchParamsBody):
+        * html/URLSearchParams.cpp:
+        (WebCore::URLSearchParams::toString):
+        * html/URLSearchParams.h:
+
</ins><span class="cx"> 2016-09-29  Simon Fraser  &lt;simon.fraser@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Re-order the arguments to drawPattern() functions
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesfetchFetchBodycpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/fetch/FetchBody.cpp (206631 => 206632)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/fetch/FetchBody.cpp        2016-09-30 06:41:08 UTC (rev 206631)
+++ trunk/Source/WebCore/Modules/fetch/FetchBody.cpp        2016-09-30 08:04:52 UTC (rev 206632)
</span><span class="lines">@@ -41,11 +41,21 @@
</span><span class="cx"> #include &quot;JSBlob.h&quot;
</span><span class="cx"> #include &quot;JSDOMFormData.h&quot;
</span><span class="cx"> #include &quot;JSReadableStream.h&quot;
</span><ins>+#include &quot;JSURLSearchParams.h&quot;
</ins><span class="cx"> #include &quot;ReadableStreamSource.h&quot;
</span><span class="cx"> #include &lt;runtime/ArrayBufferView.h&gt;
</span><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><ins>+// FIXME: This implementation is not efficient and we should probably use UTF8Encoding().
+static Vector&lt;uint8_t&gt; extractBytesFromText(const String&amp; text)
+{
+    CString data = text.utf8();
+    Vector&lt;uint8_t&gt; value(data.length());
+    memcpy(value.data(), data.data(), data.length());
+    return value;
+}
+
</ins><span class="cx"> FetchBody::FetchBody(Ref&lt;const Blob&gt;&amp;&amp; blob)
</span><span class="cx">     : m_type(Type::Blob)
</span><span class="cx">     , m_data(WTFMove(blob))
</span><span class="lines">@@ -79,6 +89,13 @@
</span><span class="cx"> {
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+FetchBody::FetchBody(Ref&lt;const URLSearchParams&gt;&amp;&amp; url)
+    : m_type(Type::URLSeachParams)
+    , m_data(WTFMove(url))
+    , m_contentType(ASCIILiteral(&quot;application/x-www-form-urlencoded;charset=UTF-8&quot;))
+{
+}
+
</ins><span class="cx"> FetchBody::FetchBody(Type type, const String&amp; contentType, const FetchBodyConsumer&amp; consumer)
</span><span class="cx">     : m_type(type)
</span><span class="cx">     , m_contentType(contentType)
</span><span class="lines">@@ -96,6 +113,8 @@
</span><span class="cx">     }
</span><span class="cx">     if (value.isString())
</span><span class="cx">         return FetchBody(value.toWTFString(&amp;state));
</span><ins>+    if (value.inherits(JSURLSearchParams::info()))
+        return FetchBody(*JSURLSearchParams::toWrapped(value));
</ins><span class="cx">     if (value.inherits(JSReadableStream::info()))
</span><span class="cx">         return { Type::ReadableStream };
</span><span class="cx">     if (value.inherits(JSC::JSArrayBuffer::info())) {
</span><span class="lines">@@ -185,8 +204,11 @@
</span><span class="cx">         consumeArrayBufferView(WTFMove(promise));
</span><span class="cx">         return;
</span><span class="cx">     case Type::Text:
</span><del>-        consumeText(WTFMove(promise));
</del><ins>+        consumeText(WTFMove(promise), textBody());
</ins><span class="cx">         return;
</span><ins>+    case Type::URLSeachParams:
+        consumeText(WTFMove(promise), urlSearchParamsBody().toString());
+        return;
</ins><span class="cx">     case Type::Blob:
</span><span class="cx">         consumeBlob(owner, WTFMove(promise));
</span><span class="cx">         return;
</span><span class="lines">@@ -225,11 +247,17 @@
</span><span class="cx">         break;
</span><span class="cx">     }
</span><span class="cx">     case Type::Text: {
</span><del>-        Vector&lt;uint8_t&gt; data = extractFromText();
</del><ins>+        Vector&lt;uint8_t&gt; data = extractBytesFromText(textBody());
</ins><span class="cx">         closeStream = source.enqueue(ArrayBuffer::tryCreate(data.data(), data.size()));
</span><span class="cx">         m_data = nullptr;
</span><span class="cx">         break;
</span><span class="cx">     }
</span><ins>+    case Type::URLSeachParams: {
+        Vector&lt;uint8_t&gt; data = extractBytesFromText(urlSearchParamsBody().toString());
+        closeStream = source.enqueue(ArrayBuffer::tryCreate(data.data(), data.size()));
+        m_data = nullptr;
+        break;
+    }
</ins><span class="cx">     case Type::Blob:
</span><span class="cx">         owner.loadBlob(blobBody(), nullptr);
</span><span class="cx">         m_data = nullptr;
</span><span class="lines">@@ -262,9 +290,9 @@
</span><span class="cx">     m_data = nullptr;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void FetchBody::consumeText(Ref&lt;DeferredPromise&gt;&amp;&amp; promise)
</del><ins>+void FetchBody::consumeText(Ref&lt;DeferredPromise&gt;&amp;&amp; promise, const String&amp; text)
</ins><span class="cx"> {
</span><del>-    Vector&lt;uint8_t&gt; data = extractFromText();
</del><ins>+    Vector&lt;uint8_t&gt; data = extractBytesFromText(text);
</ins><span class="cx">     m_consumer.resolveWithData(WTFMove(promise), data.data(), data.size());
</span><span class="cx">     m_data = nullptr;
</span><span class="cx"> }
</span><span class="lines">@@ -276,16 +304,6 @@
</span><span class="cx">     m_data = nullptr;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-Vector&lt;uint8_t&gt; FetchBody::extractFromText() const
-{
-    ASSERT(m_type == Type::Text);
-    // FIXME: This double allocation is not efficient. Might want to fix that at WTFString level.
-    CString data = textBody().utf8();
-    Vector&lt;uint8_t&gt; value(data.length());
-    memcpy(value.data(), data.data(), data.length());
-    return value;
-}
-
</del><span class="cx"> void FetchBody::loadingFailed()
</span><span class="cx"> {
</span><span class="cx">     if (m_consumePromise) {
</span><span class="lines">@@ -308,6 +326,8 @@
</span><span class="cx">         return nullptr;
</span><span class="cx">     case Type::Text:
</span><span class="cx">         return FormData::create(UTF8Encoding().encode(textBody(), EntitiesForUnencodables));
</span><ins>+    case Type::URLSeachParams:
+        return FormData::create(UTF8Encoding().encode(urlSearchParamsBody().toString(), EntitiesForUnencodables));
</ins><span class="cx">     case Type::Blob: {
</span><span class="cx">         RefPtr&lt;FormData&gt; body = FormData::create();
</span><span class="cx">         body-&gt;appendBlob(blobBody().url());
</span><span class="lines">@@ -350,6 +370,9 @@
</span><span class="cx">     case Type::Text:
</span><span class="cx">         clone.m_data = textBody();
</span><span class="cx">         break;
</span><ins>+    case Type::URLSeachParams:
+        clone.m_data = urlSearchParamsBody();
+        break;
</ins><span class="cx">     case Type::Loaded:
</span><span class="cx">     case Type::None:
</span><span class="cx">     case Type::Loading:
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesfetchFetchBodyh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/fetch/FetchBody.h (206631 => 206632)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/fetch/FetchBody.h        2016-09-30 06:41:08 UTC (rev 206631)
+++ trunk/Source/WebCore/Modules/fetch/FetchBody.h        2016-09-30 08:04:52 UTC (rev 206632)
</span><span class="lines">@@ -36,6 +36,7 @@
</span><span class="cx"> #include &quot;FetchLoader.h&quot;
</span><span class="cx"> #include &quot;FormData.h&quot;
</span><span class="cx"> #include &quot;JSDOMPromise.h&quot;
</span><ins>+#include &quot;URLSearchParams.h&quot;
</ins><span class="cx"> #include &lt;wtf/Variant.h&gt;
</span><span class="cx"> 
</span><span class="cx"> namespace JSC {
</span><span class="lines">@@ -79,7 +80,7 @@
</span><span class="cx"> 
</span><span class="cx">     RefPtr&lt;FormData&gt; bodyForInternalRequest(ScriptExecutionContext&amp;) const;
</span><span class="cx"> 
</span><del>-    enum class Type { None, ArrayBuffer, ArrayBufferView, Blob, FormData, Text, Loading, Loaded, ReadableStream };
</del><ins>+    enum class Type { None, ArrayBuffer, ArrayBufferView, Blob, FormData, Text, URLSeachParams, Loading, Loaded, ReadableStream };
</ins><span class="cx">     Type type() const { return m_type; }
</span><span class="cx"> 
</span><span class="cx">     FetchBodyConsumer&amp; consumer() { return m_consumer; }
</span><span class="lines">@@ -94,15 +95,15 @@
</span><span class="cx">     FetchBody(Ref&lt;const ArrayBufferView&gt;&amp;&amp;);
</span><span class="cx">     FetchBody(DOMFormData&amp;, Document&amp;);
</span><span class="cx">     FetchBody(String&amp;&amp;);
</span><ins>+    FetchBody(Ref&lt;const URLSearchParams&gt;&amp;&amp;);
</ins><span class="cx">     FetchBody(Type, const String&amp;, const FetchBodyConsumer&amp;);
</span><span class="cx">     FetchBody(Type type) : m_type(type) { }
</span><span class="cx"> 
</span><span class="cx">     void consume(FetchBodyOwner&amp;, Ref&lt;DeferredPromise&gt;&amp;&amp;);
</span><span class="cx"> 
</span><del>-    Vector&lt;uint8_t&gt; extractFromText() const;
</del><span class="cx">     void consumeArrayBuffer(Ref&lt;DeferredPromise&gt;&amp;&amp;);
</span><span class="cx">     void consumeArrayBufferView(Ref&lt;DeferredPromise&gt;&amp;&amp;);
</span><del>-    void consumeText(Ref&lt;DeferredPromise&gt;&amp;&amp;);
</del><ins>+    void consumeText(Ref&lt;DeferredPromise&gt;&amp;&amp;, const String&amp;);
</ins><span class="cx">     void consumeBlob(FetchBodyOwner&amp;, Ref&lt;DeferredPromise&gt;&amp;&amp;);
</span><span class="cx"> 
</span><span class="cx">     const Blob&amp; blobBody() const { return std::experimental::get&lt;Ref&lt;const Blob&gt;&gt;(m_data).get(); }
</span><span class="lines">@@ -112,11 +113,11 @@
</span><span class="cx">     const ArrayBufferView&amp; arrayBufferViewBody() const { return std::experimental::get&lt;Ref&lt;const ArrayBufferView&gt;&gt;(m_data).get(); }
</span><span class="cx">     String&amp; textBody() { return std::experimental::get&lt;String&gt;(m_data); }
</span><span class="cx">     const String&amp; textBody() const { return std::experimental::get&lt;String&gt;(m_data); }
</span><ins>+    const URLSearchParams&amp; urlSearchParamsBody() const { return std::experimental::get&lt;Ref&lt;const URLSearchParams&gt;&gt;(m_data).get(); }
</ins><span class="cx"> 
</span><span class="cx">     Type m_type { Type::None };
</span><span class="cx"> 
</span><del>-    // FIXME: Add support for URLSearchParams.
-    std::experimental::variant&lt;std::nullptr_t, Ref&lt;const Blob&gt;, Ref&lt;FormData&gt;, Ref&lt;const ArrayBuffer&gt;, Ref&lt;const ArrayBufferView&gt;, String&gt; m_data;
</del><ins>+    std::experimental::variant&lt;std::nullptr_t, Ref&lt;const Blob&gt;, Ref&lt;FormData&gt;, Ref&lt;const ArrayBuffer&gt;, Ref&lt;const ArrayBufferView&gt;, Ref&lt;const URLSearchParams&gt;, String&gt; m_data;
</ins><span class="cx">     String m_contentType;
</span><span class="cx"> 
</span><span class="cx">     FetchBodyConsumer m_consumer { FetchBodyConsumer::Type::None };
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlURLSearchParamscpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/URLSearchParams.cpp (206631 => 206632)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/URLSearchParams.cpp        2016-09-30 06:41:08 UTC (rev 206631)
+++ trunk/Source/WebCore/html/URLSearchParams.cpp        2016-09-30 08:04:52 UTC (rev 206632)
</span><span class="lines">@@ -106,7 +106,7 @@
</span><span class="cx">         updateURL();
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-String URLSearchParams::toString()
</del><ins>+String URLSearchParams::toString() const
</ins><span class="cx"> {
</span><span class="cx">     return URLParser::serialize(m_pairs);
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlURLSearchParamsh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/URLSearchParams.h (206631 => 206632)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/URLSearchParams.h        2016-09-30 06:41:08 UTC (rev 206631)
+++ trunk/Source/WebCore/html/URLSearchParams.h        2016-09-30 08:04:52 UTC (rev 206632)
</span><span class="lines">@@ -42,7 +42,7 @@
</span><span class="cx">     Vector&lt;String&gt; getAll(const String&amp; name) const;
</span><span class="cx">     bool has(const String&amp; name) const;
</span><span class="cx">     void set(const String&amp; name, const String&amp; value);
</span><del>-    String toString();
</del><ins>+    String toString() const;
</ins><span class="cx">     operator const Vector&lt;std::pair&lt;String, String&gt;&gt;&amp;() { return m_pairs; }
</span><span class="cx">     void updateFromAssociatedURL();
</span><span class="cx"> 
</span></span></pre>
</div>
</div>

</body>
</html>