<!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>[198665] 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/198665">198665</a></dd>
<dt>Author</dt> <dd>youenn.fablet@crf.canon.fr</dd>
<dt>Date</dt> <dd>2016-03-25 07:19:31 -0700 (Fri, 25 Mar 2016)</dd>
</dl>

<h3>Log Message</h3>
<pre>[Fetch API] Add basic loading of resources
https://bugs.webkit.org/show_bug.cgi?id=155637

Reviewed by Darin Adler.

LayoutTests/imported/w3c:

Rebasing test expectations.
Updating scheme-blob.js to ensure generated test names are stable run after run.

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

Source/WebCore:

Adding support for basic fetch for Window (no support for Worker yet).
A FetchResponse object is created for every fetch task.
But it will only be exposed to JS at promise fulfillment time, i.e. once initial response headers are retrieved.

Updating Blob resource handle to add Content-Type and Content-Length header and notifying of error in case of erroneous HTTP method.

Fetch is limited to same origin requests currently due to some WPT tests that would timeout otherwise.

Tests: http/tests/fetch/closing-while-fetching.html
       http/tests/fetch/get-response-body-while-loading.html
Also covered by rebased tests.

* Modules/fetch/DOMWindowFetch.cpp: Creating a FetchResponse to start fetching.
(WebCore::DOMWindowFetch::fetch):
* Modules/fetch/DOMWindowFetch.h:
* Modules/fetch/FetchBody.cpp:
(WebCore::FetchBody::consume):
(WebCore::FetchBody::consumeArrayBuffer): Handling of body promises in case of data stored as a buffer.
(WebCore::FetchBody::consumeText): Passing the promise as a reference.
(WebCore::blobFromArrayBuffer): Helper routine.
(WebCore::FetchBody::fulfillTextPromise): Helper routine.
(WebCore::FetchBody::loadedAsArrayBuffer): Updated to handle storing of data as a buffer.
(WebCore::FetchBody::loadedAsText):
(WebCore::FetchBody::bodyForInternalRequest): Helper routine to generate the request body data to be sent as part of the fetch request.
(WebCore::FetchBody::extractFromText):
* Modules/fetch/FetchBody.h:
(WebCore::FetchBody::loadingBody):
(WebCore::FetchBody::FetchBody):
* Modules/fetch/FetchBodyOwner.cpp:
(WebCore::FetchBodyOwner::loadBlob): Updated to cope with the change that FetchLoader::start does not return a boolean anymore
but will directly call failure callbacks.
(WebCore::FetchBodyOwner::loadedBlobAsText): Moving it closer to other blob loading routines.
(WebCore::FetchBodyOwner::finishBlobLoading):
* Modules/fetch/FetchBodyOwner.h:
(WebCore::FetchBodyOwner::body):
(WebCore::FetchBodyOwner::loadedBlobAsArrayBuffer):
* Modules/fetch/FetchHeaders.cpp:
(WebCore::FetchHeaders::fill):
(WebCore::FetchHeaders::filterAndFill): Helper routine to fill headers from a HTTPHeaderMap after being filtered.
* Modules/fetch/FetchHeaders.h:
(WebCore::FetchHeaders::internalHeaders):
* Modules/fetch/FetchLoader.cpp:
(WebCore::FetchLoader::start):
(WebCore::FetchLoader::didFailRedirectCheck):
* Modules/fetch/FetchLoader.h:
* Modules/fetch/FetchRequest.cpp:
(WebCore::FetchRequest::internalRequest): Routine used to create the ResourceRequest transmitted to ThreadableLoader.
       * Modules/fetch/FetchRequest.h:
* Modules/fetch/FetchResponse.cpp:
(WebCore::FetchResponse::fetch): Start fetching by creating a FetchLoader based on passed request.
(WebCore::FetchResponse::BodyLoader::didSucceed): FetchLoader callback.
(WebCore::FetchResponse::BodyLoader::didFail): Ditto.
(WebCore::FetchResponse::BodyLoader::BodyLoader): Ditto.
(WebCore::FetchResponse::BodyLoader::didReceiveResponse): Ditto.
(WebCore::FetchResponse::BodyLoader::didFinishLoadingAsArrayBuffer): Ditto.
(WebCore::FetchResponse::BodyLoader::start): Starting fetch loader.
(WebCore::FetchResponse::BodyLoader::stop): Stopping fetch loader.
(WebCore::FetchResponse::stop): Stop loader if any.
* Modules/fetch/FetchResponse.h:
* platform/network/BlobResourceHandle.cpp:
(WebCore::BlobResourceHandle::doStart: Notifying the loader with an error if verb is not GET.
(WebCore::BlobResourceHandle::notifyResponseOnSuccess): Adding support for Content-Type and Content-Lenth headers.
(WebCore::BlobResourceHandle::createAsync): Removing GET verb check.

LayoutTests:

* TestExpectations: Removed flaky test expectations.
* http/tests/fetch/closing-while-fetching-expected.txt: Added.
* http/tests/fetch/closing-while-fetching.html: Added.
* http/tests/fetch/get-response-body-while-loading-expected.txt: Added.
* http/tests/fetch/get-response-body-while-loading.html: Added.
* http/tests/resources/download-json-with-delay.php: Added.
* platform/gtk/imported/w3c/web-platform-tests/fetch/api/basic/request-headers-expected.txt: Added.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkLayoutTestsTestExpectations">trunk/LayoutTests/TestExpectations</a></li>
<li><a href="#trunkLayoutTestsimportedw3cChangeLog">trunk/LayoutTests/imported/w3c/ChangeLog</a></li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestsfetchapibasicacceptheaderexpectedtxt">trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/basic/accept-header-expected.txt</a></li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestsfetchapibasicintegrityexpectedtxt">trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/basic/integrity-expected.txt</a></li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestsfetchapibasicmodenocorsexpectedtxt">trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/basic/mode-no-cors-expected.txt</a></li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestsfetchapibasicmodesameoriginexpectedtxt">trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/basic/mode-same-origin-expected.txt</a></li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestsfetchapibasicrequestforbiddenheadersexpectedtxt">trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/basic/request-forbidden-headers-expected.txt</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="#trunkLayoutTestsimportedw3cwebplatformtestsfetchapibasicschemeaboutexpectedtxt">trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/basic/scheme-about-expected.txt</a></li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestsfetchapibasicschemeblobexpectedtxt">trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/basic/scheme-blob-expected.txt</a></li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestsfetchapibasicschemeblobworkerexpectedtxt">trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/basic/scheme-blob-worker-expected.txt</a></li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestsfetchapibasicschemeblobjs">trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/basic/scheme-blob.js</a></li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestsfetchapibasicschemedataexpectedtxt">trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/basic/scheme-data-expected.txt</a></li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestsfetchapibasicschemeothersexpectedtxt">trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/basic/scheme-others-expected.txt</a></li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestsfetchapibasicstreamresponseexpectedtxt">trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/basic/stream-response-expected.txt</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</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="#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="#trunkSourceWebCoreModulesfetchFetchBodyOwnercpp">trunk/Source/WebCore/Modules/fetch/FetchBodyOwner.cpp</a></li>
<li><a href="#trunkSourceWebCoreModulesfetchFetchBodyOwnerh">trunk/Source/WebCore/Modules/fetch/FetchBodyOwner.h</a></li>
<li><a href="#trunkSourceWebCoreModulesfetchFetchHeaderscpp">trunk/Source/WebCore/Modules/fetch/FetchHeaders.cpp</a></li>
<li><a href="#trunkSourceWebCoreModulesfetchFetchHeadersh">trunk/Source/WebCore/Modules/fetch/FetchHeaders.h</a></li>
<li><a href="#trunkSourceWebCoreModulesfetchFetchLoadercpp">trunk/Source/WebCore/Modules/fetch/FetchLoader.cpp</a></li>
<li><a href="#trunkSourceWebCoreModulesfetchFetchLoaderh">trunk/Source/WebCore/Modules/fetch/FetchLoader.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="#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="#trunkSourceWebCoreplatformnetworkBlobResourceHandlecpp">trunk/Source/WebCore/platform/network/BlobResourceHandle.cpp</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li>trunk/LayoutTests/http/tests/fetch/</li>
<li><a href="#trunkLayoutTestshttptestsfetchclosingwhilefetchingexpectedtxt">trunk/LayoutTests/http/tests/fetch/closing-while-fetching-expected.txt</a></li>
<li><a href="#trunkLayoutTestshttptestsfetchclosingwhilefetchinghtml">trunk/LayoutTests/http/tests/fetch/closing-while-fetching.html</a></li>
<li><a href="#trunkLayoutTestshttptestsfetchgetresponsebodywhileloadingexpectedtxt">trunk/LayoutTests/http/tests/fetch/get-response-body-while-loading-expected.txt</a></li>
<li><a href="#trunkLayoutTestshttptestsfetchgetresponsebodywhileloadinghtml">trunk/LayoutTests/http/tests/fetch/get-response-body-while-loading.html</a></li>
<li><a href="#trunkLayoutTestshttptestsresourcesdownloadjsonwithdelayphp">trunk/LayoutTests/http/tests/resources/download-json-with-delay.php</a></li>
<li>trunk/LayoutTests/platform/gtk/imported/w3c/</li>
<li>trunk/LayoutTests/platform/gtk/imported/w3c/web-platform-tests/</li>
<li>trunk/LayoutTests/platform/gtk/imported/w3c/web-platform-tests/fetch/</li>
<li>trunk/LayoutTests/platform/gtk/imported/w3c/web-platform-tests/fetch/api/</li>
<li>trunk/LayoutTests/platform/gtk/imported/w3c/web-platform-tests/fetch/api/basic/</li>
<li><a href="#trunkLayoutTestsplatformgtkimportedw3cwebplatformtestsfetchapibasicrequestheadersexpectedtxt">trunk/LayoutTests/platform/gtk/imported/w3c/web-platform-tests/fetch/api/basic/request-headers-expected.txt</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (198664 => 198665)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2016-03-25 14:08:56 UTC (rev 198664)
+++ trunk/LayoutTests/ChangeLog        2016-03-25 14:19:31 UTC (rev 198665)
</span><span class="lines">@@ -1,3 +1,18 @@
</span><ins>+2016-03-25  Youenn Fablet  &lt;youenn.fablet@crf.canon.fr&gt;
+
+        [Fetch API] Add basic loading of resources
+        https://bugs.webkit.org/show_bug.cgi?id=155637
+
+        Reviewed by Darin Adler.
+
+        * TestExpectations: Removed flaky test expectations.
+        * http/tests/fetch/closing-while-fetching-expected.txt: Added.
+        * http/tests/fetch/closing-while-fetching.html: Added.
+        * http/tests/fetch/get-response-body-while-loading-expected.txt: Added.
+        * http/tests/fetch/get-response-body-while-loading.html: Added.
+        * http/tests/resources/download-json-with-delay.php: Added.
+        * platform/gtk/imported/w3c/web-platform-tests/fetch/api/basic/request-headers-expected.txt: Added.
+
</ins><span class="cx"> 2016-03-25  Gyuyoung Kim  &lt;gyuyoung.kim@webkit.org&gt;
</span><span class="cx"> 
</span><span class="cx">         Unreviewed EFL gardening.
</span></span></pre></div>
<a id="trunkLayoutTestsTestExpectations"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/TestExpectations (198664 => 198665)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/TestExpectations        2016-03-25 14:08:56 UTC (rev 198664)
+++ trunk/LayoutTests/TestExpectations        2016-03-25 14:19:31 UTC (rev 198665)
</span><span class="lines">@@ -317,10 +317,6 @@
</span><span class="cx"> imported/w3c/web-platform-tests/XMLHttpRequest/send-redirect-to-cors.htm [ Skip ]
</span><span class="cx"> imported/w3c/web-platform-tests/XMLHttpRequest/send-redirect-to-non-cors.htm [ Skip ]
</span><span class="cx"> 
</span><del>-# Tests that are flaky as failing assertions print a new token generated for each test run.
-imported/w3c/web-platform-tests/fetch/api/basic/scheme-blob.html [ Failure ]
-imported/w3c/web-platform-tests/fetch/api/basic/scheme-blob-worker.html [ Failure ]
-
</del><span class="cx"> # New W3C ref tests that are failing.
</span><span class="cx"> webkit.org/b/148856 imported/w3c/web-platform-tests/html/semantics/embedded-content/the-video-element/video_initially_paused.html [ ImageOnlyFailure ]
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkLayoutTestshttptestsfetchclosingwhilefetchingexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/http/tests/fetch/closing-while-fetching-expected.txt (0 => 198665)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/fetch/closing-while-fetching-expected.txt                                (rev 0)
+++ trunk/LayoutTests/http/tests/fetch/closing-while-fetching-expected.txt        2016-03-25 14:19:31 UTC (rev 198665)
</span><span class="lines">@@ -0,0 +1,3 @@
</span><ins>+
+PASS Ensuring that fetch response body promise is not fulfilled when window is closed 
+
</ins></span></pre></div>
<a id="trunkLayoutTestshttptestsfetchclosingwhilefetchinghtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/http/tests/fetch/closing-while-fetching.html (0 => 198665)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/fetch/closing-while-fetching.html                                (rev 0)
+++ trunk/LayoutTests/http/tests/fetch/closing-while-fetching.html        2016-03-25 14:19:31 UTC (rev 198665)
</span><span class="lines">@@ -0,0 +1,33 @@
</span><ins>+&lt;!doctype html&gt;
+&lt;html&gt;
+  &lt;head&gt;
+    &lt;meta charset=&quot;utf-8&quot;&gt;
+    &lt;title&gt;Fetch: retrieve response's body progressively&lt;/title&gt;
+    &lt;meta name=&quot;help&quot; href=&quot;https://fetch.spec.whatwg.org/#main-fetch&quot;&gt;
+    &lt;meta name=&quot;help&quot; href=&quot;https://fetch.spec.whatwg.org/#http-fetch&quot;&gt;
+    &lt;meta name=&quot;author&quot; title=&quot;Canon Research France&quot; href=&quot;https://www.crf.canon.fr&quot;&gt;
+    &lt;script src=&quot;/js-test-resources/testharness.js&quot;&gt;&lt;/script&gt;
+    &lt;script src=&quot;/js-test-resources/testharnessreport.js&quot;&gt;&lt;/script&gt;
+  &lt;/head&gt;
+  &lt;body&gt;
+    &lt;script&gt;
+        
+var test = async_test(&quot;Ensuring that fetch response body promise is not fulfilled when window is closed&quot;);
+test.step(function() {
+    var url = &quot;/resources/download-json-with-delay.php?iteration=5&amp;delay=1000&quot;;
+    fetch(url).then(test.step_func(function(response) {
+        assert_equals(response.status, 200);
+        response.text().then(test.step_func(function(buffer) {
+            assert_unreached();
+        }), test.step_func(function() {
+            assert_unreached();
+        }));
+        setTimeout(function() { test.done(); }, 100);
+    }), test.step_func(function() {
+        assert_unreached();
+    }));
+});
+
+    &lt;/script&gt;
+  &lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestshttptestsfetchgetresponsebodywhileloadingexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/http/tests/fetch/get-response-body-while-loading-expected.txt (0 => 198665)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/fetch/get-response-body-while-loading-expected.txt                                (rev 0)
+++ trunk/LayoutTests/http/tests/fetch/get-response-body-while-loading-expected.txt        2016-03-25 14:19:31 UTC (rev 198665)
</span><span class="lines">@@ -0,0 +1,6 @@
</span><ins>+
+PASS Testing calling Response.text() when still fetching data 
+PASS Testing calling Response.arrayBuffer() when still fetching data 
+PASS Testing calling Response.blob() when still fetching data 
+PASS Testing calling Response.json() when still fetching data 
+
</ins></span></pre></div>
<a id="trunkLayoutTestshttptestsfetchgetresponsebodywhileloadinghtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/http/tests/fetch/get-response-body-while-loading.html (0 => 198665)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/fetch/get-response-body-while-loading.html                                (rev 0)
+++ trunk/LayoutTests/http/tests/fetch/get-response-body-while-loading.html        2016-03-25 14:19:31 UTC (rev 198665)
</span><span class="lines">@@ -0,0 +1,73 @@
</span><ins>+&lt;!doctype html&gt;
+&lt;html&gt;
+  &lt;head&gt;
+    &lt;meta charset=&quot;utf-8&quot;&gt;
+    &lt;title&gt;Fetch: retrieve response's body progressively&lt;/title&gt;
+    &lt;meta name=&quot;help&quot; href=&quot;https://fetch.spec.whatwg.org/#main-fetch&quot;&gt;
+    &lt;meta name=&quot;help&quot; href=&quot;https://fetch.spec.whatwg.org/#http-fetch&quot;&gt;
+    &lt;meta name=&quot;author&quot; title=&quot;Canon Research France&quot; href=&quot;https://www.crf.canon.fr&quot;&gt;
+    &lt;script src=&quot;/js-test-resources/testharness.js&quot;&gt;&lt;/script&gt;
+    &lt;script src=&quot;/js-test-resources/testharnessreport.js&quot;&gt;&lt;/script&gt;
+  &lt;/head&gt;
+  &lt;body&gt;
+    &lt;script&gt;
+
+promise_test(function() {
+    var url = &quot;/resources/download-json-with-delay.php?iteration=5&amp;delay=200&quot;;
+    var loadingFlag = false;
+    return fetch(url).then(function(response) {
+        assert_equals(response.status, 200);
+
+        setTimeout(function() { loadingFlag = true; }, 100);
+        return response.text().then(function(text) {
+            assert_true(loadingFlag, &quot;ensuring that text() was called while loading is happening&quot;);
+            assert_true(text.indexOf(&quot;foobar&quot;) != -1, &quot;text must contain foobar&quot;);
+        });
+    });
+}, &quot;Testing calling Response.text() when still fetching data&quot;);
+
+promise_test(function() {
+    var url = &quot;/resources/download-json-with-delay.php?iteration=5&amp;delay=200&quot;;
+    var loadingFlag = false;
+    return fetch(url).then(function(response) {
+        assert_equals(response.status, 200);
+
+        setTimeout(function() { loadingFlag = true; }, 100);
+        return response.arrayBuffer().then(function(arrayBuffer) {
+            assert_true(arrayBuffer instanceof ArrayBuffer, &quot;object must be an array buffer&quot;);
+            assert_true(loadingFlag, &quot;ensuring that arrayBuffer() was called while loading is happening&quot;);
+        });
+    });
+}, &quot;Testing calling Response.arrayBuffer() when still fetching data&quot;);
+
+promise_test(function() {
+    var url = &quot;/resources/download-json-with-delay.php?iteration=5&amp;delay=200&quot;;
+    var loadingFlag = false;
+    return fetch(url).then(function(response) {
+        assert_equals(response.status, 200);
+
+        setTimeout(function() { loadingFlag = true; }, 100);
+        return response.blob().then(function(blob) {
+            assert_true(blob instanceof Blob, &quot;object must be a blob&quot;);
+            assert_true(loadingFlag, &quot;ensuring that blob() was called while loading is happening&quot;);
+        });
+    });
+}, &quot;Testing calling Response.blob() when still fetching data&quot;);
+
+promise_test(function() {
+    var url = &quot;/resources/download-json-with-delay.php?iteration=5&amp;delay=200&quot;;
+    var loadingFlag = false;
+    return fetch(url).then(function(response) {
+        assert_equals(response.status, 200);
+        
+        setTimeout(function() { loadingFlag = true; }, 100);
+        return response.json().then(function(object) {
+            assert_equals(object.constructor, Array);
+            assert_true(loadingFlag, &quot;ensuring that json() was called while loading is happening&quot;);
+        });
+    });
+}, &quot;Testing calling Response.json() when still fetching data&quot;);
+
+    &lt;/script&gt;
+  &lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestshttptestsresourcesdownloadjsonwithdelayphp"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/http/tests/resources/download-json-with-delay.php (0 => 198665)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/resources/download-json-with-delay.php                                (rev 0)
+++ trunk/LayoutTests/http/tests/resources/download-json-with-delay.php        2016-03-25 14:19:31 UTC (rev 198665)
</span><span class="lines">@@ -0,0 +1,20 @@
</span><ins>+&lt;?php
+header(&quot;Expires: Thu, 01 Dec 2003 16:00:00 GMT&quot;);
+header(&quot;Cache-Control: no-cache, no-store, must-revalidate&quot;);
+header(&quot;Pragma: no-cache&quot;);
+header(&quot;Content-Type: application/x-no-buffering-please&quot;);
+
+$iteration = $_GET['iteration'];
+$delay = $_GET['delay'];
+
+echo &quot;[$iteration, $delay &quot;;
+
+for ($i = 1; $i &lt;= $iteration; ++$i) {
+    echo &quot;, $i, \&quot;foobar\&quot;&quot;;
+    // Force content to be sent to the browser as is.
+    ob_flush();
+    flush();
+    usleep($delay * 1000);
+}
+echo &quot;]&quot;;
+?&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsimportedw3cChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/imported/w3c/ChangeLog (198664 => 198665)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/ChangeLog        2016-03-25 14:08:56 UTC (rev 198664)
+++ trunk/LayoutTests/imported/w3c/ChangeLog        2016-03-25 14:19:31 UTC (rev 198665)
</span><span class="lines">@@ -1,3 +1,29 @@
</span><ins>+2016-03-25  Youenn Fablet  &lt;youenn.fablet@crf.canon.fr&gt;
+
+        [Fetch API] Add basic loading of resources
+        https://bugs.webkit.org/show_bug.cgi?id=155637
+
+        Reviewed by Darin Adler.
+
+        Rebasing test expectations.
+        Updating scheme-blob.js to ensure generated test names are stable run after run.
+
+        * web-platform-tests/fetch/api/basic/accept-header-expected.txt:
+        * web-platform-tests/fetch/api/basic/integrity-expected.txt:
+        * web-platform-tests/fetch/api/basic/mode-no-cors-expected.txt:
+        * web-platform-tests/fetch/api/basic/mode-same-origin-expected.txt:
+        * web-platform-tests/fetch/api/basic/request-forbidden-headers-expected.txt:
+        * web-platform-tests/fetch/api/basic/request-headers-expected.txt:
+        * web-platform-tests/fetch/api/basic/scheme-about-expected.txt:
+        * web-platform-tests/fetch/api/basic/scheme-blob-expected.txt:
+        * web-platform-tests/fetch/api/basic/scheme-blob-worker-expected.txt:
+        * web-platform-tests/fetch/api/basic/scheme-blob.js:
+        (checkFetchResponse): Deleted.
+        (checkKoUrl): Deleted.
+        * web-platform-tests/fetch/api/basic/scheme-data-expected.txt:
+        * web-platform-tests/fetch/api/basic/scheme-others-expected.txt:
+        * web-platform-tests/fetch/api/basic/stream-response-expected.txt:
+
</ins><span class="cx"> 2016-03-24  Commit Queue  &lt;commit-queue@webkit.org&gt;
</span><span class="cx"> 
</span><span class="cx">         Unreviewed, rolling out r198627.
</span></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestsfetchapibasicacceptheaderexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/basic/accept-header-expected.txt (198664 => 198665)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/basic/accept-header-expected.txt        2016-03-25 14:08:56 UTC (rev 198664)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/basic/accept-header-expected.txt        2016-03-25 14:19:31 UTC (rev 198665)
</span><span class="lines">@@ -1,3 +1,3 @@
</span><span class="cx"> 
</span><del>-FAIL Request through fetch should have 'accept' header with value '*/*' promise_test: Unhandled rejection with value: &quot;Fetch is not yet implemented&quot;
</del><ins>+PASS Request through fetch should have 'accept' header with value '*/*' 
</ins><span class="cx"> 
</span></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestsfetchapibasicintegrityexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/basic/integrity-expected.txt (198664 => 198665)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/basic/integrity-expected.txt        2016-03-25 14:08:56 UTC (rev 198664)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/basic/integrity-expected.txt        2016-03-25 14:19:31 UTC (rev 198665)
</span><span class="lines">@@ -1,15 +1,15 @@
</span><span class="cx"> 
</span><del>-FAIL Empty string integrity promise_test: Unhandled rejection with value: &quot;Fetch is not yet implemented&quot;
-FAIL SHA-256 integrity promise_test: Unhandled rejection with value: &quot;Fetch is not yet implemented&quot;
-FAIL SHA-384 integrity promise_test: Unhandled rejection with value: &quot;Fetch is not yet implemented&quot;
-FAIL SHA-512 integrity promise_test: Unhandled rejection with value: &quot;Fetch is not yet implemented&quot;
-FAIL Invalid integrity assert_throws: function &quot;function () { throw e }&quot; threw &quot;Fetch is not yet implemented&quot; (undefined) expected object &quot;TypeError&quot; (&quot;TypeError&quot;)
-FAIL Multiple integrities: valid stronger than invalid promise_test: Unhandled rejection with value: &quot;Fetch is not yet implemented&quot;
-FAIL Multiple integrities: invalid stronger than valid assert_throws: function &quot;function () { throw e }&quot; threw &quot;Fetch is not yet implemented&quot; (undefined) expected object &quot;TypeError&quot; (&quot;TypeError&quot;)
-FAIL Multiple integrities: invalid as strong as valid promise_test: Unhandled rejection with value: &quot;Fetch is not yet implemented&quot;
-FAIL Multiple integrities: both are valid promise_test: Unhandled rejection with value: &quot;Fetch is not yet implemented&quot;
-FAIL Multiple integrities: both are invalid assert_throws: function &quot;function () { throw e }&quot; threw &quot;Fetch is not yet implemented&quot; (undefined) expected object &quot;TypeError&quot; (&quot;TypeError&quot;)
-FAIL CORS empty integrity promise_test: Unhandled rejection with value: &quot;Fetch is not yet implemented&quot;
-FAIL CORS SHA-512 integrity promise_test: Unhandled rejection with value: &quot;Fetch is not yet implemented&quot;
-FAIL CORS invalid integrity assert_throws: function &quot;function () { throw e }&quot; threw &quot;Fetch is not yet implemented&quot; (undefined) expected object &quot;TypeError&quot; (&quot;TypeError&quot;)
</del><ins>+PASS Empty string integrity 
+PASS SHA-256 integrity 
+PASS SHA-384 integrity 
+PASS SHA-512 integrity 
+FAIL Invalid integrity assert_unreached: Should have rejected. Reached unreachable code
+PASS Multiple integrities: valid stronger than invalid 
+FAIL Multiple integrities: invalid stronger than valid assert_unreached: Should have rejected. Reached unreachable code
+PASS Multiple integrities: invalid as strong as valid 
+PASS Multiple integrities: both are valid 
+FAIL Multiple integrities: both are invalid assert_unreached: Should have rejected. Reached unreachable code
+FAIL CORS empty integrity promise_test: Unhandled rejection with value: object &quot;TypeError: Type error&quot;
+FAIL CORS SHA-512 integrity promise_test: Unhandled rejection with value: object &quot;TypeError: Type error&quot;
+PASS CORS invalid integrity 
</ins><span class="cx"> 
</span></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestsfetchapibasicmodenocorsexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/basic/mode-no-cors-expected.txt (198664 => 198665)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/basic/mode-no-cors-expected.txt        2016-03-25 14:08:56 UTC (rev 198664)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/basic/mode-no-cors-expected.txt        2016-03-25 14:19:31 UTC (rev 198665)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx"> 
</span><del>-FAIL Fetch ../resources/top.txt with no-cors mode promise_test: Unhandled rejection with value: &quot;Fetch is not yet implemented&quot;
-FAIL Fetch http://localhost:8800/fetch/api/resources/top.txt with no-cors mode promise_test: Unhandled rejection with value: &quot;Fetch is not yet implemented&quot;
-FAIL Fetch https://localhost:9443/fetch/api/resources/top.txt with no-cors mode promise_test: Unhandled rejection with value: &quot;Fetch is not yet implemented&quot;
-FAIL Fetch http://www.localhost:8800/fetch/api/resources/top.txt with no-cors mode promise_test: Unhandled rejection with value: &quot;Fetch is not yet implemented&quot;
</del><ins>+PASS Fetch ../resources/top.txt with no-cors mode 
+PASS Fetch http://localhost:8800/fetch/api/resources/top.txt with no-cors mode 
+FAIL Fetch https://localhost:9443/fetch/api/resources/top.txt with no-cors mode promise_test: Unhandled rejection with value: object &quot;TypeError: Type error&quot;
+FAIL Fetch http://www.localhost:8800/fetch/api/resources/top.txt with no-cors mode promise_test: Unhandled rejection with value: object &quot;TypeError: Type error&quot;
</ins><span class="cx"> 
</span></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestsfetchapibasicmodesameoriginexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/basic/mode-same-origin-expected.txt (198664 => 198665)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/basic/mode-same-origin-expected.txt        2016-03-25 14:08:56 UTC (rev 198664)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/basic/mode-same-origin-expected.txt        2016-03-25 14:19:31 UTC (rev 198665)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx"> 
</span><del>-FAIL Fetch ../resources/top.txt with same-origin mode promise_test: Unhandled rejection with value: &quot;Fetch is not yet implemented&quot;
-FAIL Fetch http://localhost:8800/fetch/api/resources/top.txt with same-origin mode promise_test: Unhandled rejection with value: &quot;Fetch is not yet implemented&quot;
-FAIL Fetch https://localhost:9443/fetch/api/resources/top.txt with same-origin mode assert_throws: function &quot;function () { throw e }&quot; threw &quot;Fetch is not yet implemented&quot; (undefined) expected object &quot;TypeError&quot; (&quot;TypeError&quot;)
-FAIL Fetch http://www.localhost:8800/fetch/api/resources/top.txt with same-origin mode assert_throws: function &quot;function () { throw e }&quot; threw &quot;Fetch is not yet implemented&quot; (undefined) expected object &quot;TypeError&quot; (&quot;TypeError&quot;)
</del><ins>+PASS Fetch ../resources/top.txt with same-origin mode 
+PASS Fetch http://localhost:8800/fetch/api/resources/top.txt with same-origin mode 
+PASS Fetch https://localhost:9443/fetch/api/resources/top.txt with same-origin mode 
+PASS Fetch http://www.localhost:8800/fetch/api/resources/top.txt with same-origin mode 
</ins><span class="cx"> 
</span></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestsfetchapibasicrequestforbiddenheadersexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/basic/request-forbidden-headers-expected.txt (198664 => 198665)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/basic/request-forbidden-headers-expected.txt        2016-03-25 14:08:56 UTC (rev 198664)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/basic/request-forbidden-headers-expected.txt        2016-03-25 14:19:31 UTC (rev 198665)
</span><span class="lines">@@ -1,26 +1,26 @@
</span><span class="cx"> 
</span><del>-FAIL Accept-Charset is a forbidden request header promise_test: Unhandled rejection with value: &quot;Fetch is not yet implemented&quot;
-FAIL Accept-Encoding is a forbidden request header promise_test: Unhandled rejection with value: &quot;Fetch is not yet implemented&quot;
-FAIL Access-Control-Request-Headers is a forbidden request header promise_test: Unhandled rejection with value: &quot;Fetch is not yet implemented&quot;
-FAIL Access-Control-Request-Method is a forbidden request header promise_test: Unhandled rejection with value: &quot;Fetch is not yet implemented&quot;
-FAIL Connection is a forbidden request header promise_test: Unhandled rejection with value: &quot;Fetch is not yet implemented&quot;
-FAIL Content-Length is a forbidden request header promise_test: Unhandled rejection with value: &quot;Fetch is not yet implemented&quot;
-FAIL Cookie is a forbidden request header promise_test: Unhandled rejection with value: &quot;Fetch is not yet implemented&quot;
-FAIL Cookie2 is a forbidden request header promise_test: Unhandled rejection with value: &quot;Fetch is not yet implemented&quot;
-FAIL Date is a forbidden request header promise_test: Unhandled rejection with value: &quot;Fetch is not yet implemented&quot;
-FAIL DNT is a forbidden request header promise_test: Unhandled rejection with value: &quot;Fetch is not yet implemented&quot;
-FAIL Expect is a forbidden request header promise_test: Unhandled rejection with value: &quot;Fetch is not yet implemented&quot;
-FAIL Host is a forbidden request header promise_test: Unhandled rejection with value: &quot;Fetch is not yet implemented&quot;
-FAIL Keep-Alive is a forbidden request header promise_test: Unhandled rejection with value: &quot;Fetch is not yet implemented&quot;
-FAIL Origin is a forbidden request header promise_test: Unhandled rejection with value: &quot;Fetch is not yet implemented&quot;
-FAIL Referer is a forbidden request header promise_test: Unhandled rejection with value: &quot;Fetch is not yet implemented&quot;
-FAIL TE is a forbidden request header promise_test: Unhandled rejection with value: &quot;Fetch is not yet implemented&quot;
-FAIL Trailer is a forbidden request header promise_test: Unhandled rejection with value: &quot;Fetch is not yet implemented&quot;
-FAIL Transfer-Encoding is a forbidden request header promise_test: Unhandled rejection with value: &quot;Fetch is not yet implemented&quot;
-FAIL Upgrade is a forbidden request header promise_test: Unhandled rejection with value: &quot;Fetch is not yet implemented&quot;
-FAIL Via is a forbidden request header promise_test: Unhandled rejection with value: &quot;Fetch is not yet implemented&quot;
-FAIL Proxy- is a forbidden request header promise_test: Unhandled rejection with value: &quot;Fetch is not yet implemented&quot;
-FAIL Proxy-Test is a forbidden request header promise_test: Unhandled rejection with value: &quot;Fetch is not yet implemented&quot;
-FAIL Sec- is a forbidden request header promise_test: Unhandled rejection with value: &quot;Fetch is not yet implemented&quot;
-FAIL Sec-Test is a forbidden request header promise_test: Unhandled rejection with value: &quot;Fetch is not yet implemented&quot;
</del><ins>+PASS Accept-Charset is a forbidden request header 
+PASS Accept-Encoding is a forbidden request header 
+PASS Access-Control-Request-Headers is a forbidden request header 
+PASS Access-Control-Request-Method is a forbidden request header 
+PASS Connection is a forbidden request header 
+PASS Content-Length is a forbidden request header 
+PASS Cookie is a forbidden request header 
+PASS Cookie2 is a forbidden request header 
+PASS Date is a forbidden request header 
+PASS DNT is a forbidden request header 
+PASS Expect is a forbidden request header 
+PASS Host is a forbidden request header 
+PASS Keep-Alive is a forbidden request header 
+PASS Origin is a forbidden request header 
+PASS Referer is a forbidden request header 
+PASS TE is a forbidden request header 
+PASS Trailer is a forbidden request header 
+PASS Transfer-Encoding is a forbidden request header 
+PASS Upgrade is a forbidden request header 
+PASS Via is a forbidden request header 
+PASS Proxy- is a forbidden request header 
+PASS Proxy-Test is a forbidden request header 
+PASS Sec- is a forbidden request header 
+PASS Sec-Test is a forbidden request header 
</ins><span class="cx"> 
</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 (198664 => 198665)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/basic/request-headers-expected.txt        2016-03-25 14:08:56 UTC (rev 198664)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/basic/request-headers-expected.txt        2016-03-25 14:19:31 UTC (rev 198665)
</span><span class="lines">@@ -1,11 +1,11 @@
</span><span class="cx"> 
</span><del>-FAIL Fetch with GET promise_test: Unhandled rejection with value: &quot;Fetch is not yet implemented&quot;
-FAIL Fetch with HEAD promise_test: Unhandled rejection with value: &quot;Fetch is not yet implemented&quot;
-FAIL Fetch with HEAD with body promise_test: Unhandled rejection with value: &quot;Fetch is not yet implemented&quot;
-FAIL Fetch with PUT without body promise_test: Unhandled rejection with value: &quot;Fetch is not yet implemented&quot;
-FAIL Fetch with PUT with body promise_test: Unhandled rejection with value: &quot;Fetch is not yet implemented&quot;
-FAIL Fetch with POST without body promise_test: Unhandled rejection with value: &quot;Fetch is not yet implemented&quot;
-FAIL Fetch with POST with body promise_test: Unhandled rejection with value: &quot;Fetch is not yet implemented&quot;
-FAIL Fetch with Chicken promise_test: Unhandled rejection with value: &quot;Fetch is not yet implemented&quot;
-FAIL Fetch with Chicken with body promise_test: Unhandled rejection with value: &quot;Fetch is not yet implemented&quot;
</del><ins>+FAIL Fetch with GET assert_equals: Request has header origin: http://localhost:8800 expected (string) &quot;http://localhost:8800&quot; but got (object) null
+FAIL Fetch with HEAD assert_equals: Request has header origin: http://localhost:8800 expected (string) &quot;http://localhost:8800&quot; but got (object) null
+FAIL Fetch with HEAD with body promise_test: Unhandled rejection with value: object &quot;TypeError: Type error&quot;
+PASS Fetch with PUT without body 
+PASS Fetch with PUT with body 
+PASS Fetch with POST without body 
+PASS Fetch with POST with body 
+FAIL Fetch with Chicken assert_equals: Request has header content-length: null expected (object) null but got (string) &quot;0&quot;
+PASS Fetch with Chicken with body 
</ins><span class="cx"> 
</span></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestsfetchapibasicschemeaboutexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/basic/scheme-about-expected.txt (198664 => 198665)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/basic/scheme-about-expected.txt        2016-03-25 14:08:56 UTC (rev 198664)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/basic/scheme-about-expected.txt        2016-03-25 14:19:31 UTC (rev 198665)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx"> 
</span><del>-FAIL Fetching about:blank is OK promise_test: Unhandled rejection with value: &quot;Fetch is not yet implemented&quot;
-FAIL Fetching about:unicorn is OK promise_test: Unhandled rejection with value: &quot;Fetch is not yet implemented&quot;
-FAIL Fetching about:invalid.com is KO assert_throws: function &quot;function () { throw e }&quot; threw &quot;Fetch is not yet implemented&quot; (undefined) expected object &quot;TypeError&quot; (&quot;TypeError&quot;)
-FAIL Fetching about:config is KO assert_throws: function &quot;function () { throw e }&quot; threw &quot;Fetch is not yet implemented&quot; (undefined) expected object &quot;TypeError&quot; (&quot;TypeError&quot;)
</del><ins>+FAIL Fetching about:blank is OK promise_test: Unhandled rejection with value: object &quot;TypeError: Type error&quot;
+FAIL Fetching about:unicorn is OK promise_test: Unhandled rejection with value: object &quot;TypeError: Type error&quot;
+PASS Fetching about:invalid.com is KO 
+PASS Fetching about:config is KO 
</ins><span class="cx"> 
</span></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestsfetchapibasicschemeblobexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/basic/scheme-blob-expected.txt (198664 => 198665)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/basic/scheme-blob-expected.txt        2016-03-25 14:08:56 UTC (rev 198664)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/basic/scheme-blob-expected.txt        2016-03-25 14:19:31 UTC (rev 198665)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> 
</span><del>-FAIL Fetching blob:http://localhost:8800/4580501e-3c0f-4b03[...] is OK promise_test: Unhandled rejection with value: &quot;Fetch is not yet implemented&quot;
-FAIL Fetching [GET] blob:http://www.localhost:8800/ is KO assert_throws: function &quot;function () { throw e }&quot; threw &quot;Fetch is not yet implemented&quot; (undefined) expected object &quot;TypeError&quot; (&quot;TypeError&quot;)
-FAIL Fetching [POST] blob:http://localhost:8800/ad829fe3-9045-4b29[...] is KO assert_throws: function &quot;function () { throw e }&quot; threw &quot;Fetch is not yet implemented&quot; (undefined) expected object &quot;TypeError&quot; (&quot;TypeError&quot;)
</del><ins>+PASS Regular Blob loading 
+PASS Loading an erroneous blob scheme URL 
+FAIL Loading a blob URL using POST assert_unreached: Should have rejected. Reached unreachable code
</ins><span class="cx"> 
</span></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestsfetchapibasicschemeblobworkerexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/basic/scheme-blob-worker-expected.txt (198664 => 198665)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/basic/scheme-blob-worker-expected.txt        2016-03-25 14:08:56 UTC (rev 198664)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/basic/scheme-blob-worker-expected.txt        2016-03-25 14:19:31 UTC (rev 198665)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> 
</span><del>-FAIL Fetching blob:http://localhost:8800/8807dca8-91bf-4414[...] is OK promise_test: Unhandled rejection with value: &quot;Fetch is not yet implemented&quot;
-FAIL Fetching [GET] blob:http://www.localhost:8800/ is KO assert_throws: function &quot;function () { throw e }&quot; threw &quot;Fetch is not yet implemented&quot; (undefined) expected object &quot;TypeError&quot; (&quot;TypeError&quot;)
-FAIL Fetching [POST] blob:http://localhost:8800/41805be3-d8cc-490f[...] is KO assert_throws: function &quot;function () { throw e }&quot; threw &quot;Fetch is not yet implemented&quot; (undefined) expected object &quot;TypeError&quot; (&quot;TypeError&quot;)
</del><ins>+FAIL Regular Blob loading promise_test: Unhandled rejection with value: &quot;Fetch is not yet implemented&quot;
+FAIL Loading an erroneous blob scheme URL assert_throws: function &quot;function () { throw e }&quot; threw &quot;Fetch is not yet implemented&quot; (undefined) expected object &quot;TypeError&quot; (&quot;TypeError&quot;)
+FAIL Loading a blob URL using POST assert_throws: function &quot;function () { throw e }&quot; threw &quot;Fetch is not yet implemented&quot; (undefined) expected object &quot;TypeError&quot; (&quot;TypeError&quot;)
</ins><span class="cx"> 
</span></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestsfetchapibasicschemeblobjs"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/basic/scheme-blob.js (198664 => 198665)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/basic/scheme-blob.js        2016-03-25 14:08:56 UTC (rev 198664)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/basic/scheme-blob.js        2016-03-25 14:19:31 UTC (rev 198665)
</span><span class="lines">@@ -4,9 +4,6 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> function checkFetchResponse(url, data, mime, size, desc) {
</span><del>-  if (!desc)
-    var cut = (url.length &gt;= 45) ? &quot;[...]&quot; : &quot;&quot;;
-    desc = &quot;Fetching &quot; + url.substring(0, 45) + cut + &quot; is OK&quot;
</del><span class="cx">   promise_test(function(test) {
</span><span class="cx">     size = size.toString();
</span><span class="cx">     return fetch(url).then(function(resp) {
</span><span class="lines">@@ -22,12 +19,9 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> var blob = new Blob([&quot;Blob's data&quot;], { &quot;type&quot; : &quot;text/plain&quot; });
</span><del>-checkFetchResponse(URL.createObjectURL(blob), &quot;Blob's data&quot;, &quot;text/plain&quot;,  blob.size);
</del><ins>+checkFetchResponse(URL.createObjectURL(blob), &quot;Blob's data&quot;, &quot;text/plain&quot;,  blob.size, &quot;Regular Blob loading&quot;);
</ins><span class="cx"> 
</span><span class="cx"> function checkKoUrl(url, method, desc) {
</span><del>-  if (!desc)
-    var cut = (url.length &gt;= 45) ? &quot;[...]&quot; : &quot;&quot;;
-    desc = &quot;Fetching [&quot; + method + &quot;] &quot; + url.substring(0, 45) + cut +  &quot; is KO&quot;
</del><span class="cx">   promise_test(function(test) {
</span><span class="cx">     var promise = fetch(url, {&quot;method&quot;: method});
</span><span class="cx">     return promise_rejects(test, new TypeError(), promise);
</span><span class="lines">@@ -35,7 +29,7 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> var blob2 = new Blob([&quot;Blob's data&quot;], { &quot;type&quot; : &quot;text/plain&quot; });
</span><del>-checkKoUrl(&quot;blob:http://{{domains[www]}}:{{ports[http][0]}}/&quot;, &quot;GET&quot;);
-checkKoUrl(URL.createObjectURL(blob2), &quot;POST&quot;);
</del><ins>+checkKoUrl(&quot;blob:http://{{domains[www]}}:{{ports[http][0]}}/&quot;, &quot;GET&quot;, &quot;Loading an erroneous blob scheme URL&quot;);
+checkKoUrl(URL.createObjectURL(blob2), &quot;POST&quot;, &quot;Loading a blob URL using POST&quot;);
</ins><span class="cx"> 
</span><span class="cx"> done();
</span></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestsfetchapibasicschemedataexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/basic/scheme-data-expected.txt (198664 => 198665)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/basic/scheme-data-expected.txt        2016-03-25 14:08:56 UTC (rev 198664)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/basic/scheme-data-expected.txt        2016-03-25 14:19:31 UTC (rev 198665)
</span><span class="lines">@@ -1,8 +1,8 @@
</span><span class="cx"> 
</span><del>-FAIL Fetching data:,response%27s%20body is OK promise_test: Unhandled rejection with value: &quot;Fetch is not yet implemented&quot;
-FAIL Fetching data:text/plain;base64,cmVzcG9uc2UncyBib[...] is OK promise_test: Unhandled rejection with value: &quot;Fetch is not yet implemented&quot;
-FAIL Fetching data:image/png;base64,cmVzcG9uc2UncyBib2[...] is OK promise_test: Unhandled rejection with value: &quot;Fetch is not yet implemented&quot;
-FAIL Fetching [GET] data:notAdataUrl.com is KO assert_throws: function &quot;function () { throw e }&quot; threw &quot;Fetch is not yet implemented&quot; (undefined) expected object &quot;TypeError&quot; (&quot;TypeError&quot;)
-FAIL Fetching [POST] data:,response%27s%20body is KO assert_throws: function &quot;function () { throw e }&quot; threw &quot;Fetch is not yet implemented&quot; (undefined) expected object &quot;TypeError&quot; (&quot;TypeError&quot;)
-FAIL Fetching [HEAD] data:,response%27s%20body is KO assert_throws: function &quot;function () { throw e }&quot; threw &quot;Fetch is not yet implemented&quot; (undefined) expected object &quot;TypeError&quot; (&quot;TypeError&quot;)
</del><ins>+FAIL Fetching data:,response%27s%20body is OK promise_test: Unhandled rejection with value: object &quot;TypeError: Type error&quot;
+FAIL Fetching data:text/plain;base64,cmVzcG9uc2UncyBib[...] is OK promise_test: Unhandled rejection with value: object &quot;TypeError: Type error&quot;
+FAIL Fetching data:image/png;base64,cmVzcG9uc2UncyBib2[...] is OK promise_test: Unhandled rejection with value: object &quot;TypeError: Type error&quot;
+PASS Fetching [GET] data:notAdataUrl.com is KO 
+PASS Fetching [POST] data:,response%27s%20body is KO 
+PASS Fetching [HEAD] data:,response%27s%20body is KO 
</ins><span class="cx"> 
</span></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestsfetchapibasicschemeothersexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/basic/scheme-others-expected.txt (198664 => 198665)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/basic/scheme-others-expected.txt        2016-03-25 14:08:56 UTC (rev 198664)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/basic/scheme-others-expected.txt        2016-03-25 14:19:31 UTC (rev 198665)
</span><span class="lines">@@ -1,18 +1,18 @@
</span><span class="cx"> 
</span><del>-FAIL Fetching aaa://localhost:8800/ is KO assert_throws: function &quot;function () { throw e }&quot; threw &quot;Fetch is not yet implemented&quot; (undefined) expected object &quot;TypeError&quot; (&quot;TypeError&quot;)
-FAIL Fetching cap://localhost:8800/ is KO assert_throws: function &quot;function () { throw e }&quot; threw &quot;Fetch is not yet implemented&quot; (undefined) expected object &quot;TypeError&quot; (&quot;TypeError&quot;)
-FAIL Fetching cid://localhost:8800/ is KO assert_throws: function &quot;function () { throw e }&quot; threw &quot;Fetch is not yet implemented&quot; (undefined) expected object &quot;TypeError&quot; (&quot;TypeError&quot;)
-FAIL Fetching dav://localhost:8800/ is KO assert_throws: function &quot;function () { throw e }&quot; threw &quot;Fetch is not yet implemented&quot; (undefined) expected object &quot;TypeError&quot; (&quot;TypeError&quot;)
-FAIL Fetching dict://localhost:8800/ is KO assert_throws: function &quot;function () { throw e }&quot; threw &quot;Fetch is not yet implemented&quot; (undefined) expected object &quot;TypeError&quot; (&quot;TypeError&quot;)
-FAIL Fetching dns://localhost:8800/ is KO assert_throws: function &quot;function () { throw e }&quot; threw &quot;Fetch is not yet implemented&quot; (undefined) expected object &quot;TypeError&quot; (&quot;TypeError&quot;)
-FAIL Fetching geo://localhost:8800/ is KO assert_throws: function &quot;function () { throw e }&quot; threw &quot;Fetch is not yet implemented&quot; (undefined) expected object &quot;TypeError&quot; (&quot;TypeError&quot;)
-FAIL Fetching im://localhost:8800/ is KO assert_throws: function &quot;function () { throw e }&quot; threw &quot;Fetch is not yet implemented&quot; (undefined) expected object &quot;TypeError&quot; (&quot;TypeError&quot;)
-FAIL Fetching imap://localhost:8800/ is KO assert_throws: function &quot;function () { throw e }&quot; threw &quot;Fetch is not yet implemented&quot; (undefined) expected object &quot;TypeError&quot; (&quot;TypeError&quot;)
-FAIL Fetching ipp://localhost:8800/ is KO assert_throws: function &quot;function () { throw e }&quot; threw &quot;Fetch is not yet implemented&quot; (undefined) expected object &quot;TypeError&quot; (&quot;TypeError&quot;)
-FAIL Fetching ldap://localhost:8800/ is KO assert_throws: function &quot;function () { throw e }&quot; threw &quot;Fetch is not yet implemented&quot; (undefined) expected object &quot;TypeError&quot; (&quot;TypeError&quot;)
-FAIL Fetching mailto://localhost:8800/ is KO assert_throws: function &quot;function () { throw e }&quot; threw &quot;Fetch is not yet implemented&quot; (undefined) expected object &quot;TypeError&quot; (&quot;TypeError&quot;)
-FAIL Fetching nfs://localhost:8800/ is KO assert_throws: function &quot;function () { throw e }&quot; threw &quot;Fetch is not yet implemented&quot; (undefined) expected object &quot;TypeError&quot; (&quot;TypeError&quot;)
-FAIL Fetching pop://localhost:8800/ is KO assert_throws: function &quot;function () { throw e }&quot; threw &quot;Fetch is not yet implemented&quot; (undefined) expected object &quot;TypeError&quot; (&quot;TypeError&quot;)
-FAIL Fetching rtsp://localhost:8800/ is KO assert_throws: function &quot;function () { throw e }&quot; threw &quot;Fetch is not yet implemented&quot; (undefined) expected object &quot;TypeError&quot; (&quot;TypeError&quot;)
-FAIL Fetching snmp://localhost:8800/ is KO assert_throws: function &quot;function () { throw e }&quot; threw &quot;Fetch is not yet implemented&quot; (undefined) expected object &quot;TypeError&quot; (&quot;TypeError&quot;)
</del><ins>+PASS Fetching aaa://localhost:8800/ is KO 
+PASS Fetching cap://localhost:8800/ is KO 
+PASS Fetching cid://localhost:8800/ is KO 
+PASS Fetching dav://localhost:8800/ is KO 
+PASS Fetching dict://localhost:8800/ is KO 
+PASS Fetching dns://localhost:8800/ is KO 
+PASS Fetching geo://localhost:8800/ is KO 
+PASS Fetching im://localhost:8800/ is KO 
+PASS Fetching imap://localhost:8800/ is KO 
+PASS Fetching ipp://localhost:8800/ is KO 
+PASS Fetching ldap://localhost:8800/ is KO 
+PASS Fetching mailto://localhost:8800/ is KO 
+PASS Fetching nfs://localhost:8800/ is KO 
+PASS Fetching pop://localhost:8800/ is KO 
+PASS Fetching rtsp://localhost:8800/ is KO 
+PASS Fetching snmp://localhost:8800/ is KO 
</ins><span class="cx"> 
</span></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestsfetchapibasicstreamresponseexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/basic/stream-response-expected.txt (198664 => 198665)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/basic/stream-response-expected.txt        2016-03-25 14:08:56 UTC (rev 198664)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/basic/stream-response-expected.txt        2016-03-25 14:19:31 UTC (rev 198665)
</span><span class="lines">@@ -1,3 +1,3 @@
</span><span class="cx"> 
</span><del>-FAIL Stream response's body promise_test: Unhandled rejection with value: &quot;Fetch is not yet implemented&quot;
</del><ins>+FAIL Stream response's body assert_unreached: Body does not exist in response Reached unreachable code
</ins><span class="cx"> 
</span></span></pre></div>
<a id="trunkLayoutTestsplatformgtkimportedw3cwebplatformtestsfetchapibasicrequestheadersexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/platform/gtk/imported/w3c/web-platform-tests/fetch/api/basic/request-headers-expected.txt (0 => 198665)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/platform/gtk/imported/w3c/web-platform-tests/fetch/api/basic/request-headers-expected.txt                                (rev 0)
+++ trunk/LayoutTests/platform/gtk/imported/w3c/web-platform-tests/fetch/api/basic/request-headers-expected.txt        2016-03-25 14:19:31 UTC (rev 198665)
</span><span class="lines">@@ -0,0 +1,11 @@
</span><ins>+
+FAIL Fetch with GET assert_equals: Request has header origin: http://localhost:8800 expected (string) &quot;http://localhost:8800&quot; but got (object) null
+FAIL Fetch with HEAD assert_equals: Request has header origin: http://localhost:8800 expected (string) &quot;http://localhost:8800&quot; but got (object) null
+FAIL Fetch with HEAD with body promise_test: Unhandled rejection with value: object &quot;TypeError: Type error&quot;
+PASS Fetch with PUT without body 
+PASS Fetch with PUT with body 
+PASS Fetch with POST without body 
+PASS Fetch with POST with body 
+PASS Fetch with Chicken 
+PASS Fetch with Chicken with body 
+
</ins></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (198664 => 198665)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2016-03-25 14:08:56 UTC (rev 198664)
+++ trunk/Source/WebCore/ChangeLog        2016-03-25 14:19:31 UTC (rev 198665)
</span><span class="lines">@@ -1,3 +1,74 @@
</span><ins>+2016-03-25  Youenn Fablet  &lt;youenn.fablet@crf.canon.fr&gt;
+
+        [Fetch API] Add basic loading of resources
+        https://bugs.webkit.org/show_bug.cgi?id=155637
+
+        Reviewed by Darin Adler.
+
+        Adding support for basic fetch for Window (no support for Worker yet).
+        A FetchResponse object is created for every fetch task.
+        But it will only be exposed to JS at promise fulfillment time, i.e. once initial response headers are retrieved.
+
+        Updating Blob resource handle to add Content-Type and Content-Length header and notifying of error in case of erroneous HTTP method.
+
+        Fetch is limited to same origin requests currently due to some WPT tests that would timeout otherwise.
+
+        Tests: http/tests/fetch/closing-while-fetching.html
+               http/tests/fetch/get-response-body-while-loading.html
+        Also covered by rebased tests.
+
+        * Modules/fetch/DOMWindowFetch.cpp: Creating a FetchResponse to start fetching.
+        (WebCore::DOMWindowFetch::fetch):
+        * Modules/fetch/DOMWindowFetch.h:
+        * Modules/fetch/FetchBody.cpp:
+        (WebCore::FetchBody::consume):
+        (WebCore::FetchBody::consumeArrayBuffer): Handling of body promises in case of data stored as a buffer.
+        (WebCore::FetchBody::consumeText): Passing the promise as a reference.
+        (WebCore::blobFromArrayBuffer): Helper routine.
+        (WebCore::FetchBody::fulfillTextPromise): Helper routine.
+        (WebCore::FetchBody::loadedAsArrayBuffer): Updated to handle storing of data as a buffer.
+        (WebCore::FetchBody::loadedAsText):
+        (WebCore::FetchBody::bodyForInternalRequest): Helper routine to generate the request body data to be sent as part of the fetch request.
+        (WebCore::FetchBody::extractFromText):
+        * Modules/fetch/FetchBody.h:
+        (WebCore::FetchBody::loadingBody):
+        (WebCore::FetchBody::FetchBody):
+        * Modules/fetch/FetchBodyOwner.cpp:
+        (WebCore::FetchBodyOwner::loadBlob): Updated to cope with the change that FetchLoader::start does not return a boolean anymore
+        but will directly call failure callbacks.
+        (WebCore::FetchBodyOwner::loadedBlobAsText): Moving it closer to other blob loading routines.
+        (WebCore::FetchBodyOwner::finishBlobLoading):
+        * Modules/fetch/FetchBodyOwner.h:
+        (WebCore::FetchBodyOwner::body):
+        (WebCore::FetchBodyOwner::loadedBlobAsArrayBuffer):
+        * Modules/fetch/FetchHeaders.cpp:
+        (WebCore::FetchHeaders::fill):
+        (WebCore::FetchHeaders::filterAndFill): Helper routine to fill headers from a HTTPHeaderMap after being filtered.
+        * Modules/fetch/FetchHeaders.h:
+        (WebCore::FetchHeaders::internalHeaders):
+        * Modules/fetch/FetchLoader.cpp:
+        (WebCore::FetchLoader::start):
+        (WebCore::FetchLoader::didFailRedirectCheck):
+        * Modules/fetch/FetchLoader.h:
+        * Modules/fetch/FetchRequest.cpp:
+        (WebCore::FetchRequest::internalRequest): Routine used to create the ResourceRequest transmitted to ThreadableLoader.
+       * Modules/fetch/FetchRequest.h:
+        * Modules/fetch/FetchResponse.cpp:
+        (WebCore::FetchResponse::fetch): Start fetching by creating a FetchLoader based on passed request.
+        (WebCore::FetchResponse::BodyLoader::didSucceed): FetchLoader callback.
+        (WebCore::FetchResponse::BodyLoader::didFail): Ditto.
+        (WebCore::FetchResponse::BodyLoader::BodyLoader): Ditto.
+        (WebCore::FetchResponse::BodyLoader::didReceiveResponse): Ditto.
+        (WebCore::FetchResponse::BodyLoader::didFinishLoadingAsArrayBuffer): Ditto.
+        (WebCore::FetchResponse::BodyLoader::start): Starting fetch loader.
+        (WebCore::FetchResponse::BodyLoader::stop): Stopping fetch loader.
+        (WebCore::FetchResponse::stop): Stop loader if any.
+        * Modules/fetch/FetchResponse.h:
+        * platform/network/BlobResourceHandle.cpp:
+        (WebCore::BlobResourceHandle::doStart: Notifying the loader with an error if verb is not GET.
+        (WebCore::BlobResourceHandle::notifyResponseOnSuccess): Adding support for Content-Type and Content-Lenth headers.
+        (WebCore::BlobResourceHandle::createAsync): Removing GET verb check.
+
</ins><span class="cx"> 2016-03-25  Konstantin Tokarev  &lt;annulen@yandex.ru&gt;
</span><span class="cx"> 
</span><span class="cx">         Removed leftovers of WCHAR_UNICODE code path after r162782.
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesfetchDOMWindowFetchcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/fetch/DOMWindowFetch.cpp (198664 => 198665)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/fetch/DOMWindowFetch.cpp        2016-03-25 14:08:56 UTC (rev 198664)
+++ trunk/Source/WebCore/Modules/fetch/DOMWindowFetch.cpp        2016-03-25 14:19:31 UTC (rev 198665)
</span><span class="lines">@@ -31,16 +31,42 @@
</span><span class="cx"> 
</span><span class="cx"> #if ENABLE(FETCH_API)
</span><span class="cx"> 
</span><ins>+#include &quot;DOMWindow.h&quot;
+#include &quot;FetchRequest.h&quot;
+#include &quot;FetchResponse.h&quot;
+
</ins><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><del>-void DOMWindowFetch::fetch(DOMWindow&amp;, FetchRequest*, const Dictionary&amp;, FetchPromise&amp;&amp; promise)
</del><ins>+void DOMWindowFetch::fetch(DOMWindow&amp; window, FetchRequest* input, const Dictionary&amp; dictionary, DeferredWrapper&amp;&amp; promise)
</ins><span class="cx"> {
</span><del>-    promise.reject(ASCIILiteral(&quot;Fetch is not yet implemented&quot;));
</del><ins>+    if (!window.scriptExecutionContext())
+        return;
+    ScriptExecutionContext&amp; context = *window.scriptExecutionContext();
+
+    ExceptionCode ec = 0;
+    RefPtr&lt;FetchRequest&gt; fetchRequest = FetchRequest::create(context, input, dictionary, ec);
+    if (ec) {
+        promise.reject(ec);
+        return;
+    }
+    ASSERT(fetchRequest);
+    FetchResponse::fetch(context, *fetchRequest, WTFMove(promise));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-void DOMWindowFetch::fetch(DOMWindow&amp;, const String&amp;, const Dictionary&amp;, FetchPromise&amp;&amp; promise)
</del><ins>+void DOMWindowFetch::fetch(DOMWindow&amp; window, const String&amp; url, const Dictionary&amp; dictionary, DeferredWrapper&amp;&amp; promise)
</ins><span class="cx"> {
</span><del>-    promise.reject(ASCIILiteral(&quot;Fetch is not yet implemented&quot;));
</del><ins>+    if (!window.scriptExecutionContext())
+        return;
+    ScriptExecutionContext&amp; context = *window.scriptExecutionContext();
+    
+    ExceptionCode ec = 0;
+    RefPtr&lt;FetchRequest&gt; fetchRequest = FetchRequest::create(context, url, dictionary, ec);
+    if (ec) {
+        promise.reject(ec);
+        return;
+    }
+    ASSERT(fetchRequest);
+    FetchResponse::fetch(context, *fetchRequest, WTFMove(promise));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> } // namespace WebCore
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesfetchDOMWindowFetchh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/fetch/DOMWindowFetch.h (198664 => 198665)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/fetch/DOMWindowFetch.h        2016-03-25 14:08:56 UTC (rev 198664)
+++ trunk/Source/WebCore/Modules/fetch/DOMWindowFetch.h        2016-03-25 14:19:31 UTC (rev 198665)
</span><span class="lines">@@ -30,19 +30,19 @@
</span><span class="cx"> 
</span><span class="cx"> #if ENABLE(FETCH_API)
</span><span class="cx"> 
</span><del>-#include &quot;JSDOMPromise.h&quot;
</del><ins>+#include &lt;wtf/Forward.h&gt;
</ins><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><ins>+class DOMWindow;
+class DeferredWrapper;
</ins><span class="cx"> class Dictionary;
</span><span class="cx"> class FetchRequest;
</span><del>-class FetchResponse;
</del><span class="cx"> 
</span><span class="cx"> class DOMWindowFetch {
</span><span class="cx"> public:
</span><del>-    using FetchPromise = DOMPromise&lt;RefPtr&lt;FetchResponse&gt;, String&gt;;
-    static void fetch(DOMWindow&amp;, FetchRequest*, const Dictionary&amp;, FetchPromise&amp;&amp;);
-    static void fetch(DOMWindow&amp;, const String&amp;, const Dictionary&amp;, FetchPromise&amp;&amp;);
</del><ins>+    static void fetch(DOMWindow&amp;, FetchRequest*, const Dictionary&amp;, DeferredWrapper&amp;&amp;);
+    static void fetch(DOMWindow&amp;, const String&amp;, const Dictionary&amp;, DeferredWrapper&amp;&amp;);
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> } // namespace WebCore
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesfetchFetchBodycpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/fetch/FetchBody.cpp (198664 => 198665)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/fetch/FetchBody.cpp        2016-03-25 14:08:56 UTC (rev 198664)
+++ trunk/Source/WebCore/Modules/fetch/FetchBody.cpp        2016-03-25 14:19:31 UTC (rev 198665)
</span><span class="lines">@@ -35,12 +35,15 @@
</span><span class="cx"> #include &quot;Dictionary.h&quot;
</span><span class="cx"> #include &quot;ExceptionCode.h&quot;
</span><span class="cx"> #include &quot;FetchBodyOwner.h&quot;
</span><ins>+#include &quot;FormData.h&quot;
</ins><span class="cx"> #include &quot;HTTPParsers.h&quot;
</span><span class="cx"> #include &quot;JSBlob.h&quot;
</span><span class="cx"> #include &quot;JSDOMFormData.h&quot;
</span><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><ins>+static RefPtr&lt;Blob&gt; blobFromArrayBuffer(ArrayBuffer*, const String&amp;);
+
</ins><span class="cx"> FetchBody::FetchBody(Ref&lt;Blob&gt;&amp;&amp; blob)
</span><span class="cx">     : m_type(Type::Blob)
</span><span class="cx">     , m_mimeType(blob-&gt;type())
</span><span class="lines">@@ -155,21 +158,46 @@
</span><span class="cx"> 
</span><span class="cx"> void FetchBody::consume(FetchBodyOwner&amp; owner, Consumer::Type type, DeferredWrapper&amp;&amp; promise)
</span><span class="cx"> {
</span><ins>+    if (m_type == Type::ArrayBuffer) {
+        consumeArrayBuffer(type, promise);
+        return;
+    }
</ins><span class="cx">     if (m_type == Type::Text) {
</span><del>-        consumeText(type, WTFMove(promise));
</del><ins>+        consumeText(type, promise);
</ins><span class="cx">         return;
</span><span class="cx">     }
</span><span class="cx">     if (m_type == Type::Blob) {
</span><span class="cx">         consumeBlob(owner, type, WTFMove(promise));
</span><span class="cx">         return;
</span><span class="cx">     }
</span><ins>+    if (m_type == Type::Loading) {
+        // FIXME: We should be able to change the loading type to text if consumer type is JSON or Text.
+        m_consumer = Consumer({type, WTFMove(promise)});
+        return;
+    }
</ins><span class="cx"> 
</span><span class="cx">     // FIXME: Support other types.
</span><span class="cx">     promise.reject&lt;ExceptionCode&gt;(0);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void FetchBody::consumeText(Consumer::Type type, DeferredWrapper&amp;&amp; promise)
</del><ins>+void FetchBody::consumeArrayBuffer(Consumer::Type type, DeferredWrapper&amp; promise)
</ins><span class="cx"> {
</span><ins>+    if (type == Consumer::Type::ArrayBuffer) {
+        fulfillPromiseWithArrayBuffer(promise, m_data.get());
+        return;
+    }
+    if (type == Consumer::Type::Blob) {
+        promise.resolve(blobFromArrayBuffer(m_data.get(), Blob::normalizedContentType(extractMIMETypeFromMediaType(m_mimeType))));
+        return;
+    }
+
+    ASSERT(type == Consumer::Type::Text || type == Consumer::Type::JSON);
+    // FIXME: Do we need TextResourceDecoder to create a String to decode UTF-8 data.
+    fulfillTextPromise(type, TextResourceDecoder::create(ASCIILiteral(&quot;text/plain&quot;), &quot;UTF-8&quot;)-&gt;decodeAndFlush(static_cast&lt;const char*&gt;(m_data-&gt;data()), m_data-&gt;byteLength()), promise);
+}
+
+void FetchBody::consumeText(Consumer::Type type, DeferredWrapper&amp; promise)
+{
</ins><span class="cx">     ASSERT(type == Consumer::Type::ArrayBuffer || type == Consumer::Type::Blob);
</span><span class="cx"> 
</span><span class="cx">     if (type == Consumer::Type::ArrayBuffer) {
</span><span class="lines">@@ -214,6 +242,26 @@
</span><span class="cx">     return value;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+static inline RefPtr&lt;Blob&gt; blobFromArrayBuffer(ArrayBuffer* buffer, const String&amp; contentType)
+{
+    if (!buffer)
+        return Blob::create(Vector&lt;char&gt;(), contentType);
+
+    // FIXME: We should try to move buffer to Blob without doing this copy.
+    Vector&lt;char&gt; value(buffer-&gt;byteLength());
+    memcpy(value.data(), buffer-&gt;data(), buffer-&gt;byteLength());
+    return Blob::create(WTFMove(value), contentType);
+}
+
+void FetchBody::fulfillTextPromise(FetchBody::Consumer::Type type, const String&amp; text, DeferredWrapper&amp; promise)
+{
+    ASSERT(type == Consumer::Type::Text || type == Consumer::Type::JSON);
+    if (type == FetchBody::Consumer::Type::Text)
+        promise.resolve(text);
+    else
+        fulfillPromiseWithJSON(promise, text);
+}
+
</ins><span class="cx"> void FetchBody::loadingFailed()
</span><span class="cx"> {
</span><span class="cx">     ASSERT(m_consumer);
</span><span class="lines">@@ -223,16 +271,23 @@
</span><span class="cx"> 
</span><span class="cx"> void FetchBody::loadedAsArrayBuffer(RefPtr&lt;ArrayBuffer&gt;&amp;&amp; buffer)
</span><span class="cx"> {
</span><ins>+    if (m_type == Type::Loading) {
+        m_type = Type::ArrayBuffer;
+        m_data = buffer;
+        if (m_consumer) {
+            consumeArrayBuffer(m_consumer-&gt;type, m_consumer-&gt;promise);
+            m_consumer = Nullopt;
+        }
+        return;
+    }
+
</ins><span class="cx">     ASSERT(m_consumer);
</span><span class="cx">     ASSERT(m_consumer-&gt;type == Consumer::Type::Blob || m_consumer-&gt;type == Consumer::Type::ArrayBuffer);
</span><span class="cx">     if (m_consumer-&gt;type == Consumer::Type::ArrayBuffer)
</span><span class="cx">         fulfillPromiseWithArrayBuffer(m_consumer-&gt;promise, buffer.get());
</span><span class="cx">     else {
</span><span class="cx">         ASSERT(m_blob);
</span><del>-        Vector&lt;char&gt; data;
-        data.reserveCapacity(buffer-&gt;byteLength());
-        data.append(static_cast&lt;const char*&gt;(buffer-&gt;data()), buffer-&gt;byteLength());
-        m_consumer-&gt;promise.resolve&lt;RefPtr&lt;Blob&gt;&gt;(Blob::create(WTFMove(data), m_blob-&gt;type()));
</del><ins>+        m_consumer-&gt;promise.resolve(blobFromArrayBuffer(buffer.get(), m_blob-&gt;type()));
</ins><span class="cx">     }
</span><span class="cx">     m_consumer = Nullopt;
</span><span class="cx"> }
</span><span class="lines">@@ -241,13 +296,26 @@
</span><span class="cx"> {
</span><span class="cx">     ASSERT(m_consumer);
</span><span class="cx">     ASSERT(m_consumer-&gt;type == Consumer::Type::Text || m_consumer-&gt;type == Consumer::Type::JSON);
</span><del>-    if (m_consumer-&gt;type == Consumer::Type::Text)
-        m_consumer-&gt;promise.resolve(text);
-    else
-        fulfillPromiseWithJSON(m_consumer-&gt;promise, text);
</del><ins>+
+    fulfillTextPromise(m_consumer-&gt;type, text, m_consumer-&gt;promise);
</ins><span class="cx">     m_consumer = Nullopt;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+RefPtr&lt;FormData&gt; FetchBody::bodyForInternalRequest() const
+{
+    if (m_type == Type::None)
+        return nullptr;
+    if (m_type == Type::Text)
+        return FormData::create(UTF8Encoding().encode(m_text, EntitiesForUnencodables));
+    if (m_type == Type::Blob) {
+        RefPtr&lt;FormData&gt; body = FormData::create();
+        body-&gt;appendBlob(m_blob-&gt;url());
+        return body;
+    }
+    ASSERT_NOT_REACHED();
+    return nullptr;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><ins>+}
+
</ins><span class="cx"> #endif // ENABLE(FETCH_API)
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesfetchFetchBodyh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/fetch/FetchBody.h (198664 => 198665)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/fetch/FetchBody.h        2016-03-25 14:08:56 UTC (rev 198664)
+++ trunk/Source/WebCore/Modules/fetch/FetchBody.h        2016-03-25 14:19:31 UTC (rev 198665)
</span><span class="lines">@@ -44,6 +44,7 @@
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><span class="cx"> class FetchBodyOwner;
</span><ins>+class FormData;
</ins><span class="cx"> 
</span><span class="cx"> class FetchBody {
</span><span class="cx"> public:
</span><span class="lines">@@ -61,18 +62,22 @@
</span><span class="cx"> 
</span><span class="cx">     static FetchBody extract(JSC::ExecState&amp;, JSC::JSValue);
</span><span class="cx">     static FetchBody extractFromBody(FetchBody*);
</span><ins>+    static FetchBody loadingBody() { return { Type::Loading }; }
</ins><span class="cx">     FetchBody() = default;
</span><span class="cx"> 
</span><span class="cx">     void loadingFailed();
</span><span class="cx">     void loadedAsArrayBuffer(RefPtr&lt;ArrayBuffer&gt;&amp;&amp;);
</span><span class="cx">     void loadedAsText(String&amp;&amp;);
</span><span class="cx"> 
</span><ins>+    RefPtr&lt;FormData&gt; bodyForInternalRequest() const;
+
</ins><span class="cx"> private:
</span><del>-    enum class Type { None, Text, Blob, FormData };
</del><ins>+    enum class Type { None, ArrayBuffer, Loading, Text, Blob, FormData };
</ins><span class="cx"> 
</span><span class="cx">     FetchBody(Ref&lt;Blob&gt;&amp;&amp;);
</span><span class="cx">     FetchBody(Ref&lt;DOMFormData&gt;&amp;&amp;);
</span><span class="cx">     FetchBody(String&amp;&amp;);
</span><ins>+    FetchBody(Type type) : m_type(type) { }
</ins><span class="cx"> 
</span><span class="cx">     struct Consumer {
</span><span class="cx">         enum class Type { Text, Blob, JSON, ArrayBuffer };
</span><span class="lines">@@ -84,17 +89,21 @@
</span><span class="cx"> 
</span><span class="cx">     Vector&lt;char&gt; extractFromText() const;
</span><span class="cx">     bool processIfEmptyOrDisturbed(Consumer::Type, DeferredWrapper&amp;);
</span><del>-    void consumeText(Consumer::Type, DeferredWrapper&amp;&amp;);
</del><ins>+    void consumeArrayBuffer(Consumer::Type, DeferredWrapper&amp;);
+    void consumeText(Consumer::Type, DeferredWrapper&amp;);
</ins><span class="cx">     void consumeBlob(FetchBodyOwner&amp;, Consumer::Type, DeferredWrapper&amp;&amp;);
</span><span class="cx">     static FetchLoader::Type loadingType(Consumer::Type);
</span><ins>+    static void fulfillTextPromise(FetchBody::Consumer::Type, const String&amp;, DeferredWrapper&amp;);
+    static void fulfillArrayBufferPromise(FetchBody::Consumer::Type, const String&amp;, DeferredWrapper&amp;);
</ins><span class="cx"> 
</span><del>-    Type m_type = Type::None;
</del><ins>+    Type m_type { Type::None };
</ins><span class="cx">     String m_mimeType;
</span><del>-    bool m_isDisturbed = false;
</del><ins>+    bool m_isDisturbed { false };
</ins><span class="cx"> 
</span><span class="cx">     // FIXME: Add support for BufferSource and URLSearchParams.
</span><span class="cx">     RefPtr&lt;Blob&gt; m_blob;
</span><span class="cx">     RefPtr&lt;DOMFormData&gt; m_formData;
</span><ins>+    RefPtr&lt;ArrayBuffer&gt; m_data;
</ins><span class="cx">     String m_text;
</span><span class="cx"> 
</span><span class="cx">     Optional&lt;Consumer&gt; m_consumer;
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesfetchFetchBodyOwnercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/fetch/FetchBodyOwner.cpp (198664 => 198665)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/fetch/FetchBodyOwner.cpp        2016-03-25 14:08:56 UTC (rev 198664)
+++ trunk/Source/WebCore/Modules/fetch/FetchBodyOwner.cpp        2016-03-25 14:19:31 UTC (rev 198665)
</span><span class="lines">@@ -59,19 +59,23 @@
</span><span class="cx">     ASSERT(m_body.isDisturbed());
</span><span class="cx">     ASSERT(!m_blobLoader);
</span><span class="cx"> 
</span><ins>+    if (!scriptExecutionContext()) {
+        m_body.loadingFailed();
+        return;
+    }
+
</ins><span class="cx">     m_blobLoader = { *this };
</span><span class="cx">     m_blobLoader-&gt;loader = std::make_unique&lt;FetchLoader&gt;(type, *m_blobLoader);
</span><span class="cx"> 
</span><ins>+    m_blobLoader-&gt;loader-&gt;start(*scriptExecutionContext(), blob);
+    if (!m_blobLoader-&gt;loader-&gt;isStarted()) {
+        m_body.loadingFailed();
+        m_blobLoader = Nullopt;
+        return;
+    }
</ins><span class="cx">     setPendingActivity(this);
</span><del>-    if (!scriptExecutionContext() || !m_blobLoader-&gt;loader-&gt;start(*scriptExecutionContext(), blob))
-        blobLoadingFailed();
</del><span class="cx"> }
</span><span class="cx"> 
</span><del>-void FetchBodyOwner::loadedBlobAsText(String&amp;&amp; text)
-{
-    m_body.loadedAsText(WTFMove(text));
-}
-
</del><span class="cx"> void FetchBodyOwner::finishBlobLoading()
</span><span class="cx"> {
</span><span class="cx">     ASSERT(m_blobLoader);
</span><span class="lines">@@ -80,6 +84,11 @@
</span><span class="cx">     unsetPendingActivity(this);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void FetchBodyOwner::loadedBlobAsText(String&amp;&amp; text)
+{
+    m_body.loadedAsText(WTFMove(text));
+}
+
</ins><span class="cx"> void FetchBodyOwner::blobLoadingFailed()
</span><span class="cx"> {
</span><span class="cx">     m_body.loadingFailed();
</span><span class="lines">@@ -97,6 +106,13 @@
</span><span class="cx">         didFail();
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void FetchBodyOwner::BlobLoader::didFail()
+{
+    // didFail might be called within FetchLoader::start call.
+    if (loader-&gt;isStarted())
+        owner.blobLoadingFailed();
+}
+
</ins><span class="cx"> } // namespace WebCore
</span><span class="cx"> 
</span><span class="cx"> #endif // ENABLE(FETCH_API)
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesfetchFetchBodyOwnerh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/fetch/FetchBodyOwner.h (198664 => 198665)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/fetch/FetchBodyOwner.h        2016-03-25 14:08:56 UTC (rev 198664)
+++ trunk/Source/WebCore/Modules/fetch/FetchBodyOwner.h        2016-03-25 14:19:31 UTC (rev 198665)
</span><span class="lines">@@ -54,6 +54,13 @@
</span><span class="cx"> 
</span><span class="cx">     bool isActive() const { return !!m_blobLoader; }
</span><span class="cx"> 
</span><ins>+protected:
+    const FetchBody&amp; body() const { return m_body; }
+    FetchBody&amp; body() { return m_body; }
+
+    // ActiveDOMObject API
+    void stop() override;
+
</ins><span class="cx"> private:
</span><span class="cx">     // Blob loading routines
</span><span class="cx">     void loadedBlobAsText(String&amp;&amp;);
</span><span class="lines">@@ -62,9 +69,6 @@
</span><span class="cx">     void blobLoadingFailed();
</span><span class="cx">     void finishBlobLoading();
</span><span class="cx"> 
</span><del>-    // ActiveDOMObject API
-    void stop() override;
-
</del><span class="cx">     struct BlobLoader final : FetchLoaderClient {
</span><span class="cx">         BlobLoader(FetchBodyOwner&amp;);
</span><span class="cx"> 
</span><span class="lines">@@ -72,7 +76,7 @@
</span><span class="cx">         void didFinishLoadingAsText(String&amp;&amp; text) final { owner.loadedBlobAsText(WTFMove(text)); }
</span><span class="cx">         void didFinishLoadingAsArrayBuffer(RefPtr&lt;ArrayBuffer&gt;&amp;&amp; buffer) final { owner.loadedBlobAsArrayBuffer(WTFMove(buffer)); }
</span><span class="cx">         void didReceiveResponse(const ResourceResponse&amp;) final;
</span><del>-        void didFail() final { owner.blobLoadingFailed(); };
</del><ins>+        void didFail() final;
</ins><span class="cx">         void didSucceed() final { owner.blobLoadingSucceeded(); }
</span><span class="cx"> 
</span><span class="cx">         FetchBodyOwner&amp; owner;
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesfetchFetchHeaderscpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/fetch/FetchHeaders.cpp (198664 => 198665)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/fetch/FetchHeaders.cpp        2016-03-25 14:08:56 UTC (rev 198664)
+++ trunk/Source/WebCore/Modules/fetch/FetchHeaders.cpp        2016-03-25 14:19:31 UTC (rev 198665)
</span><span class="lines">@@ -156,14 +156,19 @@
</span><span class="cx"> 
</span><span class="cx"> void FetchHeaders::fill(const FetchHeaders* headers)
</span><span class="cx"> {
</span><ins>+    ASSERT(m_guard != Guard::Immutable);
+
</ins><span class="cx">     if (!headers)
</span><span class="cx">         return;
</span><span class="cx"> 
</span><del>-    ASSERT(m_guard != Guard::Immutable);
</del><ins>+    filterAndFill(headers-&gt;m_headers, m_guard);
+}
</ins><span class="cx"> 
</span><ins>+void FetchHeaders::filterAndFill(const HTTPHeaderMap&amp; headers, Guard guard)
+{
</ins><span class="cx">     ExceptionCode ec;
</span><del>-    for (auto&amp; header : headers-&gt;m_headers) {
-        if (canWriteHeader(header.key, header.value, m_guard, ec)) {
</del><ins>+    for (auto&amp; header : headers) {
+        if (canWriteHeader(header.key, header.value, guard, ec)) {
</ins><span class="cx">             if (header.keyAsHTTPHeaderName)
</span><span class="cx">                 m_headers.add(header.keyAsHTTPHeaderName.value(), header.value);
</span><span class="cx">             else
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesfetchFetchHeadersh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/fetch/FetchHeaders.h (198664 => 198665)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/fetch/FetchHeaders.h        2016-03-25 14:08:56 UTC (rev 198664)
+++ trunk/Source/WebCore/Modules/fetch/FetchHeaders.h        2016-03-25 14:19:31 UTC (rev 198665)
</span><span class="lines">@@ -64,6 +64,8 @@
</span><span class="cx"> 
</span><span class="cx">     void fill(const FetchHeaders*);
</span><span class="cx"> 
</span><ins>+    void filterAndFill(const HTTPHeaderMap&amp;, Guard);
+
</ins><span class="cx">     String fastGet(HTTPHeaderName name) const { return m_headers.get(name); }
</span><span class="cx">     void fastSet(HTTPHeaderName name, const String&amp; value) { m_headers.set(name, value); }
</span><span class="cx"> 
</span><span class="lines">@@ -79,6 +81,8 @@
</span><span class="cx">     };
</span><span class="cx">     Iterator createIterator() { return Iterator(*this); }
</span><span class="cx"> 
</span><ins>+    const HTTPHeaderMap&amp; internalHeaders() const { return m_headers; }
+
</ins><span class="cx"> private:
</span><span class="cx">     FetchHeaders(Guard guard) : m_guard(guard) { }
</span><span class="cx">     FetchHeaders(Guard guard, const HTTPHeaderMap&amp; headers) : m_guard(guard), m_headers(headers) { }
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesfetchFetchLoadercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/fetch/FetchLoader.cpp (198664 => 198665)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/fetch/FetchLoader.cpp        2016-03-25 14:08:56 UTC (rev 198664)
+++ trunk/Source/WebCore/Modules/fetch/FetchLoader.cpp        2016-03-25 14:19:31 UTC (rev 198665)
</span><span class="lines">@@ -34,8 +34,10 @@
</span><span class="cx"> #include &quot;BlobURL.h&quot;
</span><span class="cx"> #include &quot;FetchBody.h&quot;
</span><span class="cx"> #include &quot;FetchLoaderClient.h&quot;
</span><ins>+#include &quot;FetchRequest.h&quot;
</ins><span class="cx"> #include &quot;ResourceRequest.h&quot;
</span><span class="cx"> #include &quot;ScriptExecutionContext.h&quot;
</span><ins>+#include &quot;SecurityOrigin.h&quot;
</ins><span class="cx"> #include &quot;SharedBuffer.h&quot;
</span><span class="cx"> #include &quot;TextResourceDecoder.h&quot;
</span><span class="cx"> #include &quot;ThreadableBlobRegistry.h&quot;
</span><span class="lines">@@ -43,11 +45,14 @@
</span><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><del>-bool FetchLoader::start(ScriptExecutionContext&amp; context, Blob&amp; blob)
</del><ins>+void FetchLoader::start(ScriptExecutionContext&amp; context, Blob&amp; blob)
</ins><span class="cx"> {
</span><span class="cx">     auto urlForReading = BlobURL::createPublicURL(context.securityOrigin());
</span><del>-    if (urlForReading.isEmpty())
-        return false;
</del><ins>+    if (urlForReading.isEmpty()) {
+        m_client.didFail();
+        return;
+    }
+
</ins><span class="cx">     ThreadableBlobRegistry::registerBlobURL(context.securityOrigin(), urlForReading, blob.url());
</span><span class="cx"> 
</span><span class="cx">     ResourceRequest request(urlForReading);
</span><span class="lines">@@ -63,9 +68,23 @@
</span><span class="cx">     options.contentSecurityPolicyEnforcement = ContentSecurityPolicyEnforcement::DoNotEnforce;
</span><span class="cx"> 
</span><span class="cx">     m_loader = ThreadableLoader::create(&amp;context, this, request, options);
</span><del>-    return true;
</del><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void FetchLoader::start(ScriptExecutionContext&amp; context, const FetchRequest&amp; request)
+{
+    // FIXME: Compute loading options according fetch options.
+    ThreadableLoaderOptions options;
+    options.setSendLoadCallbacks(SendCallbacks);
+    options.setSniffContent(DoNotSniffContent);
+    options.setDataBufferingPolicy(DoNotBufferData);
+    options.preflightPolicy = ConsiderPreflight;
+    options.setAllowCredentials(AllowStoredCredentials);
+    options.crossOriginRequestPolicy = DenyCrossOriginRequests;
+    options.contentSecurityPolicyEnforcement = ContentSecurityPolicyEnforcement::DoNotEnforce;
+
+    m_loader = ThreadableLoader::create(&amp;context, this, request.internalRequest(), options);
+}
+
</ins><span class="cx"> FetchLoader::FetchLoader(Type type, FetchLoaderClient&amp; client)
</span><span class="cx">     : m_type(type)
</span><span class="cx">     , m_client(client)
</span><span class="lines">@@ -113,6 +132,11 @@
</span><span class="cx">     m_client.didFail();
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void FetchLoader::didFailRedirectCheck()
+{
+    m_client.didFail();
+}
+
</ins><span class="cx"> } // namespace WebCore
</span><span class="cx"> 
</span><span class="cx"> #endif // ENABLE(FETCH_API)
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesfetchFetchLoaderh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/fetch/FetchLoader.h (198664 => 198665)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/fetch/FetchLoader.h        2016-03-25 14:08:56 UTC (rev 198664)
+++ trunk/Source/WebCore/Modules/fetch/FetchLoader.h        2016-03-25 14:19:31 UTC (rev 198665)
</span><span class="lines">@@ -39,6 +39,7 @@
</span><span class="cx"> 
</span><span class="cx"> class Blob;
</span><span class="cx"> class FetchLoaderClient;
</span><ins>+class FetchRequest;
</ins><span class="cx"> class ScriptExecutionContext;
</span><span class="cx"> 
</span><span class="cx"> class FetchLoader final : public ThreadableLoaderClient {
</span><span class="lines">@@ -47,15 +48,18 @@
</span><span class="cx"> 
</span><span class="cx">     FetchLoader(Type, FetchLoaderClient&amp;);
</span><span class="cx"> 
</span><del>-    bool start(ScriptExecutionContext&amp;, Blob&amp;);
</del><ins>+    void start(ScriptExecutionContext&amp;, const FetchRequest&amp;);
+    void start(ScriptExecutionContext&amp;, Blob&amp;);
</ins><span class="cx">     void stop();
</span><span class="cx"> 
</span><ins>+    bool isStarted() const { return !!m_loader; }
</ins><span class="cx"> private:
</span><span class="cx">     // ThreadableLoaderClient API.
</span><span class="cx">     void didReceiveResponse(unsigned long, const ResourceResponse&amp;) final;
</span><span class="cx">     void didReceiveData(const char*, int) final;
</span><span class="cx">     void didFinishLoading(unsigned long, double) final;
</span><span class="cx">     void didFail(const ResourceError&amp;) final;
</span><ins>+    void didFailRedirectCheck() final;
</ins><span class="cx"> 
</span><span class="cx"> private:
</span><span class="cx">     Type m_type { Type::ArrayBuffer };
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesfetchFetchRequestcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/fetch/FetchRequest.cpp (198664 => 198665)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/fetch/FetchRequest.cpp        2016-03-25 14:08:56 UTC (rev 198664)
+++ trunk/Source/WebCore/Modules/fetch/FetchRequest.cpp        2016-03-25 14:19:31 UTC (rev 198665)
</span><span class="lines">@@ -435,6 +435,14 @@
</span><span class="cx">     return String();
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+ResourceRequest FetchRequest::internalRequest() const
+{
+    ResourceRequest request = m_internalRequest.request;
+    request.setHTTPHeaderFields(m_headers-&gt;internalHeaders());
+    request.setHTTPBody(body().bodyForInternalRequest());
+    return request;
+}
+
</ins><span class="cx"> RefPtr&lt;FetchRequest&gt; FetchRequest::clone(ScriptExecutionContext&amp; context, ExceptionCode&amp; ec)
</span><span class="cx"> {
</span><span class="cx">     if (isDisturbed()) {
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesfetchFetchRequesth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/fetch/FetchRequest.h (198664 => 198665)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/fetch/FetchRequest.h        2016-03-25 14:08:56 UTC (rev 198664)
+++ trunk/Source/WebCore/Modules/fetch/FetchRequest.h        2016-03-25 14:19:31 UTC (rev 198665)
</span><span class="lines">@@ -72,6 +72,9 @@
</span><span class="cx">         String integrity;
</span><span class="cx">     };
</span><span class="cx"> 
</span><ins>+    const FetchOptions&amp; fetchOptions() const { return m_internalRequest.options; }
+    ResourceRequest internalRequest() const;
+
</ins><span class="cx"> private:
</span><span class="cx">     FetchRequest(ScriptExecutionContext&amp;, FetchBody&amp;&amp;, Ref&lt;FetchHeaders&gt;&amp;&amp;, InternalRequest&amp;&amp;);
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesfetchFetchResponsecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/fetch/FetchResponse.cpp (198664 => 198665)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/fetch/FetchResponse.cpp        2016-03-25 14:08:56 UTC (rev 198664)
+++ trunk/Source/WebCore/Modules/fetch/FetchResponse.cpp        2016-03-25 14:19:31 UTC (rev 198665)
</span><span class="lines">@@ -153,6 +153,82 @@
</span><span class="cx">     return JSC::jsNull();
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void FetchResponse::fetch(ScriptExecutionContext&amp; context, const FetchRequest&amp; request, FetchPromise&amp;&amp; promise)
+{
+    Ref&lt;FetchResponse&gt; response = adoptRef(*new FetchResponse(context, Type::Basic, FetchBody::loadingBody(), FetchHeaders::create(FetchHeaders::Guard::Immutable), ResourceResponse()));
+
+    // Setting pending activity until BodyLoader didFail or didSucceed callback is called.
+    response-&gt;setPendingActivity(response.ptr());
+
+    response-&gt;m_bodyLoader = BodyLoader(response.get(), WTFMove(promise));
+    if (!response-&gt;m_bodyLoader-&gt;start(context, request))
+        response-&gt;m_bodyLoader = Nullopt;
+}
+
+void FetchResponse::BodyLoader::didSucceed()
+{
+    m_response.m_bodyLoader = Nullopt;
+    m_response.unsetPendingActivity(&amp;m_response);
+}
+
+void FetchResponse::BodyLoader::didFail()
+{
+    if (m_promise)
+        std::exchange(m_promise, Nullopt)-&gt;reject(TypeError);
+
+    // Check whether didFail is called as part of FetchLoader::start.
+    if (m_loader-&gt;isStarted())
+        m_response.m_bodyLoader = Nullopt;
+
+    // FIXME: Handle the case of failing after didReceiveResponse is called.
+
+    m_response.unsetPendingActivity(&amp;m_response);
+}
+
+FetchResponse::BodyLoader::BodyLoader(FetchResponse&amp; response, FetchPromise&amp;&amp; promise)
+    : m_response(response)
+    , m_promise(WTFMove(promise))
+{
+}
+
+void FetchResponse::BodyLoader::didReceiveResponse(const ResourceResponse&amp; resourceResponse)
+{
+    ASSERT(m_promise);
+
+    m_response.m_response = resourceResponse;
+    m_response.m_headers-&gt;filterAndFill(resourceResponse.httpHeaderFields(), FetchHeaders::Guard::Response);
+
+    std::exchange(m_promise, Nullopt)-&gt;resolve(&amp;m_response);
+}
+
+void FetchResponse::BodyLoader::didFinishLoadingAsArrayBuffer(RefPtr&lt;ArrayBuffer&gt;&amp;&amp; buffer)
+{
+    m_response.body().loadedAsArrayBuffer(WTFMove(buffer));
+}
+
+bool FetchResponse::BodyLoader::start(ScriptExecutionContext&amp; context, const FetchRequest&amp; request)
+{
+    m_loader = std::make_unique&lt;FetchLoader&gt;(FetchLoader::Type::ArrayBuffer, *this);
+    m_loader-&gt;start(context, request);
+    return m_loader-&gt;isStarted();
+}
+
+void FetchResponse::BodyLoader::stop()
+{
+    if (m_loader)
+        m_loader-&gt;stop();
+}
+
+void FetchResponse::stop()
+{
+    FetchBodyOwner::stop();
+    if (m_bodyLoader) {
+        RefPtr&lt;FetchResponse&gt; protect(this);
+        m_bodyLoader-&gt;stop();
+        m_bodyLoader = Nullopt;
+    }
+}
+
</ins><span class="cx"> const char* FetchResponse::activeDOMObjectName() const
</span><span class="cx"> {
</span><span class="cx">     return &quot;Response&quot;;
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesfetchFetchResponseh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/fetch/FetchResponse.h (198664 => 198665)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/fetch/FetchResponse.h        2016-03-25 14:08:56 UTC (rev 198664)
+++ trunk/Source/WebCore/Modules/fetch/FetchResponse.h        2016-03-25 14:19:31 UTC (rev 198665)
</span><span class="lines">@@ -42,6 +42,7 @@
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><span class="cx"> class Dictionary;
</span><ins>+class FetchRequest;
</ins><span class="cx"> 
</span><span class="cx"> typedef int ExceptionCode;
</span><span class="cx"> 
</span><span class="lines">@@ -53,6 +54,9 @@
</span><span class="cx">     // FIXME: Binding generator should not require below method to handle optional status parameter.
</span><span class="cx">     static RefPtr&lt;FetchResponse&gt; redirect(ScriptExecutionContext&amp; context, const String&amp; url, ExceptionCode&amp; ec) { return redirect(context, url, 302, ec); }
</span><span class="cx"> 
</span><ins>+    using FetchPromise = DOMPromise&lt;RefPtr&lt;FetchResponse&gt;, ExceptionCode&gt;;
+    static void fetch(ScriptExecutionContext&amp;, const FetchRequest&amp;, FetchPromise&amp;&amp;);
+
</ins><span class="cx">     void initializeWith(const Dictionary&amp;, ExceptionCode&amp;);
</span><span class="cx"> 
</span><span class="cx">     String type() const;
</span><span class="lines">@@ -71,14 +75,35 @@
</span><span class="cx">     FetchResponse(ScriptExecutionContext&amp;, Type, FetchBody&amp;&amp;, Ref&lt;FetchHeaders&gt;&amp;&amp;, ResourceResponse&amp;&amp;);
</span><span class="cx"> 
</span><span class="cx">     // ActiveDOMObject API
</span><ins>+    void stop() final;
</ins><span class="cx">     const char* activeDOMObjectName() const final;
</span><span class="cx">     bool canSuspendForDocumentSuspension() const final;
</span><span class="cx"> 
</span><ins>+    class BodyLoader final : public FetchLoaderClient {
+    public:
+        BodyLoader(FetchResponse&amp;, FetchPromise&amp;&amp;);
+
+        bool start(ScriptExecutionContext&amp;, const FetchRequest&amp;);
+        void stop();
+
+    private:
+        // FetchLoaderClient API
+        void didSucceed() final;
+        void didFail() final;
+        void didReceiveResponse(const ResourceResponse&amp;);
+        void didFinishLoadingAsArrayBuffer(RefPtr&lt;ArrayBuffer&gt;&amp;&amp;) final;
+
+        FetchResponse&amp; m_response;
+        Optional&lt;FetchPromise&gt; m_promise;
+        std::unique_ptr&lt;FetchLoader&gt; m_loader;
+    };
+
</ins><span class="cx">     Type m_type;
</span><span class="cx">     ResourceResponse m_response;
</span><span class="cx">     Ref&lt;FetchHeaders&gt; m_headers;
</span><span class="cx">     bool m_isLocked = false;
</span><span class="cx">     bool m_isRedirected = false;
</span><ins>+    Optional&lt;BodyLoader&gt; m_bodyLoader;
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> } // namespace WebCore
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformnetworkBlobResourceHandlecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/network/BlobResourceHandle.cpp (198664 => 198665)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/network/BlobResourceHandle.cpp        2016-03-25 14:08:56 UTC (rev 198664)
+++ trunk/Source/WebCore/platform/network/BlobResourceHandle.cpp        2016-03-25 14:19:31 UTC (rev 198665)
</span><span class="lines">@@ -136,10 +136,6 @@
</span><span class="cx"> 
</span><span class="cx"> PassRefPtr&lt;BlobResourceHandle&gt; BlobResourceHandle::createAsync(BlobData* blobData, const ResourceRequest&amp; request, ResourceHandleClient* client)
</span><span class="cx"> {
</span><del>-    // FIXME: Should probably call didFail() instead of blocking the load without explanation.
-    if (!equalLettersIgnoringASCIICase(request.httpMethod(), &quot;get&quot;))
-        return nullptr;
-
</del><span class="cx">     return adoptRef(new BlobResourceHandle(blobData, request, client, true));
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -207,6 +203,12 @@
</span><span class="cx">     if (m_aborted || m_errorCode)
</span><span class="cx">         return;
</span><span class="cx"> 
</span><ins>+    if (!equalLettersIgnoringASCIICase(firstRequest().httpMethod(), &quot;get&quot;)) {
+        m_errorCode = methodNotAllowed;
+        notifyResponse();
+        return;
+    }
+
</ins><span class="cx">     // If the blob data is not found, fail now.
</span><span class="cx">     if (!m_blobData) {
</span><span class="cx">         m_errorCode = notFoundError;
</span><span class="lines">@@ -578,6 +580,10 @@
</span><span class="cx">     ResourceResponse response(firstRequest().url(), m_blobData-&gt;contentType(), m_totalRemainingSize, String());
</span><span class="cx">     response.setHTTPStatusCode(isRangeRequest ? httpPartialContent : httpOK);
</span><span class="cx">     response.setHTTPStatusText(isRangeRequest ? httpPartialContentText : httpOKText);
</span><ins>+
+    response.setHTTPHeaderField(HTTPHeaderName::ContentType, m_blobData-&gt;contentType());
+    response.setHTTPHeaderField(HTTPHeaderName::ContentLength, String::number(m_totalRemainingSize));
+
</ins><span class="cx">     if (isRangeRequest)
</span><span class="cx">         response.setHTTPHeaderField(HTTPHeaderName::ContentRange, ParsedContentRange(m_rangeOffset, m_rangeEnd, m_totalSize).headerValue());
</span><span class="cx">     // FIXME: If a resource identified with a blob: URL is a File object, user agents must use that file's name attribute,
</span></span></pre>
</div>
</div>

</body>
</html>