| OLD | NEW |
| (Empty) | |
| 1 'use strict'; |
| 2 |
| 3 if (self.importScripts) { |
| 4 self.importScripts('/resources/testharness.js'); |
| 5 self.importScripts('../resources/test-utils.js'); |
| 6 self.importScripts('../resources/recording-streams.js'); |
| 7 } |
| 8 |
| 9 const error1 = new Error('error1!'); |
| 10 error1.name = 'error1'; |
| 11 |
| 12 const error2 = new Error('error2!'); |
| 13 error2.name = 'error2'; |
| 14 |
| 15 promise_test(t => { |
| 16 |
| 17 const rs = recordingReadableStream(); |
| 18 |
| 19 const ws = recordingWritableStream({ |
| 20 start() { |
| 21 return Promise.reject(error1); |
| 22 } |
| 23 }); |
| 24 |
| 25 return promise_rejects(t, error1, rs.pipeTo(ws), 'pipeTo must reject with the
same error') |
| 26 .then(() => { |
| 27 assert_array_equals(rs.eventsWithoutPulls, ['cancel', error1]); |
| 28 assert_array_equals(ws.events, []); |
| 29 }); |
| 30 |
| 31 }, 'Errors must be propagated backward: starts errored; preventCancel omitted; f
ulfilled cancel promise'); |
| 32 |
| 33 promise_test(t => { |
| 34 |
| 35 const rs = recordingReadableStream(); |
| 36 |
| 37 const ws = recordingWritableStream({ |
| 38 write() { |
| 39 return Promise.reject(error1); |
| 40 } |
| 41 }); |
| 42 |
| 43 const writer = ws.getWriter(); |
| 44 |
| 45 return promise_rejects(t, error1, writer.write('Hello'), 'writer.write() must
reject with the write error') |
| 46 .then(() => promise_rejects(t, error1, writer.closed, 'writer.closed must re
ject with the write error')) |
| 47 .then(() => { |
| 48 writer.releaseLock(); |
| 49 |
| 50 return promise_rejects(t, error1, rs.pipeTo(ws), 'pipeTo must reject with
the write error') |
| 51 .then(() => { |
| 52 assert_array_equals(rs.eventsWithoutPulls, ['cancel', error1]); |
| 53 assert_array_equals(ws.events, ['write', 'Hello']); |
| 54 }); |
| 55 }); |
| 56 |
| 57 }, 'Errors must be propagated backward: becomes errored before piping due to wri
te; preventCancel omitted; ' + |
| 58 'fulfilled cancel promise'); |
| 59 |
| 60 promise_test(t => { |
| 61 |
| 62 const rs = recordingReadableStream({ |
| 63 cancel() { |
| 64 throw error2; |
| 65 } |
| 66 }); |
| 67 |
| 68 const ws = recordingWritableStream({ |
| 69 write() { |
| 70 return Promise.reject(error1); |
| 71 } |
| 72 }); |
| 73 |
| 74 const writer = ws.getWriter(); |
| 75 |
| 76 return promise_rejects(t, error1, writer.write('Hello'), 'writer.write() must
reject with the write error') |
| 77 .then(() => promise_rejects(t, error1, writer.closed, 'writer.closed must re
ject with the write error')) |
| 78 .then(() => { |
| 79 writer.releaseLock(); |
| 80 |
| 81 return promise_rejects(t, error2, rs.pipeTo(ws), 'pipeTo must reject with
the cancel error') |
| 82 .then(() => { |
| 83 assert_array_equals(rs.eventsWithoutPulls, ['cancel', error1]); |
| 84 assert_array_equals(ws.events, ['write', 'Hello']); |
| 85 }); |
| 86 }); |
| 87 |
| 88 }, 'Errors must be propagated backward: becomes errored before piping due to wri
te; preventCancel omitted; rejected ' + |
| 89 'cancel promise'); |
| 90 |
| 91 for (const falsy of [undefined, null, false, +0, -0, NaN, '']) { |
| 92 const stringVersion = Object.is(falsy, -0) ? '-0' : String(falsy); |
| 93 |
| 94 promise_test(t => { |
| 95 |
| 96 const rs = recordingReadableStream(); |
| 97 |
| 98 const ws = recordingWritableStream({ |
| 99 write() { |
| 100 return Promise.reject(error1); |
| 101 } |
| 102 }); |
| 103 |
| 104 const writer = ws.getWriter(); |
| 105 |
| 106 return promise_rejects(t, error1, writer.write('Hello'), 'writer.write() mus
t reject with the write error') |
| 107 .then(() => promise_rejects(t, error1, writer.closed, 'writer.closed must
reject with the write error')) |
| 108 .then(() => { |
| 109 writer.releaseLock(); |
| 110 |
| 111 return promise_rejects(t, error1, rs.pipeTo(ws, { preventCancel: falsy }
), |
| 112 'pipeTo must reject with the write error') |
| 113 .then(() => { |
| 114 assert_array_equals(rs.eventsWithoutPulls, ['cancel', error1]); |
| 115 assert_array_equals(ws.events, ['write', 'Hello']); |
| 116 }); |
| 117 }); |
| 118 |
| 119 }, `Errors must be propagated backward: becomes errored before piping due to w
rite; preventCancel = ` + |
| 120 `${stringVersion} (falsy); fulfilled cancel promise`); |
| 121 } |
| 122 |
| 123 for (const truthy of [true, 'a', 1, Symbol(), { }]) { |
| 124 promise_test(t => { |
| 125 |
| 126 const rs = recordingReadableStream(); |
| 127 |
| 128 const ws = recordingWritableStream({ |
| 129 write() { |
| 130 return Promise.reject(error1); |
| 131 } |
| 132 }); |
| 133 |
| 134 const writer = ws.getWriter(); |
| 135 |
| 136 return promise_rejects(t, error1, writer.write('Hello'), 'writer.write() mus
t reject with the write error') |
| 137 .then(() => promise_rejects(t, error1, writer.closed, 'writer.closed must
reject with the write error')) |
| 138 .then(() => { |
| 139 writer.releaseLock(); |
| 140 |
| 141 return promise_rejects(t, error1, rs.pipeTo(ws, { preventCancel: truthy
}), |
| 142 'pipeTo must reject with the write error') |
| 143 .then(() => { |
| 144 assert_array_equals(rs.eventsWithoutPulls, []); |
| 145 assert_array_equals(ws.events, ['write', 'Hello']); |
| 146 }); |
| 147 }); |
| 148 |
| 149 }, `Errors must be propagated backward: becomes errored before piping due to w
rite; preventCancel = ` + |
| 150 `${String(truthy)} (truthy)`); |
| 151 } |
| 152 |
| 153 promise_test(t => { |
| 154 |
| 155 const rs = recordingReadableStream(); |
| 156 |
| 157 const ws = recordingWritableStream({ |
| 158 write() { |
| 159 return Promise.reject(error1); |
| 160 } |
| 161 }); |
| 162 |
| 163 const writer = ws.getWriter(); |
| 164 |
| 165 return promise_rejects(t, error1, writer.write('Hello'), 'writer.write() must
reject with the write error') |
| 166 .then(() => promise_rejects(t, error1, writer.closed, 'writer.closed must re
ject with the write error')) |
| 167 .then(() => { |
| 168 writer.releaseLock(); |
| 169 |
| 170 return promise_rejects(t, error1, rs.pipeTo(ws, { preventCancel: true, pre
ventAbort: true }), |
| 171 'pipeTo must reject with the write error') |
| 172 .then(() => { |
| 173 assert_array_equals(rs.eventsWithoutPulls, []); |
| 174 assert_array_equals(ws.events, ['write', 'Hello']); |
| 175 }); |
| 176 }); |
| 177 |
| 178 }, 'Errors must be propagated backward: becomes errored before piping due to wri
te, preventCancel = true; ' + |
| 179 'preventAbort = true'); |
| 180 |
| 181 promise_test(t => { |
| 182 |
| 183 const rs = recordingReadableStream(); |
| 184 |
| 185 const ws = recordingWritableStream({ |
| 186 write() { |
| 187 return Promise.reject(error1); |
| 188 } |
| 189 }); |
| 190 |
| 191 const writer = ws.getWriter(); |
| 192 |
| 193 return promise_rejects(t, error1, writer.write('Hello'), 'writer.write() must
reject with the write error') |
| 194 .then(() => promise_rejects(t, error1, writer.closed, 'writer.closed must re
ject with the write error')) |
| 195 .then(() => { |
| 196 writer.releaseLock(); |
| 197 |
| 198 return promise_rejects(t, error1, rs.pipeTo(ws, { preventCancel: true, pre
ventAbort: true, preventClose: true }), |
| 199 'pipeTo must reject with the write error') |
| 200 .then(() => { |
| 201 assert_array_equals(rs.eventsWithoutPulls, []); |
| 202 assert_array_equals(ws.events, ['write', 'Hello']); |
| 203 }); |
| 204 }); |
| 205 |
| 206 }, 'Errors must be propagated backward: becomes errored before piping due to wri
te; preventCancel = true, ' + |
| 207 'preventAbort = true, preventClose = true'); |
| 208 |
| 209 promise_test(t => { |
| 210 |
| 211 const rs = recordingReadableStream({ |
| 212 start(controller) { |
| 213 controller.enqueue('Hello'); |
| 214 } |
| 215 }); |
| 216 |
| 217 const ws = recordingWritableStream({ |
| 218 write() { |
| 219 throw error1; |
| 220 } |
| 221 }); |
| 222 |
| 223 return promise_rejects(t, error1, rs.pipeTo(ws), 'pipeTo must reject with the
same error').then(() => { |
| 224 assert_array_equals(rs.eventsWithoutPulls, ['cancel', error1]); |
| 225 assert_array_equals(ws.events, ['write', 'Hello']); |
| 226 }); |
| 227 |
| 228 }, 'Errors must be propagated backward: becomes errored during piping due to wri
te; preventCancel omitted; fulfilled ' + |
| 229 'cancel promise'); |
| 230 |
| 231 promise_test(t => { |
| 232 |
| 233 const rs = recordingReadableStream({ |
| 234 start(controller) { |
| 235 controller.enqueue('Hello'); |
| 236 }, |
| 237 cancel() { |
| 238 throw error2; |
| 239 } |
| 240 }); |
| 241 |
| 242 const ws = recordingWritableStream({ |
| 243 write() { |
| 244 throw error1; |
| 245 } |
| 246 }); |
| 247 |
| 248 return promise_rejects(t, error2, rs.pipeTo(ws), 'pipeTo must reject with the
cancel error').then(() => { |
| 249 assert_array_equals(rs.eventsWithoutPulls, ['cancel', error1]); |
| 250 assert_array_equals(ws.events, ['write', 'Hello']); |
| 251 }); |
| 252 |
| 253 }, 'Errors must be propagated backward: becomes errored during piping due to wri
te; preventCancel omitted; rejected ' + |
| 254 'cancel promise'); |
| 255 |
| 256 promise_test(t => { |
| 257 |
| 258 const rs = recordingReadableStream({ |
| 259 start(controller) { |
| 260 controller.enqueue('Hello'); |
| 261 } |
| 262 }); |
| 263 |
| 264 const ws = recordingWritableStream({ |
| 265 write() { |
| 266 throw error1; |
| 267 } |
| 268 }); |
| 269 |
| 270 return promise_rejects(t, error1, rs.pipeTo(ws, { preventCancel: true }), 'pip
eTo must reject with the same error') |
| 271 .then(() => { |
| 272 assert_array_equals(rs.eventsWithoutPulls, []); |
| 273 assert_array_equals(ws.events, ['write', 'Hello']); |
| 274 }); |
| 275 |
| 276 }, 'Errors must be propagated backward: becomes errored during piping due to wri
te; preventCancel = true'); |
| 277 |
| 278 promise_test(t => { |
| 279 |
| 280 const rs = recordingReadableStream({ |
| 281 start(controller) { |
| 282 controller.enqueue('a'); |
| 283 controller.enqueue('b'); |
| 284 controller.enqueue('c'); |
| 285 } |
| 286 }); |
| 287 |
| 288 const ws = recordingWritableStream({ |
| 289 write() { |
| 290 if (ws.events.length > 2) { |
| 291 return delay(0).then(() => { |
| 292 throw error1; |
| 293 }); |
| 294 } |
| 295 return undefined; |
| 296 } |
| 297 }); |
| 298 |
| 299 return promise_rejects(t, error1, rs.pipeTo(ws), 'pipeTo must reject with the
same error').then(() => { |
| 300 assert_array_equals(rs.eventsWithoutPulls, ['cancel', error1]); |
| 301 assert_array_equals(ws.events, ['write', 'a', 'write', 'b']); |
| 302 }); |
| 303 |
| 304 }, 'Errors must be propagated backward: becomes errored during piping due to wri
te, but async; preventCancel = ' + |
| 305 'false; fulfilled cancel promise'); |
| 306 |
| 307 promise_test(t => { |
| 308 |
| 309 const rs = recordingReadableStream({ |
| 310 start(controller) { |
| 311 controller.enqueue('a'); |
| 312 controller.enqueue('b'); |
| 313 controller.enqueue('c'); |
| 314 }, |
| 315 cancel() { |
| 316 throw error2; |
| 317 } |
| 318 }); |
| 319 |
| 320 const ws = recordingWritableStream({ |
| 321 write() { |
| 322 if (ws.events.length > 2) { |
| 323 return delay(0).then(() => { |
| 324 throw error1; |
| 325 }); |
| 326 } |
| 327 return undefined; |
| 328 } |
| 329 }); |
| 330 |
| 331 return promise_rejects(t, error2, rs.pipeTo(ws), 'pipeTo must reject with the
cancel error').then(() => { |
| 332 assert_array_equals(rs.eventsWithoutPulls, ['cancel', error1]); |
| 333 assert_array_equals(ws.events, ['write', 'a', 'write', 'b']); |
| 334 }); |
| 335 |
| 336 }, 'Errors must be propagated backward: becomes errored during piping due to wri
te, but async; preventCancel = ' + |
| 337 'false; rejected cancel promise'); |
| 338 |
| 339 promise_test(t => { |
| 340 |
| 341 const rs = recordingReadableStream({ |
| 342 start(controller) { |
| 343 controller.enqueue('a'); |
| 344 controller.enqueue('b'); |
| 345 controller.enqueue('c'); |
| 346 } |
| 347 }); |
| 348 |
| 349 const ws = recordingWritableStream({ |
| 350 write() { |
| 351 if (ws.events.length > 2) { |
| 352 return delay(0).then(() => { |
| 353 throw error1; |
| 354 }); |
| 355 } |
| 356 return undefined; |
| 357 } |
| 358 }); |
| 359 |
| 360 return promise_rejects(t, error1, rs.pipeTo(ws, { preventCancel: true }), 'pip
eTo must reject with the same error') |
| 361 .then(() => { |
| 362 assert_array_equals(rs.eventsWithoutPulls, []); |
| 363 assert_array_equals(ws.events, ['write', 'a', 'write', 'b']); |
| 364 }); |
| 365 |
| 366 }, 'Errors must be propagated backward: becomes errored during piping due to wri
te, but async; preventCancel = true'); |
| 367 |
| 368 promise_test(t => { |
| 369 |
| 370 const rs = recordingReadableStream(); |
| 371 |
| 372 const ws = recordingWritableStream(); |
| 373 |
| 374 const pipePromise = promise_rejects(t, error1, rs.pipeTo(ws), 'pipeTo must rej
ect with the same error'); |
| 375 |
| 376 setTimeout(() => ws.controller.error(error1), 10); |
| 377 |
| 378 return pipePromise.then(() => { |
| 379 assert_array_equals(rs.eventsWithoutPulls, ['cancel', error1]); |
| 380 assert_array_equals(ws.events, []); |
| 381 }); |
| 382 |
| 383 }, 'Errors must be propagated backward: becomes errored after piping; preventCan
cel omitted; fulfilled cancel promise'); |
| 384 |
| 385 promise_test(t => { |
| 386 |
| 387 const rs = recordingReadableStream({ |
| 388 cancel() { |
| 389 throw error2; |
| 390 } |
| 391 }); |
| 392 |
| 393 const ws = recordingWritableStream(); |
| 394 |
| 395 const pipePromise = promise_rejects(t, error2, rs.pipeTo(ws), 'pipeTo must rej
ect with the cancel error'); |
| 396 |
| 397 setTimeout(() => ws.controller.error(error1), 10); |
| 398 |
| 399 return pipePromise.then(() => { |
| 400 assert_array_equals(rs.eventsWithoutPulls, ['cancel', error1]); |
| 401 assert_array_equals(ws.events, []); |
| 402 }); |
| 403 |
| 404 }, 'Errors must be propagated backward: becomes errored after piping; preventCan
cel omitted; rejected cancel promise'); |
| 405 |
| 406 promise_test(t => { |
| 407 |
| 408 const rs = recordingReadableStream(); |
| 409 |
| 410 const ws = recordingWritableStream(); |
| 411 |
| 412 const pipePromise = promise_rejects(t, error1, rs.pipeTo(ws, { preventCancel:
true }), |
| 413 'pipeTo must reject with the same error'); |
| 414 |
| 415 setTimeout(() => ws.controller.error(error1), 10); |
| 416 |
| 417 return pipePromise.then(() => { |
| 418 assert_array_equals(rs.eventsWithoutPulls, []); |
| 419 assert_array_equals(ws.events, []); |
| 420 }); |
| 421 |
| 422 }, 'Errors must be propagated backward: becomes errored after piping; preventCan
cel = true'); |
| 423 |
| 424 promise_test(t => { |
| 425 |
| 426 const rs = recordingReadableStream({ |
| 427 start(controller) { |
| 428 controller.enqueue('a'); |
| 429 controller.enqueue('b'); |
| 430 controller.enqueue('c'); |
| 431 controller.close(); |
| 432 } |
| 433 }); |
| 434 |
| 435 const ws = recordingWritableStream({ |
| 436 write(chunk) { |
| 437 if (chunk === 'c') { |
| 438 return Promise.reject(error1); |
| 439 } |
| 440 return undefined; |
| 441 } |
| 442 }); |
| 443 |
| 444 return promise_rejects(t, error1, rs.pipeTo(ws), 'pipeTo must reject with the
same error').then(() => { |
| 445 assert_array_equals(rs.eventsWithoutPulls, []); |
| 446 assert_array_equals(ws.events, ['write', 'a', 'write', 'b', 'write', 'c']); |
| 447 }); |
| 448 |
| 449 }, 'Errors must be propagated backward: becomes errored after piping due to last
write; source is closed; ' + |
| 450 'preventCancel omitted (but cancel is never called)'); |
| 451 |
| 452 promise_test(t => { |
| 453 |
| 454 const rs = recordingReadableStream({ |
| 455 start(controller) { |
| 456 controller.enqueue('a'); |
| 457 controller.enqueue('b'); |
| 458 controller.enqueue('c'); |
| 459 controller.close(); |
| 460 } |
| 461 }); |
| 462 |
| 463 const ws = recordingWritableStream({ |
| 464 write(chunk) { |
| 465 if (chunk === 'c') { |
| 466 return Promise.reject(error1); |
| 467 } |
| 468 return undefined; |
| 469 } |
| 470 }); |
| 471 |
| 472 return promise_rejects(t, error1, rs.pipeTo(ws, { preventCancel: true }), 'pip
eTo must reject with the same error') |
| 473 .then(() => { |
| 474 assert_array_equals(rs.eventsWithoutPulls, []); |
| 475 assert_array_equals(ws.events, ['write', 'a', 'write', 'b', 'write', 'c'])
; |
| 476 }); |
| 477 |
| 478 }, 'Errors must be propagated backward: becomes errored after piping due to last
write; source is closed; ' + |
| 479 'preventCancel = true'); |
| 480 |
| 481 promise_test(t => { |
| 482 |
| 483 const rs = recordingReadableStream(); |
| 484 |
| 485 const ws = recordingWritableStream(undefined, new CountQueuingStrategy({ highW
aterMark: 0 })); |
| 486 |
| 487 const pipePromise = promise_rejects(t, error1, rs.pipeTo(ws), 'pipeTo must rej
ect with the same error'); |
| 488 |
| 489 setTimeout(() => ws.controller.error(error1), 10); |
| 490 |
| 491 return pipePromise.then(() => { |
| 492 assert_array_equals(rs.eventsWithoutPulls, ['cancel', error1]); |
| 493 assert_array_equals(ws.events, []); |
| 494 }); |
| 495 |
| 496 }, 'Errors must be propagated backward: becomes errored after piping; dest never
desires chunks; preventCancel = ' + |
| 497 'false; fulfilled cancel promise'); |
| 498 |
| 499 promise_test(t => { |
| 500 |
| 501 const rs = recordingReadableStream({ |
| 502 cancel() { |
| 503 throw error2; |
| 504 } |
| 505 }); |
| 506 |
| 507 const ws = recordingWritableStream(undefined, new CountQueuingStrategy({ highW
aterMark: 0 })); |
| 508 |
| 509 const pipePromise = promise_rejects(t, error2, rs.pipeTo(ws), 'pipeTo must rej
ect with the cancel error'); |
| 510 |
| 511 setTimeout(() => ws.controller.error(error1), 10); |
| 512 |
| 513 return pipePromise.then(() => { |
| 514 assert_array_equals(rs.eventsWithoutPulls, ['cancel', error1]); |
| 515 assert_array_equals(ws.events, []); |
| 516 }); |
| 517 |
| 518 }, 'Errors must be propagated backward: becomes errored after piping; dest never
desires chunks; preventCancel = ' + |
| 519 'false; rejected cancel promise'); |
| 520 |
| 521 promise_test(t => { |
| 522 |
| 523 const rs = recordingReadableStream(); |
| 524 |
| 525 const ws = recordingWritableStream(undefined, new CountQueuingStrategy({ highW
aterMark: 0 })); |
| 526 |
| 527 const pipePromise = promise_rejects(t, error1, rs.pipeTo(ws, { preventCancel:
true }), |
| 528 'pipeTo must reject with the same error'); |
| 529 |
| 530 setTimeout(() => ws.controller.error(error1), 10); |
| 531 |
| 532 return pipePromise.then(() => { |
| 533 assert_array_equals(rs.eventsWithoutPulls, []); |
| 534 assert_array_equals(ws.events, []); |
| 535 }); |
| 536 |
| 537 }, 'Errors must be propagated backward: becomes errored after piping; dest never
desires chunks; preventCancel = ' + |
| 538 'true'); |
| 539 |
| 540 promise_test(() => { |
| 541 |
| 542 const rs = recordingReadableStream(); |
| 543 |
| 544 const ws = recordingWritableStream(); |
| 545 |
| 546 ws.abort(error1); |
| 547 |
| 548 return rs.pipeTo(ws).then( |
| 549 () => assert_unreached('the promise must not fulfill'), |
| 550 err => { |
| 551 assert_equals(err.name, 'TypeError', 'the promise must reject with a TypeE
rror (_not_ with error1)'); |
| 552 |
| 553 assert_array_equals(rs.eventsWithoutPulls, ['cancel', err]); |
| 554 assert_array_equals(ws.events, ['abort', error1]); |
| 555 } |
| 556 ); |
| 557 |
| 558 }, 'Errors must be propagated backward: becomes errored before piping via abort;
preventCancel omitted; fulfilled ' + |
| 559 'cancel promise'); |
| 560 |
| 561 promise_test(t => { |
| 562 |
| 563 const rs = recordingReadableStream({ |
| 564 cancel() { |
| 565 throw error2; |
| 566 } |
| 567 }); |
| 568 |
| 569 const ws = recordingWritableStream(); |
| 570 |
| 571 ws.abort(error1); |
| 572 |
| 573 return promise_rejects(t, error2, rs.pipeTo(ws), 'pipeTo must reject with the
cancel error') |
| 574 .then(() => { |
| 575 return ws.getWriter().closed.then( |
| 576 () => assert_unreached('the promise must not fulfill'), |
| 577 err => { |
| 578 assert_equals(err.name, 'TypeError', 'the promise must reject with a T
ypeError (_not_ with error1)'); |
| 579 |
| 580 assert_array_equals(rs.eventsWithoutPulls, ['cancel', err]); |
| 581 assert_array_equals(ws.events, ['abort', error1]); |
| 582 } |
| 583 ); |
| 584 }); |
| 585 |
| 586 }, 'Errors must be propagated backward: becomes errored before piping via abort;
preventCancel omitted; rejected ' + |
| 587 'cancel promise'); |
| 588 |
| 589 promise_test(t => { |
| 590 |
| 591 const rs = recordingReadableStream(); |
| 592 |
| 593 const ws = recordingWritableStream(); |
| 594 |
| 595 ws.abort(error1); |
| 596 |
| 597 return promise_rejects(t, new TypeError(), rs.pipeTo(ws, { preventCancel: true
})).then(() => { |
| 598 assert_array_equals(rs.eventsWithoutPulls, []); |
| 599 assert_array_equals(ws.events, ['abort', error1]); |
| 600 }); |
| 601 |
| 602 }, 'Errors must be propagated backward: becomes errored before piping via abort;
preventCancel = true'); |
| 603 |
| 604 promise_test(t => { |
| 605 |
| 606 const rs = recordingReadableStream(); |
| 607 |
| 608 let resolveWriteCalled; |
| 609 const writeCalledPromise = new Promise(resolve => { |
| 610 resolveWriteCalled = resolve; |
| 611 }); |
| 612 |
| 613 const ws = recordingWritableStream({ |
| 614 write() { |
| 615 resolveWriteCalled(); |
| 616 return flushAsyncEvents(); |
| 617 } |
| 618 }); |
| 619 |
| 620 const pipePromise = rs.pipeTo(ws); |
| 621 |
| 622 rs.controller.enqueue('a'); |
| 623 |
| 624 return writeCalledPromise.then(() => { |
| 625 ws.controller.error(error1); |
| 626 |
| 627 return promise_rejects(t, error1, pipePromise); |
| 628 }).then(() => { |
| 629 assert_array_equals(rs.eventsWithoutPulls, ['cancel', error1]); |
| 630 assert_array_equals(ws.events, ['write', 'a']); |
| 631 }); |
| 632 |
| 633 }, 'Errors must be propagated backward: erroring via the controller errors once
pending write completes'); |
| 634 |
| 635 done(); |
| OLD | NEW |