]> git.kaiwu.me - njs.git/commitdiff
Tests: update Test262 and allow unhandled rejections
authorDmitry Volyntsev <xeioex@nginx.com>
Tue, 22 Sep 2026 04:55:31 +0000 (21:55 -0700)
committerDmitry Volyntsev <xeioexception@gmail.com>
Fri, 25 Sep 2026 23:00:29 +0000 (16:00 -0700)
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
test/njs_test262.failures
test/njs_test262.version

index 3ed7fc3a533379c2c72289e5cfad83dcdf19d349..39a47db33323a7007f0a7db57f285d33696cdb1c 100644 (file)
@@ -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) {
index f57db9198c5db7c30a181d22d75e48adc3916783..2e3086630d7687d161c86d7608e5c9d58ac0b90c 100644 (file)
@@ -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
index 69813890c0f0181c2707178acedddea90d54f7f8..73356f440bdaf14fc7f69c7944532b031593a6f1 100644 (file)
@@ -1 +1 @@
-419d3e0a2273ba01a3bfcbec423f2801425b8e93
+045bf6f9966ce3291b8fbc1e0403cd97b9201b00