Skip to content

Commit d795d91

Browse files
committed
[JSC] TestAPI::promiseUnhandledRejection() predominantly fails on MacOS 12.3 in --debug
https://bugs.webkit.org/show_bug.cgi?id=240243 <rdar://92975620> 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: (TestAPI::promiseUnhandledRejection): Canonical link: https://commits.webkit.org/250965@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@294811 268f45cc-cd09-0410-ab3c-d52691b4dbfc
1 parent e16c91f commit d795d91

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

‎Source/JavaScriptCore/API/tests/testapi.cpp‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -555,6 +555,8 @@ void TestAPI::promiseUnhandledRejection()
555555
static TestAPI* tester = this;
556556
static bool callbackCalled = false;
557557
auto callback = [](JSContextRef ctx, JSObjectRef, JSObjectRef, size_t argumentCount, const JSValueRef arguments[], JSValueRef*) -> JSValueRef {
558+
if (callbackCalled)
559+
return JSValueMakeUndefined(ctx);
558560
tester->check(argumentCount && JSValueIsStrictEqual(ctx, arguments[0], promise), "callback should receive rejected promise as first argument");
559561
tester->check(argumentCount > 1 && JSValueIsStrictEqual(ctx, arguments[1], reason), "callback should receive rejection reason as second argument");
560562
tester->check(argumentCount == 2, "callback should not receive a third argument");

0 commit comments

Comments
 (0)