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

Side by Side Diff: third_party/WebKit/LayoutTests/http/tests/fetch/script-tests/stream-reader.js

Issue 2439673002: [Fetch API] Streaming error should be reported as a TypeError (Closed)
Patch Set: fix Created 4 years, 2 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 unified diff | Download patch
OLDNEW
1 if (self.importScripts) { 1 if (self.importScripts) {
2 importScripts('/fetch/resources/fetch-test-helpers.js'); 2 importScripts('/fetch/resources/fetch-test-helpers.js');
3 importScripts('/streams/resources/rs-utils.js'); 3 importScripts('/streams/resources/rs-utils.js');
4 } 4 }
5 5
6 promise_test(function(t) { 6 promise_test(function(t) {
7 return fetch('/fetch/resources/doctype.html').then(function(res) { 7 return fetch('/fetch/resources/doctype.html').then(function(res) {
8 var stream = res.body; 8 var stream = res.body;
9 var reader = stream.getReader(); 9 var reader = stream.getReader();
10 assert_throws({name: 'TypeError'}, function() { stream.getReader() }); 10 assert_throws({name: 'TypeError'}, function() { stream.getReader() });
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 res.body.cancel(); 89 res.body.cancel();
90 assert_true(res.bodyUsed); 90 assert_true(res.bodyUsed);
91 assert_false(clone.bodyUsed); 91 assert_false(clone.bodyUsed);
92 return clone.arrayBuffer(); 92 return clone.arrayBuffer();
93 }).then(function(r) { 93 }).then(function(r) {
94 assert_equals(r.byteLength, 190); 94 assert_equals(r.byteLength, 190);
95 assert_true(clone.bodyUsed); 95 assert_true(clone.bodyUsed);
96 }); 96 });
97 }, 'Cancelling stream should not affect cloned one.'); 97 }, 'Cancelling stream should not affect cloned one.');
98 98
99 promise_test(t => {
100 let reader;
101 return fetch('/fetch/resources/slow-failure.cgi').then(res => {
102 reader = res.body.getReader();
103 return readableStreamToArray(res.body, reader);
104 }).then(unreached_fulfillment(t), e => {
105 reader.releaseLock();
106 assert_equals(e.name, 'TypeError');
107 });
108 }, 'Streaming error should be reported as a TypeError.');
109
99 done(); 110 done();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698