Title: [199825] trunk/LayoutTests/imported/w3c
Revision
199825
Author
youenn.fab...@crf.canon.fr
Date
2016-04-21 11:11:28 -0700 (Thu, 21 Apr 2016)

Log Message

[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.

Modified Paths

Diff

Modified: trunk/LayoutTests/imported/w3c/ChangeLog (199824 => 199825)


--- 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)
@@ -1,3 +1,23 @@
+2016-04-21  Youenn Fablet  <youenn.fab...@crf.canon.fr>
+
+        [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.
+
 2016-04-19  Youenn Fablet  <youenn.fab...@crf.canon.fr>
 
         imported/w3c/web-platform-tests/streams/readable-streams/general.https.html is a flaky failure

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/resources/utils.js (199824 => 199825)


--- 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)
@@ -74,3 +74,11 @@
     validateBufferFromString(retrievedArrayBuffer, expectedValue, "Retrieve and verify stream");
   });
 }
+
+// From streams tests
+function delay(milliseconds)
+{
+    return new Promise(function(resolve) {
+        step_timeout(resolve, milliseconds);
+    });
+}

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-cancel-stream.html (199824 => 199825)


--- 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)
@@ -27,17 +27,12 @@
 promise_test(function(test) {
     var response = new Response(new Blob(["T"], { "type" : "text/plain" }));
     var reader = response.body.getReader();
-    var resolve;
-    var promise = new Promise(function(_resolve, _reject) {
-        resolve = _resolve;
-    });
-    promise.then(function() {
+
+    return delay(100).then(function() {
         return reader.read().then(function(value) {
-        return reader.cancel();
+            return reader.cancel();
         });
     });
-    setTimeout(resolve, 100);
-    return promise;
 }, "Cancelling a closed blob Response stream");
 
 promise_test(function(test) {

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-stream-disturbed-1.html (199824 => 199825)


--- 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)
@@ -20,13 +20,6 @@
     });
 }
 
-function createResponseWithCancelledReadableStream(callback) {
-    return fetch("../resources/data.json").then(function(response) {
-        response.body.cancel();
-        return callback(response);
-    });
-}
-
 promise_test(function() {
     return createResponseWithReadableStream(function(response) {
         return response.blob().then(function(blob) {

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-stream-disturbed-2-expected.txt (199824 => 199825)


--- 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)
@@ -1,6 +1,6 @@
 
-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
+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 
 

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-stream-disturbed-2.html (199824 => 199825)


--- 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)
@@ -19,44 +19,29 @@
     });
 }
 
-function createResponseWithCancelledReadableStream(callback) {
-    return fetch("../resources/data.json").then(function(response) {
-        response.body.cancel();
-        return callback(response);
+promise_test(function(test) {
+    return createResponseWithLockedReadableStream(function(response) {
+        return promise_rejects(test, new TypeError(), response.blob());
     });
-}
-
-promise_test(function() {
-    return createResponseWithReadableStream(function(response) {
-        return response.blob().then(function(blob) {
-            assert_true(blob instanceof Blob);
-        });
-    });
 }, "Getting blob after getting a locked Response body");
 
-promise_test(function() {
-    return createResponseWithReadableStream(function(response) {
-        return response.text().then(function(text) {
-            assert_true(text.length > 0);
-        });
+promise_test(function(test) {
+    return createResponseWithLockedReadableStream(function(response) {
+        return promise_rejects(test, new TypeError(), response.text());
     });
 }, "Getting text after getting a locked Response body");
 
-promise_test(function() {
-    return createResponseWithReadableStream(function(response) {
-        return response.json().then(function(json) {
-            assert_true(typeof json === "object");
-        });
+promise_test(function(test) {
+    return createResponseWithLockedReadableStream(function(response) {
+        return promise_rejects(test, new TypeError(), response.json());
     });
 }, "Getting json after getting a locked Response body");
 
-promise_test(function() {
-    return createResponseWithReadableStream(function(response) {
-        return response.arrayBuffer().then(function(arrayBuffer) {
-            assert_true(arrayBuffer.byteLength > 0);
-        });
+promise_test(function(test) {
+    return createResponseWithLockedReadableStream(function(response) {
+        return promise_rejects(test, new TypeError(), response.arrayBuffer());
     });
-}, "Getting arraybuffer after getting a locked Response body");
+}, "Getting arrayBuffer after getting a locked Response body");
 
     </script>
   </body>

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-stream-disturbed-5-expected.txt (199824 => 199825)


--- 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)
@@ -1,6 +1,6 @@
 
-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 
+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
 

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-stream-disturbed-5.html (199824 => 199825)


--- 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)
@@ -15,30 +15,34 @@
 promise_test(function() {
     return fetch("../resources/data.json").then(function(response) {
         response.blob();
-        assert_equals(response.body, null);
+        assert_not_equals(response.body, null);
+        assert_throws(new TypeError(), function() { response.body.getReader(); });
     });
-}, "Getting a null body after consuming as blob");
+}, "Getting a body reader after consuming as blob");
 
 promise_test(function() {
     return fetch("../resources/data.json").then(function(response) {
         response.text();
-        assert_equals(response.body, null);
+        assert_not_equals(response.body, null);
+        assert_throws(new TypeError(), function() { response.body.getReader(); });
     });
-}, "Getting a null body after consuming as text");
+}, "Getting a body reader after consuming as text");
 
 promise_test(function() {
     return fetch("../resources/data.json").then(function(response) {
         response.json();
-        assert_equals(response.body, null);
+        assert_not_equals(response.body, null);
+        assert_throws(new TypeError(), function() { response.body.getReader(); });
     });
-}, "Getting a null body after consuming as json");
+}, "Getting a body reader after consuming as json");
 
 promise_test(function() {
     return fetch("../resources/data.json").then(function(response) {
         response.arrayBuffer();
-        assert_equals(response.body, null);
+        assert_not_equals(response.body, null);
+        assert_throws(new TypeError(), function() { response.body.getReader(); });
     });
-}, "Getting a null body after consuming as arrayBuffer");
+}, "Getting a body reader after consuming as arrayBuffer");
 
     </script>
   </body>
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to