@@ -129,6 +129,27 @@ typedef struct JsNativeFunctionInfo
129129/// <returns>The result of the call, if any.</returns>
130130typedef _Ret_maybenull_ JsValueRef (CHAKRA_CALLBACK * JsEnhancedNativeFunction )(_In_ JsValueRef callee , _In_ JsValueRef * arguments , _In_ unsigned short argumentCount , _In_ JsNativeFunctionInfo * info , _In_opt_ void * callbackState );
131131
132+ /// <summary>
133+ /// A Promise Rejection Tracker callback.
134+ /// </summary>
135+ /// <remarks>
136+ /// The host can specify a promise rejection tracker callback in <c>JsSetHostPromiseRejectionTracker</c>.
137+ /// If a promise is rejected with no reactions or a reaction is added to a promise that was rejected
138+ /// before it had reactions by default nothing is done.
139+ /// A Promise Rejection Tracker callback may be set - which will then be called when this occurs.
140+ /// Note - per draft ECMASpec 2018 25.4.1.9 this function should not set or return an exception
141+ /// Note also the promise and reason parameters may be garbage collected after this function is called
142+ /// if you wish to make further use of them you will need to use JsAddRef to preserve them
143+ /// However if you use JsAddRef you must also call JsRelease and not hold unto them after
144+ /// a handled notification (both per spec and to avoid memory leaks)
145+ /// </remarks>
146+ /// <param name="promise">The promise object, represented as a JsValueRef.</param>
147+ /// <param name="reason">The value/cause of the rejection, represented as a JsValueRef.</param>
148+ /// <param name="handled">Boolean - false for promiseRejected: i.e. if the promise has just been rejected with no handler,
149+ /// true for promiseHandled: i.e. if it was rejected before without a handler and is now being handled.</param>
150+ /// <param name="callbackState">The state passed to <c>JsSetHostPromiseRejectionTracker</c>.</param>
151+ typedef void (CHAKRA_CALLBACK * JsHostPromiseRejectionTrackerCallback )(_In_ JsValueRef promise , _In_ JsValueRef reason , _In_ bool handled , _In_opt_ void * callbackState );
152+
132153/// <summary>
133154/// Creates a new enhanced JavaScript function.
134155/// </summary>
@@ -992,5 +1013,27 @@ CHAKRA_API
9921013 _In_ JsValueRef object ,
9931014 _In_ JsValueRef key ,
9941015 _Out_ bool * hasOwnProperty );
1016+
1017+ /// <summary>
1018+ /// Sets whether any action should be taken when a promise is rejected with no reactions
1019+ /// or a reaction is added to a promise that was rejected before it had reactions.
1020+ /// By default in either of these cases nothing occurs.
1021+ /// This function allows you to specify if something should occur and provide a callback
1022+ /// to implement whatever should occur.
1023+ /// </summary>
1024+ /// <remarks>
1025+ /// Requires an active script context.
1026+ /// </remarks>
1027+ /// <param name="promiseRejectionTrackerCallback">The callback function being set.</param>
1028+ /// <param name="callbackState">
1029+ /// User provided state that will be passed back to the callback.
1030+ /// </param>
1031+ /// <returns>
1032+ /// The code <c>JsNoError</c> if the operation succeeded, a failure code otherwise.
1033+ /// </returns>
1034+ CHAKRA_API
1035+ JsSetHostPromiseRejectionTracker (
1036+ _In_ JsHostPromiseRejectionTrackerCallback promiseRejectionTrackerCallback ,
1037+ _In_opt_ void * callbackState );
9951038#endif // _CHAKRACOREBUILD
9961039#endif // _CHAKRACORE_H_
0 commit comments