Skip to content

Commit af15f32

Browse files
committed
Add GetPromiseIsHandled to JSAPI via patch
Ref: #150 (comment)
1 parent 5ad6180 commit af15f32

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

etc/patches/is_handled.patch

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
diff --git a/mozjs/js/src/jsapi.cpp b/mozjs/js/src/jsapi.cpp
2+
index 94ef1b3ed..06be95062 100644
3+
--- a/mozjs/js/src/jsapi.cpp
4+
+++ b/mozjs/js/src/jsapi.cpp
5+
@@ -5162,6 +5162,14 @@ JS::GetPromiseResult(JS::HandleObject promiseObj)
6+
return promise->state() == JS::PromiseState::Fulfilled ? promise->value() : promise->reason();
7+
}
8+
9+
+JS_PUBLIC_API(bool)
10+
+JS::GetPromiseIsHandled(JS::HandleObject promiseObj)
11+
+{
12+
+ PromiseObject* promise = &promiseObj->as<PromiseObject>();
13+
+ MOZ_ASSERT(promise->state() == JS::PromiseState::Rejected);
14+
+ return !promise->isUnhandled();
15+
+}
16+
+
17+
JS_PUBLIC_API(JSObject*)
18+
JS::GetPromiseAllocationSite(JS::HandleObject promise)
19+
{
20+
diff --git a/mozjs/js/src/jsapi.h b/mozjs/js/src/jsapi.h
21+
index c7f92e273..5c5e9abc5 100644
22+
--- a/mozjs/js/src/jsapi.h
23+
+++ b/mozjs/js/src/jsapi.h
24+
@@ -4390,6 +4390,12 @@ GetPromiseID(JS::HandleObject promise);
25+
extern JS_PUBLIC_API(JS::Value)
26+
GetPromiseResult(JS::HandleObject promise);
27+
28+
+/**
29+
+ * Returns thhe given Promise's internal slot of `isHandled`.
30+
+ */
31+
+extern JS_PUBLIC_API(bool)
32+
+GetPromiseIsHandled(JS::HandleObject promise);
33+
+
34+
/**
35+
* Returns a js::SavedFrame linked list of the stack that lead to the given
36+
* Promise's allocation.

0 commit comments

Comments
 (0)