-
Notifications
You must be signed in to change notification settings - Fork 3.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[streams] Add tests for aborting pipeTo() #13358
Conversation
Add tests for aborting ReadableStream.prototype.pipeTo using an AbortSignal. Tests correspond to PR whatwg/streams#744.
The reference implementation now supports the "signal" option to pipeTo(). It has diverged from the standard text, which will be updated separately. Tests are at web-platform-tests/wpt#13358.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall LGTM, some minor suggestions. A bit amused that almost all of the tests use an already-aborted signal, but I guess that's where the edge cases lie.
OK, here's a suggestion: wait for the pipe to complete successfully, then abort the signal, and make sure that doesn't somehow error/cancel the streams? I dunno, maybe that's too silly.
streams/piping/abort.js
Outdated
} | ||
}); | ||
const ws = new WritableStream(); | ||
return promise_rejects(t, new TypeError(), rs.pipeTo(ws, { signal: invalidSignal }), 'pipeTo should reject'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we test that this never calls any underlying source methods?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea. Done.
.then(() => { | ||
assert_equals(rs.events.length, 2, 'cancel should have been called'); | ||
assert_equals(rs.events[0], 'cancel', 'first event should be cancel'); | ||
assert_equals(rs.events[1].name, 'AbortError', 'the argument to cancel should be an AbortError'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe also test that its .constructor.name is DOMException.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
Also check the constructor name of the AbortError is DOMException.
I will write tests for abort-after-completion. That was an important oversight. |
The reference implementation now supports the "signal" option to pipeTo(). It has diverged from the standard text, which will be updated separately. Tests are at web-platform-tests/wpt#13358.
Once a shutdown condition happens, aborting the signal should no longer do anything. Verify this works.
Use preventCancel, preventClose and preventAbort to keep the readable or writable open after the pipeTo finishes to verify that the abort doesn't close them.
Add tests for aborting ReadableStream.prototype.pipeTo using an
AbortSignal.
Tests correspond to PR whatwg/streams#744.