From 0a4ffe8adf3665ebe6d34c6ac0f6a31f4360c314 Mon Sep 17 00:00:00 2001 From: Jason Zhang Date: Wed, 25 Sep 2024 23:45:58 +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. --- 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 cace607a0776..2c70ef7acdfe 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 5425c86bba85..af3646c65ea6 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",