From b0f13560cb5a860df042649fbceb8cd728011b8b Mon Sep 17 00:00:00 2001 From: Marcos Casagrande Date: Thu, 18 May 2023 16:05:11 +0200 Subject: [PATCH] fix(ext/webidl): change createPromiseConverter (#16367) --- ext/webidl/00_webidl.js | 10 ++++++---- tools/wpt/expectation.json | 30 +++++++----------------------- 2 files changed, 13 insertions(+), 27 deletions(-) diff --git a/ext/webidl/00_webidl.js b/ext/webidl/00_webidl.js index 247ebfe0d2..dfaa774e29 100644 --- a/ext/webidl/00_webidl.js +++ b/ext/webidl/00_webidl.js @@ -948,10 +948,12 @@ function createRecordConverter(keyConverter, valueConverter) { function createPromiseConverter(converter) { return (V, prefix, context, opts) => - PromisePrototypeThen( - PromiseResolve(V), - (V) => converter(V, prefix, context, opts), - ); + // should be able to handle thenables + // see: https://github.com/web-platform-tests/wpt/blob/a31d3ba53a79412793642366f3816c9a63f0cf57/streams/writable-streams/close.any.js#L207 + typeof V?.then === "function" + ? PromisePrototypeThen(PromiseResolve(V), (V) => + converter(V, prefix, context, opts)) + : PromiseResolve(converter(V, prefix, context, opts)); } function invokeCallbackFunction( diff --git a/tools/wpt/expectation.json b/tools/wpt/expectation.json index 4fc0067e70..57b8ba75ab 100644 --- a/tools/wpt/expectation.json +++ b/tools/wpt/expectation.json @@ -1843,14 +1843,8 @@ "bad-buffers-and-views.any.worker.html": true, "construct-byob-request.any.html": true, "construct-byob-request.any.worker.html": true, - "general.any.html": [ - "ReadableStream with byte source: Respond to multiple pull() by separate enqueue()", - "ReadableStream with byte source: enqueue() discards auto-allocated BYOB request" - ], - "general.any.worker.html": [ - "ReadableStream with byte source: Respond to multiple pull() by separate enqueue()", - "ReadableStream with byte source: enqueue() discards auto-allocated BYOB request" - ], + "general.any.html": true, + "general.any.worker.html": true, "non-transferable-buffers.any.html": true, "non-transferable-buffers.any.worker.html": true, "enqueue-with-detached-buffer.window.html": false, @@ -1862,10 +1856,7 @@ "enqueue-with-detached-buffer.any.worker.html": true }, "readable-streams": { - "async-iterator.any.html": [ - "next() that succeeds; return()", - "next() that succeeds; return() [no awaiting]" - ], + "async-iterator.any.html": true, "bad-strategies.any.html": true, "bad-strategies.any.worker.html": true, "bad-underlying-sources.any.html": true, @@ -1892,10 +1883,7 @@ "tee.any.worker.html": true, "templated.any.html": true, "templated.any.worker.html": true, - "async-iterator.any.worker.html": [ - "next() that succeeds; return()", - "next() that succeeds; return() [no awaiting]" - ], + "async-iterator.any.worker.html": true, "cross-realm-crash.window.html": false }, "transform-streams": { @@ -1929,12 +1917,8 @@ "bad-underlying-sinks.any.worker.html": true, "byte-length-queuing-strategy.any.html": true, "byte-length-queuing-strategy.any.worker.html": true, - "close.any.html": [ - "when close is called on a WritableStream in waiting state, ready should be fulfilled immediately even if close takes a long time" - ], - "close.any.worker.html": [ - "when close is called on a WritableStream in waiting state, ready should be fulfilled immediately even if close takes a long time" - ], + "close.any.html": true, + "close.any.worker.html": true, "constructor.any.html": true, "constructor.any.worker.html": true, "count-queuing-strategy.any.html": true, @@ -9087,4 +9071,4 @@ "media-sniff.window.html": false } } -} \ No newline at end of file +}