Skip to content

Commit 5ad6180

Browse files
committed
Introduce internal slot of Promise - GetPromiseIsHandled
1 parent 4a31b2e commit 5ad6180

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

mozjs/js/src/jsapi.cpp

+8
Original file line numberDiff line numberDiff line change
@@ -5162,6 +5162,14 @@ JS::GetPromiseResult(JS::HandleObject promiseObj)
51625162
return promise->state() == JS::PromiseState::Fulfilled ? promise->value() : promise->reason();
51635163
}
51645164

5165+
JS_PUBLIC_API(bool)
5166+
JS::GetPromiseIsHandled(JS::HandleObject promiseObj)
5167+
{
5168+
PromiseObject* promise = &promiseObj->as<PromiseObject>();
5169+
MOZ_ASSERT(promise->state() == JS::PromiseState::Rejected);
5170+
return !promise->isUnhandled();
5171+
}
5172+
51655173
JS_PUBLIC_API(JSObject*)
51665174
JS::GetPromiseAllocationSite(JS::HandleObject promise)
51675175
{

mozjs/js/src/jsapi.h

+6
Original file line numberDiff line numberDiff line change
@@ -4390,6 +4390,12 @@ GetPromiseID(JS::HandleObject promise);
43904390
extern JS_PUBLIC_API(JS::Value)
43914391
GetPromiseResult(JS::HandleObject promise);
43924392

4393+
/**
4394+
* Returns thhe given Promise's internal slot of `isHandled`.
4395+
*/
4396+
extern JS_PUBLIC_API(bool)
4397+
GetPromiseIsHandled(JS::HandleObject promise);
4398+
43934399
/**
43944400
* Returns a js::SavedFrame linked list of the stack that lead to the given
43954401
* Promise's allocation.

0 commit comments

Comments
 (0)