From b0f13560cb5a860df042649fbceb8cd728011b8b Mon Sep 17 00:00:00 2001 From: Marcos Casagrande Date: Thu, 18 May 2023 16:05:11 +0200 Subject: fix(ext/webidl): change createPromiseConverter (#16367) --- ext/webidl/00_webidl.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'ext') diff --git a/ext/webidl/00_webidl.js b/ext/webidl/00_webidl.js index 247ebfe0d..dfaa774e2 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( -- cgit v1.2.3