Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(445)

Unified Diff: third_party/WebKit/LayoutTests/external/wpt/fetch/api/response/response-consume-stream.html

Issue 2778753002: Import //fetch from Web Platform Tests. (Closed)
Patch Set: Baselines. Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/LayoutTests/external/wpt/fetch/api/response/response-consume-stream.html
diff --git a/third_party/WebKit/LayoutTests/external/wpt/fetch/api/response/response-consume-stream.html b/third_party/WebKit/LayoutTests/external/wpt/fetch/api/response/response-consume-stream.html
new file mode 100644
index 0000000000000000000000000000000000000000..54d55fcb45f05efcff13efa369cbbd345447acd2
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/external/wpt/fetch/api/response/response-consume-stream.html
@@ -0,0 +1,73 @@
+<!doctype html>
+<html>
+ <head>
+ <meta charset="utf-8">
+ <title>Response consume</title>
+ <meta name="help" href="https://fetch.spec.whatwg.org/#response">
+ <meta name="help" href="https://fetch.spec.whatwg.org/#body-mixin">
+ <meta name="author" title="Canon Research France" href="https://www.crf.canon.fr">
+ <script src="/resources/testharness.js"></script>
+ <script src="/resources/testharnessreport.js"></script>
+ <script src="../resources/utils.js"></script>
+ </head>
+ <body>
+ <script>
+
+promise_test(function(test) {
+ var body = "";
+ var response = new Response("");
+ return validateStreamFromString(response.body.getReader(), "");
+}, "Read empty text response's body as readableStream");
+
+promise_test(function(test) {
+ var response = new Response(new Blob([], { "type" : "text/plain" }));
+ return validateStreamFromString(response.body.getReader(), "");
+}, "Read empty blob response's body as readableStream");
+
+var formData = new FormData();
+formData.append("name", "value");
+var textData = JSON.stringify("This is response's body");
+var blob = new Blob([textData], { "type" : "text/plain" });
+var urlSearchParamsData = "name=value";
+var urlSearchParams = new URLSearchParams(urlSearchParamsData);
+
+promise_test(function(test) {
+ var response = new Response(blob);
+ return validateStreamFromString(response.body.getReader(), textData);
+}, "Read blob response's body as readableStream");
+
+promise_test(function(test) {
+ var response = new Response(textData);
+ return validateStreamFromString(response.body.getReader(), textData);
+}, "Read text response's body as readableStream");
+
+promise_test(function(test) {
+ var response = new Response(urlSearchParams);
+ return validateStreamFromString(response.body.getReader(), urlSearchParamsData);
+}, "Read URLSearchParams response's body as readableStream");
+
+promise_test(function(test) {
+ var arrayBuffer = new ArrayBuffer(textData.length);
+ var int8Array = new Int8Array(arrayBuffer);
+ for (var cptr = 0; cptr < textData.length; cptr++)
+ int8Array[cptr] = textData.charCodeAt(cptr);
+
+ return validateStreamFromString(new Response(arrayBuffer).body.getReader(), textData);
+}, "Read array buffer response's body as readableStream");
+
+promise_test(function(test) {
+ var response = new Response(formData);
+ return validateStreamFromString(response.body.getReader(), "name=value");
+}, "Read form data response's body as readableStream");
+
+test(function() {
+ assert_equals(Response.error().body, null);
+}, "Getting an error Response stream");
+
+promise_test(function(test) {
+ assert_equals(Response.redirect(301).body, null);
+}, "Getting a redirect Response stream");
+
+ </script>
+ </body>
+</html>

Powered by Google App Engine
This is Rietveld 408576698