Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
add test
  • Loading branch information
MoonBall committed Jan 4, 2022
commit c308d8aa4012580a25cd123d2104b8b990b41cb2
30 changes: 30 additions & 0 deletions test/parallel/test-whatwg-readablestream.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,36 @@ const {
assert(r.locked);
}

{
// Throw error and return rejected promise in `cancel()` method
// would execute same cleanup code
const r1 = new ReadableStream({
cancel: () => {
return Promise.reject('Cancel Error');
},
});
r1.cancel().finally(common.mustCall(() => {
const controllerState = r1[kState].controller[kState];

assert.deepEqual(controllerState.pullAlgorithm, undefined)
assert.deepEqual(controllerState.cancelAlgorithm, undefined)
assert.deepEqual(controllerState.sizeAlgorithm, undefined)
})).catch(() => {});

const r2 = new ReadableStream({
cancel() {
throw Error('Cancel Error');
}
});
r2.cancel().finally(common.mustCall(() => {
const controllerState = r2[kState].controller[kState];

assert.deepEqual(controllerState.pullAlgorithm, undefined)
assert.deepEqual(controllerState.cancelAlgorithm, undefined)
assert.deepEqual(controllerState.sizeAlgorithm, undefined)
})).catch(() => {});
}

{
const source = {
start: common.mustCall((controller) => {
Expand Down