stream: treat null asyncIterator as undefined

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: https://github.com/nodejs/node/pull/55119
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Matthew Aitken <maitken033380023@gmail.com>
Reviewed-By: Mattias Buelens <mattias@buelens.com>
This commit is contained in:
Jason Zhang 2024-09-28 00:04:11 +09:30 committed by GitHub
parent fb852798dc
commit 87a79cd8a1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 2 additions and 8 deletions

View File

@ -211,11 +211,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) {

View File

@ -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",