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

Unified Diff: LayoutTests/http/tests/fetch/script-tests/stream-reader.js

Issue 1053503002: [Fetch] Response.clone should tee the body stream. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 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
« no previous file with comments | « LayoutTests/http/tests/fetch/script-tests/response.js ('k') | Source/modules/fetch/Body.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: LayoutTests/http/tests/fetch/script-tests/stream-reader.js
diff --git a/LayoutTests/http/tests/fetch/script-tests/stream-reader.js b/LayoutTests/http/tests/fetch/script-tests/stream-reader.js
index 3faa1f855fd8017420c666021a44d3ad23f58c16..a10a62e9e6df4ffbd353c7e3292bdbb3d8610591 100644
--- a/LayoutTests/http/tests/fetch/script-tests/stream-reader.js
+++ b/LayoutTests/http/tests/fetch/script-tests/stream-reader.js
@@ -105,13 +105,29 @@ sequential_promise_test(function(t) {
assert_not_equals(read, 190);
reader.releaseLock();
- return read_until_end(original.clone().body.getReader());
- }).then(function(chunks) {
- for (var chunk of chunks) {
- read += chunk.byteLength;
+ var original_body = original.body;
+ var clone = original.clone();
+ assert_not_equals(original.body, clone.body);
+ assert_not_equals(original.body, original_body);
+ assert_not_equals(clone.body, original_body);
+ assert_throws({name: 'TypeError'}, function() {
+ original_body.getReader();
+ });
+ var reader1 = original.body.getReader();
+ var reader2 = clone.body.getReader();
+ return Promise.all([read_until_end(reader1), read_until_end(reader2)]);
+ }).then(function(r) {
+ var read1 = 0;
+ var read2 = 0;
+ for (var chunk of r[0]) {
+ read1 += chunk.byteLength;
+ }
+ for (var chunk of r[1]) {
+ read2 += chunk.byteLength;
}
// Make sure that we received all data in total.
- assert_equals(read, 190);
+ assert_equals(read + read1, 190);
+ assert_equals(read + read2, 190);
});
}, 'Clone after reading partially');
« no previous file with comments | « LayoutTests/http/tests/fetch/script-tests/response.js ('k') | Source/modules/fetch/Body.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698