From 87a79cd8a1d02316978a643c459174eac3a436c8 Mon Sep 17 00:00:00 2001 From: Jason Zhang Date: Sat, 28 Sep 2024 00:04:11 +0930 Subject: [PATCH] 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 Reviewed-By: Matthew Aitken Reviewed-By: Mattias Buelens --- lib/internal/webstreams/util.js | 3 ++- test/wpt/status/streams.json | 7 ------- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/lib/internal/webstreams/util.js b/lib/internal/webstreams/util.js index cace607a077618..2c70ef7acdfe66 100644 --- a/lib/internal/webstreams/util.js +++ b/lib/internal/webstreams/util.js @@ -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) { diff --git a/test/wpt/status/streams.json b/test/wpt/status/streams.json index 5425c86bba8507..af3646c65ea660 100644 --- a/test/wpt/status/streams.json +++ b/test/wpt/status/streams.json @@ -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",