Skip to content
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

Merged
merged 7 commits into from
Nov 7, 2018

Conversation

ricea
Copy link
Contributor

@ricea ricea commented Oct 4, 2018

Add tests for aborting ReadableStream.prototype.pipeTo using an
AbortSignal.

Tests correspond to PR whatwg/streams#744.

Add tests for aborting ReadableStream.prototype.pipeTo using an
AbortSignal.

Tests correspond to PR whatwg/streams#744.
ricea added a commit to whatwg/streams that referenced this pull request Oct 4, 2018
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.
Copy link
Member

@domenic domenic left a 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.

}
});
const ws = new WritableStream();
return promise_rejects(t, new TypeError(), rs.pipeTo(ws, { signal: invalidSignal }), 'pipeTo should reject');
Copy link
Member

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?

Copy link
Contributor Author

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');
Copy link
Member

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.

Copy link
Contributor Author

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.
@ricea
Copy link
Contributor Author

ricea commented Oct 11, 2018

I will write tests for abort-after-completion. That was an important oversight.

ricea added a commit to whatwg/streams that referenced this pull request Oct 19, 2018
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.
ricea added 3 commits October 22, 2018 17:47
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.
@domenic domenic merged commit 349d418 into web-platform-tests:master Nov 7, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants