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

Side by Side Diff: third_party/WebKit/LayoutTests/http/tests/streams/readable-streams/bad-underlying-sources.js

Issue 1902673003: Reflect recent spec changes to V8 Extra ReadableStream impl (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed build Created 4 years, 7 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 'use strict'; 1 'use strict';
2 2
3 if (self.importScripts) { 3 if (self.importScripts) {
4 self.importScripts('/resources/testharness.js'); 4 self.importScripts('/resources/testharness.js');
5 } 5 }
6 6
7 7
8 test(() => { 8 test(() => {
9 9
10 const theError = new Error('a unique string'); 10 const theError = new Error('a unique string');
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 promise_test(() => { 146 promise_test(() => {
147 147
148 let controller; 148 let controller;
149 const rs = new ReadableStream({ 149 const rs = new ReadableStream({
150 start(c) { 150 start(c) {
151 controller = c; 151 controller = c;
152 } 152 }
153 }); 153 });
154 154
155 rs.cancel(); 155 rs.cancel();
156 controller.enqueue('a'); // Calling enqueue after canceling should not throw a nything. 156 assert_throws(new TypeError, () => controller.enqueue('a'), 'Calling enqueue a fter canceling should throw');
157 157
158 return rs.getReader().closed; 158 return rs.getReader().closed;
159 159
160 }, 'Underlying source: calling enqueue on an empty canceled stream should not th row'); 160 }, 'Underlying source: calling enqueue on an empty canceled stream should throw' );
161 161
162 promise_test(() => { 162 promise_test(() => {
163 163
164 let controller; 164 let controller;
165 const rs = new ReadableStream({ 165 const rs = new ReadableStream({
166 start(c) { 166 start(c) {
167 c.enqueue('a'); 167 c.enqueue('a');
168 c.enqueue('b'); 168 c.enqueue('b');
169 controller = c; 169 controller = c;
170 } 170 }
171 }); 171 });
172 172
173 rs.cancel(); 173 rs.cancel();
174 controller.enqueue('c'); // Calling enqueue after canceling should not throw a nything. 174 assert_throws(new TypeError, () => controller.enqueue('c'), 'Calling enqueue a fter canceling should throw');
175 175
176 return rs.getReader().closed; 176 return rs.getReader().closed;
177 177
178 }, 'Underlying source: calling enqueue on a non-empty canceled stream should not throw'); 178 }, 'Underlying source: calling enqueue on a non-empty canceled stream should thr ow');
179 179
180 promise_test(() => { 180 promise_test(() => {
181 181
182 return new ReadableStream({ 182 return new ReadableStream({
183 start(c) { 183 start(c) {
184 c.close(); 184 c.close();
185 assert_throws(new TypeError(), () => c.enqueue('a'), 'call to enqueue shou ld throw a TypeError'); 185 assert_throws(new TypeError(), () => c.enqueue('a'), 'call to enqueue shou ld throw a TypeError');
186 } 186 }
187 }).getReader().closed; 187 }).getReader().closed;
188 188
189 }, 'Underlying source: calling enqueue on a closed stream should throw'); 189 }, 'Underlying source: calling enqueue on a closed stream should throw');
190 190
191 promise_test(t => { 191 promise_test(t => {
192 192
193 const theError = new Error('boo'); 193 const theError = new Error('boo');
194 const closed = new ReadableStream({ 194 const closed = new ReadableStream({
195 start(c) { 195 start(c) {
196 c.error(theError); 196 c.error(theError);
197 assert_throws(theError, () => c.enqueue('a'), 'call to enqueue should thro w the error'); 197 assert_throws(new TypeError(), () => c.enqueue('a'), 'call to enqueue shou ld throw the error');
198 } 198 }
199 }).getReader().closed; 199 }).getReader().closed;
200 200
201 return promise_rejects(t, theError, closed); 201 return promise_rejects(t, theError, closed);
202 202
203 }, 'Underlying source: calling enqueue on an errored stream should throw'); 203 }, 'Underlying source: calling enqueue on an errored stream should throw');
204 204
205 promise_test(() => { 205 promise_test(() => {
206 206
207 return new ReadableStream({ 207 return new ReadableStream({
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 let controller; 244 let controller;
245 let startCalled = false; 245 let startCalled = false;
246 const rs = new ReadableStream({ 246 const rs = new ReadableStream({
247 start(c) { 247 start(c) {
248 controller = c; 248 controller = c;
249 startCalled = true; 249 startCalled = true;
250 } 250 }
251 }); 251 });
252 252
253 rs.cancel(); 253 rs.cancel();
254 controller.close(); // Calling close after canceling should not throw anything . 254 assert_throws(new TypeError(), () => controller.close(), 'Calling close after canceling should throw');
255 255
256 return rs.getReader().closed.then(() => { 256 return rs.getReader().closed.then(() => {
257 assert_true(startCalled); 257 assert_true(startCalled);
258 }); 258 });
259 259
260 }, 'Underlying source: calling close on an empty canceled stream should not thro w'); 260 }, 'Underlying source: calling close on an empty canceled stream should throw');
261 261
262 promise_test(() => { 262 promise_test(() => {
263 263
264 let controller; 264 let controller;
265 let startCalled = false; 265 let startCalled = false;
266 const rs = new ReadableStream({ 266 const rs = new ReadableStream({
267 start(c) { 267 start(c) {
268 controller = c; 268 controller = c;
269 c.enqueue('a'); 269 c.enqueue('a');
270 startCalled = true; 270 startCalled = true;
271 } 271 }
272 }); 272 });
273 273
274 rs.cancel(); 274 rs.cancel();
275 controller.close(); // Calling close after canceling should not throw anything . 275 assert_throws(new TypeError(), () => controller.close(), 'Calling close after canceling should throw');
276 276
277 return rs.getReader().closed.then(() => { 277 return rs.getReader().closed.then(() => {
278 assert_true(startCalled); 278 assert_true(startCalled);
279 }); 279 });
280 280
281 }, 'Underlying source: calling close on a non-empty canceled stream should not t hrow'); 281 }, 'Underlying source: calling close on a non-empty canceled stream should throw ');
282 282
283 promise_test(() => { 283 promise_test(() => {
284 284
285 const theError = new Error('boo'); 285 const theError = new Error('boo');
286 let startCalled = false; 286 let startCalled = false;
287 287
288 const closed = new ReadableStream({ 288 const closed = new ReadableStream({
289 start(c) { 289 start(c) {
290 c.error(theError); 290 c.error(theError);
291 assert_throws(new TypeError(), () => c.close(), 'call to close should thro w a TypeError'); 291 assert_throws(new TypeError(), () => c.close(), 'call to close should thro w a TypeError');
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
374 374
375 return closed.catch(e => { 375 return closed.catch(e => {
376 assert_true(startCalled); 376 assert_true(startCalled);
377 assert_equals(e, firstError, 'closed should reject with the first error'); 377 assert_equals(e, firstError, 'closed should reject with the first error');
378 }); 378 });
379 379
380 }, 'Underlying source: calling error and returning a rejected promise from pull should cause the stream to error ' + 380 }, 'Underlying source: calling error and returning a rejected promise from pull should cause the stream to error ' +
381 'with the first error'); 381 'with the first error');
382 382
383 done(); 383 done();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698