@@ -1716,7 +1716,8 @@ JSContext *JS_NewCustomContext(JSRuntime *rt)
17161716int run_test_buf (ThreadLocalStorage * tls , const char * filename , char * harness ,
17171717 namelist_t * ip , char * buf , size_t buf_len ,
17181718 const char * error_type , int eval_flags , bool is_negative ,
1719- bool is_async , bool can_block , int * msec )
1719+ bool is_async , bool can_block , bool track_promise_rejections ,
1720+ int * msec )
17201721{
17211722 JSRuntime * rt ;
17221723 JSContext * ctx ;
@@ -1741,6 +1742,9 @@ int run_test_buf(ThreadLocalStorage *tls, const char *filename, char *harness,
17411742 /* loader for ES6 modules */
17421743 JS_SetModuleLoaderFunc (rt , NULL , js_module_loader_test , (void * ) filename );
17431744
1745+ if (track_promise_rejections )
1746+ JS_SetHostPromiseRejectionTracker (rt , js_std_promise_rejection_tracker , NULL );
1747+
17441748 add_helpers (ctx );
17451749
17461750 for (i = 0 ; i < ip -> count ; i ++ ) {
@@ -1787,6 +1791,7 @@ int run_test(ThreadLocalStorage *tls, const char *filename, int *msec)
17871791 int ret , eval_flags , use_strict , use_nostrict ;
17881792 bool is_negative , is_nostrict , is_onlystrict , is_async , is_module , skip ;
17891793 bool detect_module = true;
1794+ bool track_promise_rejections = false;
17901795 bool can_block ;
17911796 namelist_t include_list = { 0 }, * ip = & include_list ;
17921797
@@ -1845,6 +1850,9 @@ int run_test(ThreadLocalStorage *tls, const char *filename, int *msec)
18451850 else if (str_equal (option , "qjs:no-detect-module" )) {
18461851 detect_module = false;
18471852 }
1853+ else if (str_equal (option , "qjs:track-promise-rejections" )) {
1854+ track_promise_rejections = true;
1855+ }
18481856 else if (str_equal (option , "module" )) {
18491857 is_module = true;
18501858 skip |= skip_module ;
@@ -1939,12 +1947,13 @@ int run_test(ThreadLocalStorage *tls, const char *filename, int *msec)
19391947 if (use_nostrict ) {
19401948 ret = run_test_buf (tls , filename , harness , ip , buf , buf_len ,
19411949 error_type , eval_flags , is_negative , is_async ,
1942- can_block , msec );
1950+ can_block , track_promise_rejections , msec );
19431951 }
19441952 if (use_strict ) {
19451953 ret |= run_test_buf (tls , filename , harness , ip , buf , buf_len ,
19461954 error_type , eval_flags | JS_EVAL_FLAG_STRICT ,
1947- is_negative , is_async , can_block , msec );
1955+ is_negative , is_async , can_block ,
1956+ track_promise_rejections , msec );
19481957 }
19491958 }
19501959 namelist_free (& include_list );
0 commit comments