mirror of
https://github.com/denoland/deno.git
synced 2024-11-21 15:04:11 -05:00
fix(ext/web): ReadableStream.from()
ignores null Symbol.asyncIterator
(#23910)
If `@@asyncIterator` is `null` or `undefined`, it should ignores and fallback to `@@iterator`. Tests have been merged into WPT. https://github.com/web-platform-tests/wpt/pull/46374 The proposal of `ReadableStream.from` uses TC39 [GetIterator][] and [GetMethod][] within it. GetMethod treats null as undefined. So if `@@asyncIterator` is `null` it should be ignored and fallback to `@@iterator`. [GetIterator]: https://tc39.es/ecma262/#sec-getiterator [GetMethod]: https://tc39.es/ecma262/#sec-getmethod ```bash > deno eval "ReadableStream.from({ [Symbol.asyncIterator]: null, [Symbol.iterator]: () => ({ next: () => ({ done: true }) }) }).pipeTo(new WritableStream())" error: Uncaught (in promise) TypeError: obj[SymbolAsyncIterator] is not a function ReadableStream.from({ [Symbol.asyncIterator]: null, [Symbol.iterator]: () => ({ next: () => ({ done: true }) }) }).pipeTo(new WritableStream()) ^ at getIterator (ext:deno_web/06_streams.js:5105:38) at Function.from (ext:deno_web/06_streams.js:5207:22) at file:///D:/work/js/deno/tests/wpt/suite/$deno$eval:1:16 ``` --------- Co-authored-by: Asher Gomez <ashersaupingomez@gmail.com>
This commit is contained in:
parent
de5b47b13c
commit
fa27350977
3 changed files with 18 additions and 7 deletions
|
@ -5096,8 +5096,8 @@ async function* createAsyncFromSyncIterator(syncIterator) {
|
|||
// Ref: https://tc39.es/ecma262/#sec-getiterator
|
||||
function getIterator(obj, async = false) {
|
||||
if (async) {
|
||||
if (obj[SymbolAsyncIterator] === undefined) {
|
||||
if (obj[SymbolIterator] === undefined) {
|
||||
if (obj[SymbolAsyncIterator] == null) {
|
||||
if (obj[SymbolIterator] == null) {
|
||||
throw new TypeError("No iterator found");
|
||||
}
|
||||
return createAsyncFromSyncIterator(obj[SymbolIterator]());
|
||||
|
@ -5105,7 +5105,7 @@ function getIterator(obj, async = false) {
|
|||
return obj[SymbolAsyncIterator]();
|
||||
}
|
||||
} else {
|
||||
if (obj[SymbolIterator] === undefined) {
|
||||
if (obj[SymbolIterator] == null) {
|
||||
throw new TypeError("No iterator found");
|
||||
}
|
||||
return obj[SymbolIterator]();
|
||||
|
|
|
@ -3170,8 +3170,14 @@
|
|||
"owning-type-message-port.any.worker.html": false,
|
||||
"owning-type.any.html": false,
|
||||
"owning-type.any.worker.html": false,
|
||||
"from.any.html": true,
|
||||
"from.any.worker.html": true
|
||||
"from.any.html": [
|
||||
"ReadableStream.from accepts a sync iterable of values",
|
||||
"ReadableStream.from accepts a sync iterable of promises"
|
||||
],
|
||||
"from.any.worker.html": [
|
||||
"ReadableStream.from accepts a sync iterable of values",
|
||||
"ReadableStream.from accepts a sync iterable of promises"
|
||||
]
|
||||
},
|
||||
"transform-streams": {
|
||||
"backpressure.any.html": true,
|
||||
|
@ -10072,7 +10078,6 @@
|
|||
"Worker-replace-event-handler.any.worker.html": true,
|
||||
"Worker-replace-global-constructor.any.worker.html": true,
|
||||
"Worker-replace-self.any.worker.html": true,
|
||||
"WorkerGlobalScope_requestAnimationFrame.tentative.worker.html": false,
|
||||
"WorkerLocation-origin.sub.window.html": false,
|
||||
"WorkerNavigator-hardware-concurrency.any.worker.html": true,
|
||||
"WorkerNavigator.any.worker.html": false,
|
||||
|
@ -10753,6 +10758,9 @@
|
|||
},
|
||||
"service-workers": {
|
||||
"idlharness.https.any.html": [
|
||||
"ServiceWorkerContainer interface: operation register((TrustedScriptURL or USVString), optional RegistrationOptions)",
|
||||
"ServiceWorkerContainer interface: navigator.serviceWorker must inherit property \"register((TrustedScriptURL or USVString), optional RegistrationOptions)\" with the proper type",
|
||||
"ServiceWorkerContainer interface: calling register((TrustedScriptURL or USVString), optional RegistrationOptions) on navigator.serviceWorker with too few arguments must throw TypeError",
|
||||
"ServiceWorker interface: existence and properties of interface object",
|
||||
"ServiceWorker interface object length",
|
||||
"ServiceWorker interface object name",
|
||||
|
@ -10861,6 +10869,9 @@
|
|||
"idl_test setup"
|
||||
],
|
||||
"idlharness.https.any.worker.html": [
|
||||
"ServiceWorkerContainer interface: operation register((TrustedScriptURL or USVString), optional RegistrationOptions)",
|
||||
"ServiceWorkerContainer interface: navigator.serviceWorker must inherit property \"register((TrustedScriptURL or USVString), optional RegistrationOptions)\" with the proper type",
|
||||
"ServiceWorkerContainer interface: calling register((TrustedScriptURL or USVString), optional RegistrationOptions) on navigator.serviceWorker with too few arguments must throw TypeError",
|
||||
"ServiceWorker interface: existence and properties of interface object",
|
||||
"ServiceWorker interface object length",
|
||||
"ServiceWorker interface object name",
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 915d40b37fbd3554548d5cbec9f335f329ccc944
|
||||
Subproject commit 5b7a1a44887d1c68ad67a4df894febd45f520c2a
|
Loading…
Reference in a new issue