Skip to content
Browse files
[JSC] TestAPI::promiseUnhandledRejection() predominantly fails on Mac…
…OS 12.3 in --debug

Reviewed by Mark Lam.

The failures are caused by an unhandled rejection, that was originated in
TestAPI::promiseDrainDoesNotEatExceptions() and ended up in the callback of
TestAPI::promiseUnhandledRejection(), with an unexpected promise and reason.

That is, the callback of TestAPI::promiseUnhandledRejection() is called twice,
with only the first invocation being successful.

The failures weren't observed before MacOS 12.3 because TestAPI::promiseDrainDoesNotEatExceptions()
is a DYLD_MACOSX_VERSION-conditional test.

To fix the tests, this change ensures that TestAPI::promiseUnhandledRejection() performs assertions
only on the first run, aligning it with TestAPI::promiseUnhandledRejectionFromUnhandledRejectionCallback().

* Source/JavaScriptCore/API/tests/testapi.cpp:

Canonical link:
git-svn-id: 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
shvaikalesh committed May 25, 2022
1 parent e16c91f commit d795d91cb66c5b4af2f55019f86fa5b6721a6e35
Showing 1 changed file with 2 additions and 0 deletions.
@@ -555,6 +555,8 @@ void TestAPI::promiseUnhandledRejection()
static TestAPI* tester = this;
static bool callbackCalled = false;
auto callback = [](JSContextRef ctx, JSObjectRef, JSObjectRef, size_t argumentCount, const JSValueRef arguments[], JSValueRef*) -> JSValueRef {
if (callbackCalled)
return JSValueMakeUndefined(ctx);
tester->check(argumentCount && JSValueIsStrictEqual(ctx, arguments[0], promise), "callback should receive rejected promise as first argument");
tester->check(argumentCount > 1 && JSValueIsStrictEqual(ctx, arguments[1], reason), "callback should receive rejection reason as second argument");
tester->check(argumentCount == 2, "callback should not receive a third argument");

0 comments on commit d795d91

Please sign in to comment.