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/update WPTs with AbortSignal's abort reason #31400

Merged

Conversation

nidhijaju
Copy link
Member

@nidhijaju nidhijaju commented Oct 27, 2021

This PR updates the existing aborting test cases to check the ctrl.signal.reason again, which was initially removed in #31293 when abortReason was removed from the spec.

I've also parameterized a few test cases to check the AbortSignal's abort reason is properly used in rs.pipeTo() calls.

See whatwg/streams#1182 for the accompanying spec change.

/cc @yutakahirano, @MattiasBuelens

streams/piping/abort.any.js Outdated Show resolved Hide resolved
assert_equals(rs.events[0], 'cancel', 'first event should be cancel');
assert_equals(rs.events[1].name, reason, 'the argument to cancel should be reason');
}, 'an aborted signal should cause the writable stream to reject with the signal\'s abort reason');

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we want to have a test for the case where the pipeTo operation is aborted after it started.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Other tests in this file already handle such cases. However, they always call abortController.abort(). Should we parameterize some of these tests, so you can run them with abort() or with abort(reason)? 🤔

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a fair point. A lot of the tests are either of the form "prevent... should prevent ....", "abort signal takes priority over ...", or "abort should do nothing after ..." which IIUC doesn't really make sense to test for the abort reason specifically. I've looked through the rest and tried parameterizing a few that seemed useful to me, but if you think there's any others I should do as well, please let me know :)

streams/piping/abort.any.js Outdated Show resolved Hide resolved
streams/writable-streams/aborting.any.js Outdated Show resolved Hide resolved
ws.getWriter().closed.catch(e => {
assert_equals(e, error, 'the writable should be errored with the same object');
for (const reason of [null, undefined, error1]) {
promise_test(() => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about making this an async function?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I kept the tests using Promise chains to stay consistent because all of the other tests in the file also used them. Although I agree using async/await is slightly more readable, would it be weird if some tests use async/await, while the rest still have Promise chains? (just wondering because I'm not sure what the norm is)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nevermind, I've made it an async function now, but if you think I should change it back, please let me know.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would it be weird if some tests use async/await, while the rest still have Promise chains?

I don't think that's a problem. @ricea do you have any opinions?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I actually just talked to Adam offline, and he mentioned preferring async/await in newer tests now.

streams/writable-streams/aborting.any.js Outdated Show resolved Hide resolved
streams/piping/abort.any.js Outdated Show resolved Hide resolved
streams/piping/abort.any.js Outdated Show resolved Hide resolved
streams/piping/abort.any.js Outdated Show resolved Hide resolved
streams/piping/abort.any.js Outdated Show resolved Hide resolved
Copy link
Contributor

@yutakahirano yutakahirano left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@nidhijaju nidhijaju merged commit b724cac into web-platform-tests:master Nov 9, 2021
@nidhijaju
Copy link
Member Author

Thank you for reviewing!

Gabisampaio pushed a commit to Gabisampaio/wpt that referenced this pull request Nov 18, 2021
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.

5 participants