From 777e8f8ac0ccee6238083b38dba1916797c741cb Mon Sep 17 00:00:00 2001 From: Dmitry Volyntsev Date: Mon, 21 Sep 2026 21:55:31 -0700 Subject: [PATCH] Tests: update Test262 and allow unhandled rejections Track the current Test262 revision and let the Test262 runner follow the suite's handling of rejected promises instead of imposing a separate policy. --- src/test/njs_test262.c | 90 --------------------------------------- test/njs_test262.failures | 6 --- test/njs_test262.version | 2 +- 3 files changed, 1 insertion(+), 97 deletions(-) diff --git a/src/test/njs_test262.c b/src/test/njs_test262.c index 3ed7fc3a..39a47db3 100644 --- a/src/test/njs_test262.c +++ b/src/test/njs_test262.c @@ -187,12 +187,6 @@ typedef struct { } njs_test262_wire_t; -typedef struct { - njs_opaque_value_t promise; - njs_opaque_value_t reason; -} njs_test262_rejected_t; - - typedef enum { NJS_TEST262_ASYNC_PENDING = 0, NJS_TEST262_ASYNC_COMPLETE, @@ -203,8 +197,6 @@ typedef enum { typedef struct { njs_test262_t *ctx; njs_mp_t *pool; - njs_arr_t *rejected; - /* * Asynchronous completion is signalled through print(), which is the * interface INTERPRETING.md defines. A second completion is recorded @@ -2425,51 +2417,6 @@ njs_test262_ext_print(njs_vm_t *vm, njs_value_t *args, njs_uint_t nargs, } -/* - * A promise rejected without a handler is a failure: the assertions of a test - * can all pass while its asynchronous part throws. - */ - -static void -njs_test262_rejection(njs_vm_t *vm, njs_external_ptr_t external, - njs_bool_t is_handled, njs_value_t *promise, njs_value_t *reason) -{ - void *ptr; - njs_uint_t i; - njs_test262_run_t *run; - njs_test262_rejected_t *rejected; - - run = external; - - if (run->rejected == NULL) { - return; - } - - rejected = run->rejected->start; - - if (is_handled) { - ptr = njs_value_ptr(promise); - - for (i = 0; i < run->rejected->items; i++) { - if (njs_value_ptr(njs_value_arg(&rejected[i].promise)) == ptr) { - njs_arr_remove(run->rejected, &rejected[i]); - break; - } - } - - return; - } - - rejected = njs_arr_add(run->rejected); - if (rejected == NULL) { - return; - } - - njs_value_assign(&rejected->promise, promise); - njs_value_assign(&rejected->reason, reason); -} - - /* * Resolves an import relative to the importing module and keeps the result * inside the suite tree. A _FIXTURE.js file is not enumerated as a test but @@ -2898,7 +2845,6 @@ njs_test262_run_variant(njs_test262_t *ctx, njs_test262_variant_t *variant, njs_test262_stage_t stage; njs_test262_source_t *source; njs_test262_metadata_t meta; - njs_test262_rejected_t *rejected; njs_memzero(result, sizeof(njs_test262_result_t)); @@ -2934,12 +2880,6 @@ njs_test262_run_variant(njs_test262_t *ctx, njs_test262_variant_t *variant, run->dir.length--; } - run->rejected = njs_arr_create(pool, 4, sizeof(njs_test262_rejected_t)); - if (run->rejected == NULL) { - ret = njs_test262_error(ctx, "memory allocation failed"); - goto done; - } - sources = njs_arr_create(pool, 8, sizeof(njs_test262_source_t)); if (sources == NULL) { ret = njs_test262_error(ctx, "memory allocation failed"); @@ -2980,7 +2920,6 @@ njs_test262_run_variant(njs_test262_t *ctx, njs_test262_variant_t *variant, goto done; } - njs_vm_set_rejection_tracker(vm, njs_test262_rejection, run); njs_vm_set_module_loader(vm, njs_test262_module_loader, run); ret = njs_test262_bindings(ctx, vm); @@ -3049,11 +2988,6 @@ njs_test262_run_variant(njs_test262_t *ctx, njs_test262_variant_t *variant, } } - /* - * A synchronous test may still have enqueued promise jobs. Draining them - * keeps a rejected promise from being reported as a pass. - */ - for (jobs = 0; jobs < NJS_TEST262_MAX_JOBS; jobs++) { ret = njs_vm_execute_pending_job(vm); @@ -3088,30 +3022,6 @@ njs_test262_run_variant(njs_test262_t *ctx, njs_test262_variant_t *variant, goto done; } - if (run->rejected->items != 0) { - rejected = run->rejected->start; - - result->status = NJS_TEST262_FAIL; - result->stage = NJS_TEST262_STAGE_JOBS; - - if (njs_vm_value_to_string(vm, &test, - njs_value_arg(&rejected->reason)) == NJS_OK) - { - if (test.length > NJS_TEST262_MAX_MESSAGE) { - test.length = NJS_TEST262_MAX_MESSAGE; - } - - (void) njs_test262_str_printf(ctx, &result->message, "unhandled " - "promise rejection: %V", &test); - - } else { - result->message = njs_str_value("unhandled promise rejection"); - } - - ret = NJS_OK; - goto done; - } - result->stage = NJS_TEST262_STAGE_NONE; if (meta.phase != NJS_TEST262_PHASE_NONE) { diff --git a/test/njs_test262.failures b/test/njs_test262.failures index f57db919..2e308663 100644 --- a/test/njs_test262.failures +++ b/test/njs_test262.failures @@ -381,7 +381,6 @@ built-ins/Promise/all/invoke-resolve-error-close.js strict built-ins/Promise/all/invoke-resolve-error-reject.js strict built-ins/Promise/all/invoke-resolve-get-error-reject.js strict built-ins/Promise/all/invoke-resolve-get-error.js strict -built-ins/Promise/all/invoke-resolve-get-once-multiple-calls.js strict built-ins/Promise/all/invoke-resolve-on-promises-every-iteration-of-promise.js strict built-ins/Promise/all/invoke-resolve-on-values-every-iteration-of-promise.js strict built-ins/Promise/all/invoke-then-error-close.js strict @@ -505,8 +504,6 @@ built-ins/Promise/prototype/finally/subclass-resolve-count.js strict built-ins/Promise/prototype/finally/subclass-species-constructor-reject-count.js strict built-ins/Promise/prototype/finally/subclass-species-constructor-resolve-count.js strict built-ins/Promise/prototype/finally/this-value-proxy.js strict -built-ins/Promise/prototype/then/rxn-handler-fulfilled-next-abrupt.js strict -built-ins/Promise/prototype/then/rxn-handler-rejected-next-abrupt.js strict built-ins/Promise/race/S25.4.4.3_A2.2_T1.js strict built-ins/Promise/race/S25.4.4.3_A2.2_T2.js strict built-ins/Promise/race/S25.4.4.3_A2.2_T3.js strict @@ -549,7 +546,6 @@ built-ins/Promise/race/resolve-non-callable.js strict built-ins/Promise/race/resolve-throws-iterator-return-is-not-callable.js strict built-ins/Promise/race/resolve-throws-iterator-return-null-or-undefined.js strict built-ins/Promise/reject/ctx-non-ctor.js strict -built-ins/Promise/resolve/arg-uniq-ctor.js strict built-ins/Promise/resolve/ctx-non-ctor.js strict built-ins/Promise/withResolvers/promise.js strict built-ins/Promise/withResolvers/resolvers.js strict @@ -1433,7 +1429,6 @@ language/expressions/optional-chaining/early-errors-tail-position-optchain-templ language/expressions/optional-chaining/eval-optional-call.js strict language/expressions/optional-chaining/iteration-statement-for-await-of.js strict language/expressions/optional-chaining/iteration-statement-for-of-type-error.js strict -language/expressions/optional-chaining/member-expression-async-identifier.js strict language/expressions/optional-chaining/member-expression.js strict language/expressions/optional-chaining/new-target-optional-call.js strict language/expressions/optional-chaining/optional-chain-prod-arguments.js strict @@ -1683,7 +1678,6 @@ language/statements/async-function/dflt-params-trailing-comma.js strict language/statements/async-function/early-errors-declaration-arguments-in-formal-parameters.js strict language/statements/async-function/early-errors-declaration-await-in-formals.js strict language/statements/async-function/early-errors-declaration-eval-in-formal-parameters.js strict -language/statements/async-function/evaluation-body.js strict language/statements/async-function/evaluation-default-that-throws.js strict language/statements/async-function/evaluation-unmapped-arguments.js strict language/statements/async-function/rest-param-strict-body.js strict diff --git a/test/njs_test262.version b/test/njs_test262.version index 69813890..73356f44 100644 --- a/test/njs_test262.version +++ b/test/njs_test262.version @@ -1 +1 @@ -419d3e0a2273ba01a3bfcbec423f2801425b8e93 +045bf6f9966ce3291b8fbc1e0403cd97b9201b00 -- 2.47.3