<!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>[199825] trunk/LayoutTests/imported/w3c</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/199825">199825</a></dd>
<dt>Author</dt> <dd>youenn.fablet@crf.canon.fr</dd>
<dt>Date</dt> <dd>2016-04-21 11:11:28 -0700 (Thu, 21 Apr 2016)</dd>
</dl>

<h3>Log Message</h3>
<pre>[Fetch API] Improve some fetch response streams tests
https://bugs.webkit.org/show_bug.cgi?id=156848

Reviewed by Darin Adler.

Most important changes are for response-stream-disturbed-2.html and response-stream-disturbed-5.html which were broken.
response-stream-disturbed-2.html was calling an undefined function and was expecting to get a resolved promise while it should be rejected.
response-stream-disturbed-5.html was expecting to have a null body if data is consumed.
After rereading the spec, this test is non conformant, as the body should not be null, but getting the reader should throw.

* web-platform-tests/fetch/api/resources/utils.js: Adding delay helper function.
* web-platform-tests/fetch/api/response/response-cancel-stream.html: Using delay function.
* web-platform-tests/fetch/api/response/response-stream-disturbed-1.html: Removing unused function.
* web-platform-tests/fetch/api/response/response-stream-disturbed-2-expected.txt: Rebasing
* web-platform-tests/fetch/api/response/response-stream-disturbed-2.html: Fixing test.
* web-platform-tests/fetch/api/response/response-stream-disturbed-5-expected.txt: Rebasing
* web-platform-tests/fetch/api/response/response-stream-disturbed-5.html: Fixing test.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsimportedw3cChangeLog">trunk/LayoutTests/imported/w3c/ChangeLog</a></li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestsfetchapiresourcesutilsjs">trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/resources/utils.js</a></li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestsfetchapiresponseresponsecancelstreamhtml">trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-cancel-stream.html</a></li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestsfetchapiresponseresponsestreamdisturbed1html">trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-stream-disturbed-1.html</a></li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestsfetchapiresponseresponsestreamdisturbed2expectedtxt">trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-stream-disturbed-2-expected.txt</a></li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestsfetchapiresponseresponsestreamdisturbed2html">trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-stream-disturbed-2.html</a></li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestsfetchapiresponseresponsestreamdisturbed5expectedtxt">trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-stream-disturbed-5-expected.txt</a></li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestsfetchapiresponseresponsestreamdisturbed5html">trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-stream-disturbed-5.html</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsimportedw3cChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/imported/w3c/ChangeLog (199824 => 199825)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/ChangeLog        2016-04-21 18:11:17 UTC (rev 199824)
+++ trunk/LayoutTests/imported/w3c/ChangeLog        2016-04-21 18:11:28 UTC (rev 199825)
</span><span class="lines">@@ -1,3 +1,23 @@
</span><ins>+2016-04-21  Youenn Fablet  &lt;youenn.fablet@crf.canon.fr&gt;
+
+        [Fetch API] Improve some fetch response streams tests
+        https://bugs.webkit.org/show_bug.cgi?id=156848
+
+        Reviewed by Darin Adler.
+
+        Most important changes are for response-stream-disturbed-2.html and response-stream-disturbed-5.html which were broken.
+        response-stream-disturbed-2.html was calling an undefined function and was expecting to get a resolved promise while it should be rejected.
+        response-stream-disturbed-5.html was expecting to have a null body if data is consumed.
+        After rereading the spec, this test is non conformant, as the body should not be null, but getting the reader should throw.
+
+        * web-platform-tests/fetch/api/resources/utils.js: Adding delay helper function.
+        * web-platform-tests/fetch/api/response/response-cancel-stream.html: Using delay function.
+        * web-platform-tests/fetch/api/response/response-stream-disturbed-1.html: Removing unused function.
+        * web-platform-tests/fetch/api/response/response-stream-disturbed-2-expected.txt: Rebasing
+        * web-platform-tests/fetch/api/response/response-stream-disturbed-2.html: Fixing test.
+        * web-platform-tests/fetch/api/response/response-stream-disturbed-5-expected.txt: Rebasing
+        * web-platform-tests/fetch/api/response/response-stream-disturbed-5.html: Fixing test.
+
</ins><span class="cx"> 2016-04-19  Youenn Fablet  &lt;youenn.fablet@crf.canon.fr&gt;
</span><span class="cx"> 
</span><span class="cx">         imported/w3c/web-platform-tests/streams/readable-streams/general.https.html is a flaky failure
</span></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestsfetchapiresourcesutilsjs"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/resources/utils.js (199824 => 199825)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/resources/utils.js        2016-04-21 18:11:17 UTC (rev 199824)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/resources/utils.js        2016-04-21 18:11:28 UTC (rev 199825)
</span><span class="lines">@@ -74,3 +74,11 @@
</span><span class="cx">     validateBufferFromString(retrievedArrayBuffer, expectedValue, &quot;Retrieve and verify stream&quot;);
</span><span class="cx">   });
</span><span class="cx"> }
</span><ins>+
+// From streams tests
+function delay(milliseconds)
+{
+    return new Promise(function(resolve) {
+        step_timeout(resolve, milliseconds);
+    });
+}
</ins></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestsfetchapiresponseresponsecancelstreamhtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-cancel-stream.html (199824 => 199825)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-cancel-stream.html        2016-04-21 18:11:17 UTC (rev 199824)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-cancel-stream.html        2016-04-21 18:11:28 UTC (rev 199825)
</span><span class="lines">@@ -27,17 +27,12 @@
</span><span class="cx"> promise_test(function(test) {
</span><span class="cx">     var response = new Response(new Blob([&quot;T&quot;], { &quot;type&quot; : &quot;text/plain&quot; }));
</span><span class="cx">     var reader = response.body.getReader();
</span><del>-    var resolve;
-    var promise = new Promise(function(_resolve, _reject) {
-        resolve = _resolve;
-    });
-    promise.then(function() {
</del><ins>+
+    return delay(100).then(function() {
</ins><span class="cx">         return reader.read().then(function(value) {
</span><del>-        return reader.cancel();
</del><ins>+            return reader.cancel();
</ins><span class="cx">         });
</span><span class="cx">     });
</span><del>-    setTimeout(resolve, 100);
-    return promise;
</del><span class="cx"> }, &quot;Cancelling a closed blob Response stream&quot;);
</span><span class="cx"> 
</span><span class="cx"> promise_test(function(test) {
</span></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestsfetchapiresponseresponsestreamdisturbed1html"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-stream-disturbed-1.html (199824 => 199825)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-stream-disturbed-1.html        2016-04-21 18:11:17 UTC (rev 199824)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-stream-disturbed-1.html        2016-04-21 18:11:28 UTC (rev 199825)
</span><span class="lines">@@ -20,13 +20,6 @@
</span><span class="cx">     });
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-function createResponseWithCancelledReadableStream(callback) {
-    return fetch(&quot;../resources/data.json&quot;).then(function(response) {
-        response.body.cancel();
-        return callback(response);
-    });
-}
-
</del><span class="cx"> promise_test(function() {
</span><span class="cx">     return createResponseWithReadableStream(function(response) {
</span><span class="cx">         return response.blob().then(function(blob) {
</span></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestsfetchapiresponseresponsestreamdisturbed2expectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-stream-disturbed-2-expected.txt (199824 => 199825)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-stream-disturbed-2-expected.txt        2016-04-21 18:11:17 UTC (rev 199824)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-stream-disturbed-2-expected.txt        2016-04-21 18:11:28 UTC (rev 199825)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx"> 
</span><del>-FAIL Getting blob after getting a locked Response body Can't find variable: createResponseWithReadableStream
-FAIL Getting text after getting a locked Response body Can't find variable: createResponseWithReadableStream
-FAIL Getting json after getting a locked Response body Can't find variable: createResponseWithReadableStream
-FAIL Getting arraybuffer after getting a locked Response body Can't find variable: createResponseWithReadableStream
</del><ins>+PASS Getting blob after getting a locked Response body 
+PASS Getting text after getting a locked Response body 
+PASS Getting json after getting a locked Response body 
+PASS Getting arrayBuffer after getting a locked Response body 
</ins><span class="cx"> 
</span></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestsfetchapiresponseresponsestreamdisturbed2html"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-stream-disturbed-2.html (199824 => 199825)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-stream-disturbed-2.html        2016-04-21 18:11:17 UTC (rev 199824)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-stream-disturbed-2.html        2016-04-21 18:11:28 UTC (rev 199825)
</span><span class="lines">@@ -19,44 +19,29 @@
</span><span class="cx">     });
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-function createResponseWithCancelledReadableStream(callback) {
-    return fetch(&quot;../resources/data.json&quot;).then(function(response) {
-        response.body.cancel();
-        return callback(response);
</del><ins>+promise_test(function(test) {
+    return createResponseWithLockedReadableStream(function(response) {
+        return promise_rejects(test, new TypeError(), response.blob());
</ins><span class="cx">     });
</span><del>-}
-
-promise_test(function() {
-    return createResponseWithReadableStream(function(response) {
-        return response.blob().then(function(blob) {
-            assert_true(blob instanceof Blob);
-        });
-    });
</del><span class="cx"> }, &quot;Getting blob after getting a locked Response body&quot;);
</span><span class="cx"> 
</span><del>-promise_test(function() {
-    return createResponseWithReadableStream(function(response) {
-        return response.text().then(function(text) {
-            assert_true(text.length &gt; 0);
-        });
</del><ins>+promise_test(function(test) {
+    return createResponseWithLockedReadableStream(function(response) {
+        return promise_rejects(test, new TypeError(), response.text());
</ins><span class="cx">     });
</span><span class="cx"> }, &quot;Getting text after getting a locked Response body&quot;);
</span><span class="cx"> 
</span><del>-promise_test(function() {
-    return createResponseWithReadableStream(function(response) {
-        return response.json().then(function(json) {
-            assert_true(typeof json === &quot;object&quot;);
-        });
</del><ins>+promise_test(function(test) {
+    return createResponseWithLockedReadableStream(function(response) {
+        return promise_rejects(test, new TypeError(), response.json());
</ins><span class="cx">     });
</span><span class="cx"> }, &quot;Getting json after getting a locked Response body&quot;);
</span><span class="cx"> 
</span><del>-promise_test(function() {
-    return createResponseWithReadableStream(function(response) {
-        return response.arrayBuffer().then(function(arrayBuffer) {
-            assert_true(arrayBuffer.byteLength &gt; 0);
-        });
</del><ins>+promise_test(function(test) {
+    return createResponseWithLockedReadableStream(function(response) {
+        return promise_rejects(test, new TypeError(), response.arrayBuffer());
</ins><span class="cx">     });
</span><del>-}, &quot;Getting arraybuffer after getting a locked Response body&quot;);
</del><ins>+}, &quot;Getting arrayBuffer after getting a locked Response body&quot;);
</ins><span class="cx"> 
</span><span class="cx">     &lt;/script&gt;
</span><span class="cx">   &lt;/body&gt;
</span></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestsfetchapiresponseresponsestreamdisturbed5expectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-stream-disturbed-5-expected.txt (199824 => 199825)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-stream-disturbed-5-expected.txt        2016-04-21 18:11:17 UTC (rev 199824)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-stream-disturbed-5-expected.txt        2016-04-21 18:11:28 UTC (rev 199825)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx"> 
</span><del>-PASS Getting a null body after consuming as blob 
-PASS Getting a null body after consuming as text 
-PASS Getting a null body after consuming as json 
-PASS Getting a null body after consuming as arrayBuffer 
</del><ins>+FAIL Getting a body reader after consuming as blob assert_not_equals: got disallowed value null
+FAIL Getting a body reader after consuming as text assert_not_equals: got disallowed value null
+FAIL Getting a body reader after consuming as json assert_not_equals: got disallowed value null
+FAIL Getting a body reader after consuming as arrayBuffer assert_not_equals: got disallowed value null
</ins><span class="cx"> 
</span></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestsfetchapiresponseresponsestreamdisturbed5html"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-stream-disturbed-5.html (199824 => 199825)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-stream-disturbed-5.html        2016-04-21 18:11:17 UTC (rev 199824)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-stream-disturbed-5.html        2016-04-21 18:11:28 UTC (rev 199825)
</span><span class="lines">@@ -15,30 +15,34 @@
</span><span class="cx"> promise_test(function() {
</span><span class="cx">     return fetch(&quot;../resources/data.json&quot;).then(function(response) {
</span><span class="cx">         response.blob();
</span><del>-        assert_equals(response.body, null);
</del><ins>+        assert_not_equals(response.body, null);
+        assert_throws(new TypeError(), function() { response.body.getReader(); });
</ins><span class="cx">     });
</span><del>-}, &quot;Getting a null body after consuming as blob&quot;);
</del><ins>+}, &quot;Getting a body reader after consuming as blob&quot;);
</ins><span class="cx"> 
</span><span class="cx"> promise_test(function() {
</span><span class="cx">     return fetch(&quot;../resources/data.json&quot;).then(function(response) {
</span><span class="cx">         response.text();
</span><del>-        assert_equals(response.body, null);
</del><ins>+        assert_not_equals(response.body, null);
+        assert_throws(new TypeError(), function() { response.body.getReader(); });
</ins><span class="cx">     });
</span><del>-}, &quot;Getting a null body after consuming as text&quot;);
</del><ins>+}, &quot;Getting a body reader after consuming as text&quot;);
</ins><span class="cx"> 
</span><span class="cx"> promise_test(function() {
</span><span class="cx">     return fetch(&quot;../resources/data.json&quot;).then(function(response) {
</span><span class="cx">         response.json();
</span><del>-        assert_equals(response.body, null);
</del><ins>+        assert_not_equals(response.body, null);
+        assert_throws(new TypeError(), function() { response.body.getReader(); });
</ins><span class="cx">     });
</span><del>-}, &quot;Getting a null body after consuming as json&quot;);
</del><ins>+}, &quot;Getting a body reader after consuming as json&quot;);
</ins><span class="cx"> 
</span><span class="cx"> promise_test(function() {
</span><span class="cx">     return fetch(&quot;../resources/data.json&quot;).then(function(response) {
</span><span class="cx">         response.arrayBuffer();
</span><del>-        assert_equals(response.body, null);
</del><ins>+        assert_not_equals(response.body, null);
+        assert_throws(new TypeError(), function() { response.body.getReader(); });
</ins><span class="cx">     });
</span><del>-}, &quot;Getting a null body after consuming as arrayBuffer&quot;);
</del><ins>+}, &quot;Getting a body reader after consuming as arrayBuffer&quot;);
</ins><span class="cx"> 
</span><span class="cx">     &lt;/script&gt;
</span><span class="cx">   &lt;/body&gt;
</span></span></pre>
</div>
</div>

</body>
</html>