Skip to content

Commit

Permalink
stream: treat null asyncIterator as undefined
Browse files Browse the repository at this point in the history
According to the spec, getIterator should normalize incoming method to
undefined if it is either undefined or null. This PR enforces that spec
compliance with passed WPT.

PR-URL: #55119
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Matthew Aitken <maitken033380023@gmail.com>
Reviewed-By: Mattias Buelens <mattias@buelens.com>
  • Loading branch information
jazelly authored and marco-ippolito committed Nov 17, 2024
1 parent 81bcec0 commit f10d9ad
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 8 deletions.
3 changes: 2 additions & 1 deletion lib/internal/webstreams/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -230,11 +230,12 @@ function createAsyncFromSyncIterator(syncIteratorRecord) {
return { iterator: asyncIterator, nextMethod, done: false };
}

// Refs: https://tc39.es/ecma262/#sec-getiterator
function getIterator(obj, kind = 'sync', method) {
if (method === undefined) {
if (kind === 'async') {
method = obj[SymbolAsyncIterator];
if (method === undefined) {
if (method == null) {
const syncMethod = obj[SymbolIterator];

if (syncMethod === undefined) {
Expand Down
7 changes: 0 additions & 7 deletions test/wpt/status/streams.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,6 @@
"readable-streams/cross-realm-crash.window.js": {
"skip": "Browser-specific test"
},
"readable-streams/from.any.js": {
"fail": {
"expected": [
"ReadableStream.from ignores a null @@asyncIterator"
]
}
},
"readable-streams/owning-type-message-port.any.js": {
"fail": {
"note": "Readable streams with type owning are not yet supported",
Expand Down

0 comments on commit f10d9ad

Please sign in to comment.