Skip to content

Commit

Permalink
fix(ext/webidl): change createPromiseConverter (denoland#16367)
Browse files Browse the repository at this point in the history
  • Loading branch information
marcosc90 authored May 18, 2023
1 parent c3f7e6e commit b0f1356
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 27 deletions.
10 changes: 6 additions & 4 deletions ext/webidl/00_webidl.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
30 changes: 7 additions & 23 deletions tools/wpt/expectation.json
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -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": {
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -9087,4 +9071,4 @@
"media-sniff.window.html": false
}
}
}
}

0 comments on commit b0f1356

Please sign in to comment.