From f10d9ad2839d7ef2f3c65e482327773f05c5f70a 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 47b557c69cf676..8f4c9a102312a5 100644 --- a/lib/internal/webstreams/util.js +++ b/lib/internal/webstreams/util.js @@ -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) { 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",