Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 0b17d8dd4d48bdd4e5963182b98acbe409a848a4
https://github.com/WebKit/WebKit/commit/0b17d8dd4d48bdd4e5963182b98acbe409a848a4
Author: Basuke Suzuki <[email protected]>
Date: 2026-09-30 (Wed, 30 Sep 2026)
Changed paths:
A
LayoutTests/http/wpt/css/css-view-transitions/update-callback-return-value-conversion-throws-expected.txt
A
LayoutTests/http/wpt/css/css-view-transitions/update-callback-return-value-conversion-throws.html
A
LayoutTests/http/wpt/streams/readable-byte-stream-callback-return-value-conversion-throws-expected.txt
A
LayoutTests/http/wpt/streams/readable-byte-stream-callback-return-value-conversion-throws.html
A
LayoutTests/http/wpt/web-locks/granted-callback-return-value-conversion-throws.https-expected.txt
A
LayoutTests/http/wpt/web-locks/granted-callback-return-value-conversion-throws.https.html
M Source/WebCore/bindings/js/JSDOMConvertPromise.h
M Source/WebCore/bindings/scripts/CodeGeneratorJS.pm
M Source/WebCore/bindings/scripts/test/JS/JSTestCallbackInterface.cpp
Log Message:
-----------
[Bindings] An exception raised while converting a promise-returning
callback's return value should reject the promise
https://bugs.webkit.org/show_bug.cgi?id=321697
rdar://184739141
Reviewed by Yusuke Suzuki.
For a callback whose IDL return type is a promise, the generated code already
turns an
exception thrown by invoking the callback into a rejected promise. An exception
thrown while
converting the callback's return value to a promise, however, came back as
CallbackResultType::ExceptionThrown, and each consumer handled that
differently, if at all.
Such an exception happens, for example, when the callback returns a promise
with an own
"constructor" getter that throws: %Promise%.resolve() then takes the slow path
and runs the
getter.
The generator now turns that exception into a rejected promise too, mirroring
the invocation
case. This is what WebIDL's "invoke a callback function" algorithm requires: an
exception
thrown while converting the return value becomes the completion, and for a
promise return type
that completion is returned as a promise rejected with it
(https://webidl.spec.whatwg.org/#invoke-a-callback-function). A termination
exception raised
during the conversion is still reported as ExceptionThrown.
Converter<IDLPromise<T>>::convert() also no longer takes an exception thrower.
It called one when
%Promise%.resolve() threw, but that path is only taken when an exception is
already pending, so
the call replaced the real exception with a generic TypeError. No caller passes
a thrower of its
own for a promise type. The branch that forbids further execution in a
terminating worker now
falls through to the same return.
Observable changes for the current promise-returning callbacks, which now all
see the
original exception:
- navigator.locks.request(): rejected with a generic TypeError before.
- ReadableStream with type "bytes": read() never settled when pull() returned
such a value,
and cancel() threw a TypeError synchronously.
- document.startViewTransition(): updateCallbackDone never settled, and the
TypeError was
reported as an uncaught exception.
- Navigation API intercept() handler and precommitHandler: the navigation now
fails with
navigateerror carrying the exception.
Promise<T> operation arguments, dictionary members and record values (for
example
ExtendableEvent.waitUntil(), FetchEvent.respondWith(), PaymentRequest.show(),
new PromiseRejectionEvent() and new ClipboardItem()) likewise throw the
original exception
instead of a TypeError.
Tests:
http/wpt/css/css-view-transitions/update-callback-return-value-conversion-throws.html
http/wpt/streams/readable-byte-stream-callback-return-value-conversion-throws.html
http/wpt/web-locks/granted-callback-return-value-conversion-throws.https.html
*
LayoutTests/http/wpt/css/css-view-transitions/update-callback-return-value-conversion-throws-expected.txt:
Added.
*
LayoutTests/http/wpt/css/css-view-transitions/update-callback-return-value-conversion-throws.html:
Added.
*
LayoutTests/http/wpt/streams/readable-byte-stream-callback-return-value-conversion-throws-expected.txt:
Added.
*
LayoutTests/http/wpt/streams/readable-byte-stream-callback-return-value-conversion-throws.html:
Added.
*
LayoutTests/http/wpt/web-locks/granted-callback-return-value-conversion-throws.https-expected.txt:
Added.
*
LayoutTests/http/wpt/web-locks/granted-callback-return-value-conversion-throws.https.html:
Added.
* Source/WebCore/bindings/js/JSDOMConvertPromise.h:
(WebCore::Converter<IDLPromise<T>>::convert):
* Source/WebCore/bindings/scripts/CodeGeneratorJS.pm:
(GenerateCallbackImplementationOperationBody):
* Source/WebCore/bindings/scripts/test/JS/JSTestCallbackInterface.cpp:
(WebCore::JSTestCallbackInterface::callbackThatTreatsExceptionAsRejectedPromise):
Canonical link: https://commits.webkit.org/322331@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications