From bd32672b67e973883bdd4a63e7e098aa633e4de4 Mon Sep 17 00:00:00 2001 From: Andreu Botella Date: Sun, 16 Feb 2025 03:49:35 +0100 Subject: [PATCH] Support realms in test262 If the `--expose-internals` flag is enabled, this patch adds a `__nova__.createRealm()` function that creates a new realm and returns its global. This is then used by the test262 runner to support testing cross-realm interactions for the first time. --- nova_cli/src/helper.rs | 42 +++++++++++ nova_vm/src/ecmascript/execution/realm.rs | 4 ++ tests/expectations.json | 85 ----------------------- tests/metrics.json | 6 +- tests/nova-harness.js | 24 +++++-- 5 files changed, 68 insertions(+), 93 deletions(-) diff --git a/nova_cli/src/helper.rs b/nova_cli/src/helper.rs index 7871a905e..b7d3260c5 100644 --- a/nova_cli/src/helper.rs +++ b/nova_cli/src/helper.rs @@ -112,6 +112,25 @@ pub fn initialize_global_object_with_internals(agent: &mut Agent, global: Object Ok(Value::Undefined) } + fn create_realm( + agent: &mut Agent, + _this: Value, + _args: ArgumentsList, + _gc: GcScope, + ) -> JsResult { + let create_global_object: Option fn(&mut Agent, GcScope<'a, '_>) -> Object<'a>> = + None; + let create_global_this_value: Option< + for<'a> fn(&mut Agent, GcScope<'a, '_>) -> Object<'a>, + > = None; + let realm = agent.create_realm( + create_global_object, + create_global_this_value, + Some(initialize_global_object_with_internals), + ); + Ok(realm.global_object(agent).into_value()) + } + initialize_global_object(agent, global, gc.reborrow()); let nova_obj = OrdinaryObject::create_empty_object(agent, gc.nogc()).scope(agent, gc.nogc()); @@ -153,6 +172,29 @@ pub fn initialize_global_object_with_internals(agent: &mut Agent, global: Object gc.reborrow(), ) .unwrap(); + + let function = create_builtin_function( + agent, + Behaviour::Regular(create_realm), + BuiltinFunctionArgs::new(1, "createRealm", agent.current_realm_id()), + gc.nogc(), + ); + let property_key = PropertyKey::from_static_str(agent, "createRealm", gc.nogc()).unbind(); + nova_obj + .get(agent) + .internal_define_own_property( + agent, + property_key, + PropertyDescriptor { + value: Some(function.into_value()), + writable: Some(true), + enumerable: Some(false), + configurable: Some(true), + ..Default::default() + }, + gc.reborrow(), + ) + .unwrap(); } /// Exit the program with parse errors. diff --git a/nova_vm/src/ecmascript/execution/realm.rs b/nova_vm/src/ecmascript/execution/realm.rs index 4918ac364..21c899ebb 100644 --- a/nova_vm/src/ecmascript/execution/realm.rs +++ b/nova_vm/src/ecmascript/execution/realm.rs @@ -62,6 +62,10 @@ impl RealmIdentifier { pub(crate) const fn into_u32_index(self) -> u32 { self.0.get() - 1 } + + pub fn global_object(self, agent: &mut Agent) -> Object { + agent[self].global_object + } } impl Index for Agent { diff --git a/tests/expectations.json b/tests/expectations.json index 2599b33de..ac69d0740 100644 --- a/tests/expectations.json +++ b/tests/expectations.json @@ -101,15 +101,12 @@ "built-ins/Array/isArray/15.4.3.2-1-10.js": "CRASH", "built-ins/Array/isArray/15.4.3.2-1-9.js": "CRASH", "built-ins/Array/isArray/proxy-revoked.js": "CRASH", - "built-ins/Array/length/define-own-prop-length-overflow-realm.js": "FAIL", "built-ins/Array/of/proto-from-ctor-realm.js": "FAIL", "built-ins/Array/proto-from-ctor-realm-one.js": "FAIL", "built-ins/Array/proto-from-ctor-realm-two.js": "FAIL", "built-ins/Array/proto-from-ctor-realm-zero.js": "FAIL", "built-ins/Array/prototype/Symbol.unscopables/prop-desc.js": "FAIL", "built-ins/Array/prototype/concat/Array.prototype.concat_spreadable-string-wrapper.js": "CRASH", - "built-ins/Array/prototype/concat/create-proto-from-ctor-realm-array.js": "FAIL", - "built-ins/Array/prototype/concat/create-proto-from-ctor-realm-non-array.js": "FAIL", "built-ins/Array/prototype/concat/create-revoked-proxy.js": "CRASH", "built-ins/Array/prototype/concat/is-concat-spreadable-is-array-proxy-revoked.js": "CRASH", "built-ins/Array/prototype/concat/is-concat-spreadable-proxy-revoked.js": "CRASH", @@ -159,8 +156,6 @@ "built-ins/Array/prototype/filter/15.4.4.20-9-c-i-20.js": "FAIL", "built-ins/Array/prototype/filter/15.4.4.20-9-c-iii-22.js": "CRASH", "built-ins/Array/prototype/filter/15.4.4.20-9-c-iii-23.js": "CRASH", - "built-ins/Array/prototype/filter/create-proto-from-ctor-realm-array.js": "FAIL", - "built-ins/Array/prototype/filter/create-proto-from-ctor-realm-non-array.js": "FAIL", "built-ins/Array/prototype/filter/create-revoked-proxy.js": "CRASH", "built-ins/Array/prototype/filter/resizable-buffer.js": "CRASH", "built-ins/Array/prototype/find/array-altered-during-loop.js": "CRASH", @@ -267,8 +262,6 @@ "built-ins/Array/prototype/map/15.4.4.19-5-16.js": "CRASH", "built-ins/Array/prototype/map/15.4.4.19-8-b-16.js": "FAIL", "built-ins/Array/prototype/map/15.4.4.19-8-c-i-19.js": "FAIL", - "built-ins/Array/prototype/map/create-proto-from-ctor-realm-array.js": "FAIL", - "built-ins/Array/prototype/map/create-proto-from-ctor-realm-non-array.js": "FAIL", "built-ins/Array/prototype/map/create-revoked-proxy.js": "CRASH", "built-ins/Array/prototype/map/resizable-buffer.js": "CRASH", "built-ins/Array/prototype/methods-called-as-functions.js": "CRASH", @@ -295,8 +288,6 @@ "built-ins/Array/prototype/reverse/get_if_present_with_delete.js": "CRASH", "built-ins/Array/prototype/reverse/length-exceeding-integer-limit-with-proxy.js": "CRASH", "built-ins/Array/prototype/reverse/resizable-buffer.js": "CRASH", - "built-ins/Array/prototype/slice/create-proto-from-ctor-realm-array.js": "FAIL", - "built-ins/Array/prototype/slice/create-proto-from-ctor-realm-non-array.js": "FAIL", "built-ins/Array/prototype/slice/create-revoked-proxy.js": "CRASH", "built-ins/Array/prototype/slice/resizable-buffer.js": "CRASH", "built-ins/Array/prototype/some/15.4.4.17-1-11.js": "CRASH", @@ -310,8 +301,6 @@ "built-ins/Array/prototype/some/resizable-buffer.js": "CRASH", "built-ins/Array/prototype/sort/comparefn-resizable-buffer.js": "CRASH", "built-ins/Array/prototype/sort/resizable-buffer-default-comparator.js": "CRASH", - "built-ins/Array/prototype/splice/create-proto-from-ctor-realm-array.js": "FAIL", - "built-ins/Array/prototype/splice/create-proto-from-ctor-realm-non-array.js": "FAIL", "built-ins/Array/prototype/splice/create-revoked-proxy.js": "CRASH", "built-ins/Array/prototype/toLocaleString/S15.4.4.3_A1_T1.js": "CRASH", "built-ins/Array/prototype/toLocaleString/S15.4.4.3_A3_T1.js": "CRASH", @@ -887,7 +876,6 @@ "built-ins/BigInt/prototype/toString/radix-2-to-36.js": "CRASH", "built-ins/BigInt/prototype/toString/radix-err.js": "CRASH", "built-ins/BigInt/prototype/toString/string-is-code-units-of-decimal-digits-only.js": "CRASH", - "built-ins/BigInt/prototype/valueOf/cross-realm.js": "FAIL", "built-ins/BigInt/wrapper-object-ordinary-toprimitive.js": "FAIL", "built-ins/Boolean/S9.2_A6_T1.js": "CRASH", "built-ins/Boolean/proto-from-ctor-realm.js": "FAIL", @@ -1420,13 +1408,10 @@ "built-ins/Function/15.3.5.4_2-91gs.js": "CRASH", "built-ins/Function/15.3.5.4_2-92gs.js": "CRASH", "built-ins/Function/15.3.5.4_2-93gs.js": "CRASH", - "built-ins/Function/call-bind-this-realm-undef.js": "FAIL", "built-ins/Function/call-bind-this-realm-value.js": "FAIL", "built-ins/Function/internals/Call/class-ctor-realm.js": "FAIL", "built-ins/Function/internals/Construct/base-ctor-revoked-proxy-realm.js": "FAIL", "built-ins/Function/internals/Construct/base-ctor-revoked-proxy.js": "CRASH", - "built-ins/Function/internals/Construct/derived-return-val-realm.js": "FAIL", - "built-ins/Function/internals/Construct/derived-this-uninitialized-realm.js": "FAIL", "built-ins/Function/proto-from-ctor-realm-prototype.js": "FAIL", "built-ins/Function/proto-from-ctor-realm.js": "FAIL", "built-ins/Function/prototype/Symbol.hasInstance/length.js": "FAIL", @@ -2918,7 +2903,6 @@ "built-ins/Proxy/apply/null-handler.js": "CRASH", "built-ins/Proxy/apply/return-abrupt.js": "CRASH", "built-ins/Proxy/apply/trap-is-missing-target-is-proxy.js": "CRASH", - "built-ins/Proxy/apply/trap-is-not-callable-realm.js": "FAIL", "built-ins/Proxy/apply/trap-is-null-target-is-proxy.js": "CRASH", "built-ins/Proxy/apply/trap-is-null.js": "CRASH", "built-ins/Proxy/apply/trap-is-undefined-no-property.js": "CRASH", @@ -2931,14 +2915,7 @@ "built-ins/Proxy/construct/null-handler-realm.js": "FAIL", "built-ins/Proxy/construct/null-handler.js": "CRASH", "built-ins/Proxy/construct/return-is-abrupt.js": "CRASH", - "built-ins/Proxy/construct/return-not-object-throws-boolean-realm.js": "FAIL", - "built-ins/Proxy/construct/return-not-object-throws-null-realm.js": "FAIL", - "built-ins/Proxy/construct/return-not-object-throws-number-realm.js": "FAIL", - "built-ins/Proxy/construct/return-not-object-throws-string-realm.js": "FAIL", - "built-ins/Proxy/construct/return-not-object-throws-symbol-realm.js": "FAIL", - "built-ins/Proxy/construct/return-not-object-throws-undefined-realm.js": "FAIL", "built-ins/Proxy/construct/trap-is-missing-target-is-proxy.js": "CRASH", - "built-ins/Proxy/construct/trap-is-not-callable-realm.js": "FAIL", "built-ins/Proxy/construct/trap-is-null-target-is-proxy.js": "CRASH", "built-ins/Proxy/construct/trap-is-null.js": "CRASH", "built-ins/Proxy/construct/trap-is-undefined-no-property.js": "CRASH", @@ -2950,30 +2927,18 @@ "built-ins/Proxy/create-target-is-not-a-constructor.js": "CRASH", "built-ins/Proxy/create-target-is-revoked-function-proxy.js": "CRASH", "built-ins/Proxy/create-target-is-revoked-proxy.js": "CRASH", - "built-ins/Proxy/defineProperty/desc-realm.js": "FAIL", "built-ins/Proxy/defineProperty/null-handler-realm.js": "FAIL", "built-ins/Proxy/defineProperty/null-handler.js": "CRASH", - "built-ins/Proxy/defineProperty/targetdesc-configurable-desc-not-configurable-realm.js": "FAIL", - "built-ins/Proxy/defineProperty/targetdesc-not-compatible-descriptor-not-configurable-target-realm.js": "FAIL", - "built-ins/Proxy/defineProperty/targetdesc-not-compatible-descriptor-realm.js": "FAIL", - "built-ins/Proxy/defineProperty/targetdesc-undefined-not-configurable-descriptor-realm.js": "FAIL", - "built-ins/Proxy/defineProperty/targetdesc-undefined-target-is-not-extensible-realm.js": "FAIL", - "built-ins/Proxy/defineProperty/trap-is-not-callable-realm.js": "FAIL", "built-ins/Proxy/deleteProperty/null-handler.js": "CRASH", - "built-ins/Proxy/deleteProperty/trap-is-not-callable-realm.js": "FAIL", "built-ins/Proxy/deleteProperty/trap-is-null-target-is-proxy.js": "CRASH", "built-ins/Proxy/deleteProperty/trap-is-undefined-target-is-proxy.js": "CRASH", "built-ins/Proxy/get-fn-realm-recursive.js": "FAIL", "built-ins/Proxy/get-fn-realm.js": "FAIL", "built-ins/Proxy/get/null-handler.js": "CRASH", - "built-ins/Proxy/get/trap-is-not-callable-realm.js": "FAIL", "built-ins/Proxy/get/trap-is-null-target-is-proxy.js": "CRASH", "built-ins/Proxy/getOwnPropertyDescriptor/null-handler.js": "CRASH", - "built-ins/Proxy/getOwnPropertyDescriptor/result-type-is-not-object-nor-undefined-realm.js": "FAIL", - "built-ins/Proxy/getOwnPropertyDescriptor/trap-is-not-callable-realm.js": "FAIL", "built-ins/Proxy/getOwnPropertyDescriptor/trap-is-undefined-target-is-proxy.js": "CRASH", "built-ins/Proxy/getPrototypeOf/null-handler.js": "CRASH", - "built-ins/Proxy/getPrototypeOf/trap-is-not-callable-realm.js": "FAIL", "built-ins/Proxy/has/call-with.js": "CRASH", "built-ins/Proxy/has/null-handler-using-with.js": "CRASH", "built-ins/Proxy/has/null-handler.js": "CRASH", @@ -2982,16 +2947,11 @@ "built-ins/Proxy/has/return-false-targetdesc-not-configurable-using-with.js": "CRASH", "built-ins/Proxy/has/return-is-abrupt-with.js": "CRASH", "built-ins/Proxy/has/return-true-target-prop-exists-using-with.js": "CRASH", - "built-ins/Proxy/has/trap-is-not-callable-realm.js": "FAIL", "built-ins/Proxy/has/trap-is-not-callable-using-with.js": "CRASH", "built-ins/Proxy/has/trap-is-undefined-using-with.js": "CRASH", "built-ins/Proxy/isExtensible/null-handler.js": "CRASH", - "built-ins/Proxy/isExtensible/trap-is-not-callable-realm.js": "FAIL", "built-ins/Proxy/ownKeys/null-handler.js": "CRASH", - "built-ins/Proxy/ownKeys/return-not-list-object-throws-realm.js": "FAIL", - "built-ins/Proxy/ownKeys/trap-is-not-callable-realm.js": "FAIL", "built-ins/Proxy/preventExtensions/null-handler.js": "CRASH", - "built-ins/Proxy/preventExtensions/trap-is-not-callable-realm.js": "FAIL", "built-ins/Proxy/proxy-newtarget.js": "CRASH", "built-ins/Proxy/revocable/handler-is-revoked-proxy.js": "CRASH", "built-ins/Proxy/revocable/proxy.js": "CRASH", @@ -3009,9 +2969,7 @@ "built-ins/Proxy/revocable/tco-fn-realm.js": "FAIL", "built-ins/Proxy/set/null-handler.js": "CRASH", "built-ins/Proxy/set/trap-is-missing-target-is-proxy.js": "CRASH", - "built-ins/Proxy/set/trap-is-not-callable-realm.js": "FAIL", "built-ins/Proxy/setPrototypeOf/null-handler.js": "CRASH", - "built-ins/Proxy/setPrototypeOf/trap-is-not-callable-realm.js": "FAIL", "built-ins/Reflect/defineProperty/length.js": "FAIL", "built-ins/Reflect/getOwnPropertyDescriptor/return-from-accessor-descriptor.js": "FAIL", "built-ins/Reflect/ownKeys/return-non-enumerable-keys.js": "FAIL", @@ -5350,29 +5308,14 @@ "built-ins/StringIteratorPrototype/next/next-iteration.js": "CRASH", "built-ins/StringIteratorPrototype/next/next-missing-internal-slots.js": "CRASH", "built-ins/Symbol/asyncDispose/prop-desc.js": "CRASH", - "built-ins/Symbol/asyncIterator/cross-realm.js": "FAIL", "built-ins/Symbol/dispose/prop-desc.js": "CRASH", "built-ins/Symbol/for/create-value.js": "FAIL", - "built-ins/Symbol/for/cross-realm.js": "FAIL", "built-ins/Symbol/for/description.js": "FAIL", "built-ins/Symbol/for/retrieve-value.js": "FAIL", "built-ins/Symbol/for/to-string-err.js": "FAIL", - "built-ins/Symbol/hasInstance/cross-realm.js": "FAIL", - "built-ins/Symbol/isConcatSpreadable/cross-realm.js": "FAIL", - "built-ins/Symbol/iterator/cross-realm.js": "FAIL", "built-ins/Symbol/keyFor/arg-non-symbol.js": "FAIL", "built-ins/Symbol/keyFor/arg-symbol-registry-miss.js": "FAIL", - "built-ins/Symbol/keyFor/cross-realm.js": "FAIL", - "built-ins/Symbol/match/cross-realm.js": "FAIL", - "built-ins/Symbol/matchAll/cross-realm.js": "FAIL", "built-ins/Symbol/prototype/Symbol.toPrimitive/removed-symbol-wrapper-ordinary-toprimitive.js": "FAIL", - "built-ins/Symbol/replace/cross-realm.js": "FAIL", - "built-ins/Symbol/search/cross-realm.js": "FAIL", - "built-ins/Symbol/species/cross-realm.js": "FAIL", - "built-ins/Symbol/split/cross-realm.js": "FAIL", - "built-ins/Symbol/toPrimitive/cross-realm.js": "FAIL", - "built-ins/Symbol/toStringTag/cross-realm.js": "FAIL", - "built-ins/Symbol/unscopables/cross-realm.js": "FAIL", "built-ins/Temporal/Duration/basic.js": "FAIL", "built-ins/Temporal/Duration/builtin.js": "FAIL", "built-ins/Temporal/Duration/call-builtin.js": "FAIL", @@ -9531,7 +9474,6 @@ "built-ins/Temporal/prop-desc.js": "FAIL", "built-ins/Temporal/toStringTag/prop-desc.js": "FAIL", "built-ins/Temporal/toStringTag/string.js": "FAIL", - "built-ins/ThrowTypeError/distinct-cross-realm.js": "FAIL", "built-ins/TypedArray/from/arylk-get-length-error.js": "CRASH", "built-ins/TypedArray/from/arylk-to-length-error.js": "CRASH", "built-ins/TypedArray/from/from-array-mapper-detaches-result.js": "CRASH", @@ -10664,33 +10606,25 @@ "built-ins/TypedArrayConstructors/internals/DefineOwnProperty/key-is-minus-zero.js": "CRASH", "built-ins/TypedArrayConstructors/internals/DefineOwnProperty/key-is-not-integer.js": "CRASH", "built-ins/TypedArrayConstructors/internals/DefineOwnProperty/key-is-not-numeric-index-throws.js": "FAIL", - "built-ins/TypedArrayConstructors/internals/Delete/BigInt/detached-buffer-realm.js": "FAIL", "built-ins/TypedArrayConstructors/internals/Delete/BigInt/indexed-value-sab-non-strict.js": "CRASH", "built-ins/TypedArrayConstructors/internals/Delete/BigInt/indexed-value-sab-strict.js": "CRASH", "built-ins/TypedArrayConstructors/internals/Delete/BigInt/key-is-not-minus-zero-non-strict.js": "CRASH", "built-ins/TypedArrayConstructors/internals/Delete/BigInt/key-is-not-minus-zero-strict.js": "CRASH", - "built-ins/TypedArrayConstructors/internals/Delete/detached-buffer-realm.js": "FAIL", "built-ins/TypedArrayConstructors/internals/Delete/indexed-value-sab-non-strict.js": "CRASH", "built-ins/TypedArrayConstructors/internals/Delete/indexed-value-sab-strict.js": "CRASH", "built-ins/TypedArrayConstructors/internals/Delete/key-is-not-minus-zero-non-strict.js": "CRASH", "built-ins/TypedArrayConstructors/internals/Delete/key-is-not-minus-zero-strict.js": "CRASH", - "built-ins/TypedArrayConstructors/internals/Get/BigInt/detached-buffer-realm.js": "FAIL", "built-ins/TypedArrayConstructors/internals/Get/BigInt/indexed-value-sab.js": "CRASH", "built-ins/TypedArrayConstructors/internals/Get/BigInt/key-is-not-integer.js": "FAIL", "built-ins/TypedArrayConstructors/internals/Get/BigInt/key-is-not-minus-zero.js": "FAIL", - "built-ins/TypedArrayConstructors/internals/Get/detached-buffer-realm.js": "FAIL", "built-ins/TypedArrayConstructors/internals/Get/indexed-value-sab.js": "CRASH", "built-ins/TypedArrayConstructors/internals/Get/key-is-not-integer.js": "FAIL", "built-ins/TypedArrayConstructors/internals/Get/key-is-not-minus-zero.js": "FAIL", - "built-ins/TypedArrayConstructors/internals/GetOwnProperty/BigInt/detached-buffer-realm.js": "FAIL", "built-ins/TypedArrayConstructors/internals/GetOwnProperty/BigInt/key-is-minus-zero.js": "FAIL", - "built-ins/TypedArrayConstructors/internals/GetOwnProperty/detached-buffer-realm.js": "FAIL", "built-ins/TypedArrayConstructors/internals/GetOwnProperty/key-is-minus-zero.js": "FAIL", - "built-ins/TypedArrayConstructors/internals/HasProperty/BigInt/detached-buffer-realm.js": "FAIL", "built-ins/TypedArrayConstructors/internals/HasProperty/BigInt/infinity-with-detached-buffer.js": "CRASH", "built-ins/TypedArrayConstructors/internals/HasProperty/BigInt/key-is-minus-zero.js": "FAIL", "built-ins/TypedArrayConstructors/internals/HasProperty/BigInt/key-is-not-integer.js": "FAIL", - "built-ins/TypedArrayConstructors/internals/HasProperty/detached-buffer-realm.js": "FAIL", "built-ins/TypedArrayConstructors/internals/HasProperty/infinity-with-detached-buffer.js": "CRASH", "built-ins/TypedArrayConstructors/internals/HasProperty/key-is-minus-zero.js": "FAIL", "built-ins/TypedArrayConstructors/internals/HasProperty/key-is-not-integer.js": "FAIL", @@ -10700,7 +10634,6 @@ "built-ins/TypedArrayConstructors/internals/OwnPropertyKeys/integer-indexes-and-string-and-symbol-keys-.js": "CRASH", "built-ins/TypedArrayConstructors/internals/OwnPropertyKeys/integer-indexes-and-string-keys.js": "CRASH", "built-ins/TypedArrayConstructors/internals/OwnPropertyKeys/integer-indexes.js": "CRASH", - "built-ins/TypedArrayConstructors/internals/Set/BigInt/detached-buffer-realm.js": "FAIL", "built-ins/TypedArrayConstructors/internals/Set/BigInt/detached-buffer.js": "CRASH", "built-ins/TypedArrayConstructors/internals/Set/BigInt/key-is-canonical-invalid-index-prototype-chain-set.js": "CRASH", "built-ins/TypedArrayConstructors/internals/Set/BigInt/key-is-canonical-invalid-index-reflect-set.js": "CRASH", @@ -10708,7 +10641,6 @@ "built-ins/TypedArrayConstructors/internals/Set/BigInt/key-is-not-integer.js": "CRASH", "built-ins/TypedArrayConstructors/internals/Set/BigInt/tonumber-value-throws.js": "CRASH", "built-ins/TypedArrayConstructors/internals/Set/conversion-operation.js": "CRASH", - "built-ins/TypedArrayConstructors/internals/Set/detached-buffer-realm.js": "FAIL", "built-ins/TypedArrayConstructors/internals/Set/detached-buffer.js": "CRASH", "built-ins/TypedArrayConstructors/internals/Set/key-is-canonical-invalid-index-prototype-chain-set.js": "CRASH", "built-ins/TypedArrayConstructors/internals/Set/key-is-canonical-invalid-index-reflect-set.js": "CRASH", @@ -11411,7 +11343,6 @@ "language/eval-code/indirect/parse-failure-4.js": "FAIL", "language/eval-code/indirect/parse-failure-5.js": "FAIL", "language/eval-code/indirect/parse-failure-6.js": "FAIL", - "language/eval-code/indirect/realm.js": "FAIL", "language/eval-code/indirect/super-call.js": "FAIL", "language/eval-code/indirect/super-prop.js": "FAIL", "language/eval-code/indirect/switch-case-decl-strict.js": "FAIL", @@ -12333,7 +12264,6 @@ "language/expressions/bitwise-xor/bigint-toprimitive.js": "CRASH", "language/expressions/bitwise-xor/bigint-wrapped-values.js": "FAIL", "language/expressions/bitwise-xor/bigint.js": "CRASH", - "language/expressions/call/eval-realm-indirect.js": "FAIL", "language/expressions/call/eval-strictness-inherit-non-strict.js": "CRASH", "language/expressions/call/tco-call-args.js": "CRASH", "language/expressions/call/tco-member-args.js": "CRASH", @@ -15622,7 +15552,6 @@ "language/expressions/new.target/value-via-super-call.js": "CRASH", "language/expressions/new.target/value-via-super-property.js": "CRASH", "language/expressions/new.target/value-via-tagged-template.js": "CRASH", - "language/expressions/new/non-ctor-err-realm.js": "FAIL", "language/expressions/object/computed-property-name-topropertykey-before-value-evaluation.js": "FAIL", "language/expressions/object/concise-generator.js": "CRASH", "language/expressions/object/cpn-obj-lit-computed-property-name-from-assignment-expression-logical-and.js": "FAIL", @@ -16153,7 +16082,6 @@ "language/global-code/decl-func-dup.js": "FAIL", "language/global-code/export.js": "CRASH", "language/global-code/import.js": "CRASH", - "language/global-code/script-decl-func-dups.js": "FAIL", "language/global-code/script-decl-func.js": "FAIL", "language/global-code/script-decl-lex-deletion.js": "FAIL", "language/global-code/script-decl-lex-lex.js": "CRASH", @@ -16161,7 +16089,6 @@ "language/global-code/script-decl-lex-var-declared-via-eval.js": "FAIL", "language/global-code/script-decl-lex-var.js": "FAIL", "language/global-code/script-decl-lex.js": "FAIL", - "language/global-code/script-decl-var-collision.js": "CRASH", "language/global-code/script-decl-var.js": "FAIL", "language/identifier-resolution/S10.2.2_A1_T5.js": "CRASH", "language/identifier-resolution/S10.2.2_A1_T6.js": "CRASH", @@ -21287,8 +21214,6 @@ "language/statements/with/unscopables-inc-dec.js": "CRASH", "language/statements/with/unscopables-not-referenced-for-undef.js": "CRASH", "language/statements/with/unscopables-prop-get-err.js": "CRASH", - "language/types/reference/get-value-prop-base-primitive-realm.js": "FAIL", - "language/types/reference/put-value-prop-base-primitive-realm.js": "FAIL", "language/types/string/S8.4_A8.js": "FAIL", "staging/ArrayBuffer/resizable/access-out-of-bounds-typed-array.js": "CRASH", "staging/ArrayBuffer/resizable/array-fill-parameter-conversion-resizes.js": "CRASH", @@ -21465,7 +21390,6 @@ "staging/decorators/accessor-as-identifier.js": "CRASH", "staging/decorators/private-auto-accessor.js": "CRASH", "staging/decorators/public-auto-accessor.js": "CRASH", - "staging/explicit-resource-management/Symbol/dispose/cross-realm.js": "FAIL", "staging/explicit-resource-management/Symbol/dispose/prop-desc.js": "FAIL", "staging/explicit-resource-management/async-disposable-stack-adopt-and-defer-not-callable.js": "FAIL", "staging/explicit-resource-management/async-disposable-stack-adopt.js": "FAIL", @@ -21522,7 +21446,6 @@ "staging/sm/Array/from-iterator-close.js": "CRASH", "staging/sm/Array/from_errors.js": "FAIL", "staging/sm/Array/from_primitive.js": "CRASH", - "staging/sm/Array/from_realms.js": "FAIL", "staging/sm/Array/from_string.js": "CRASH", "staging/sm/Array/from_this.js": "CRASH", "staging/sm/Array/frozen-dense-array.js": "FAIL", @@ -21857,7 +21780,6 @@ "staging/sm/PrivateName/proxy-init-set.js": "CRASH", "staging/sm/PrivateName/read-private-eval.js": "CRASH", "staging/sm/Promise/bug-1288382.js": "CRASH", - "staging/sm/Promise/bug-1289040.js": "FAIL", "staging/sm/Promise/for-of-iterator-uses-getv.js": "CRASH", "staging/sm/Promise/promise-species.js": "FAIL", "staging/sm/Proxy/getPrototypeOf.js": "CRASH", @@ -22024,13 +21946,11 @@ "staging/sm/Symbol/keyFor.js": "CRASH", "staging/sm/Symbol/property-inheritance.js": "FAIL", "staging/sm/Symbol/property-reflection.js": "FAIL", - "staging/sm/Symbol/realms.js": "FAIL", "staging/sm/Symbol/species.js": "CRASH", "staging/sm/Symbol/toPrimitive.js": "FAIL", "staging/sm/Symbol/toString.js": "CRASH", "staging/sm/Symbol/toStringTag.js": "CRASH", "staging/sm/Symbol/typeof.js": "CRASH", - "staging/sm/Symbol/well-known.js": "FAIL", "staging/sm/Temporal/Calendar/compare-to-datetimeformat.js": "FAIL", "staging/sm/Temporal/PlainDate/from-constrain-hebrew.js": "CRASH", "staging/sm/Temporal/PlainDate/from-constrain-japanese.js": "CRASH", @@ -22239,7 +22159,6 @@ "staging/sm/extensions/array-inherited-__proto__.js": "CRASH", "staging/sm/extensions/bug472534.js": "CRASH", "staging/sm/extensions/censor-strict-caller.js": "FAIL", - "staging/sm/extensions/cross-global-eval-is-indirect.js": "FAIL", "staging/sm/extensions/dataview.js": "FAIL", "staging/sm/extensions/destructuring-__proto__-shorthand-assignment-before-var.js": "CRASH", "staging/sm/extensions/destructuring-__proto__-shorthand-assignment.js": "CRASH", @@ -22253,7 +22172,6 @@ "staging/sm/extensions/getOwnPropertyNames-__proto__.js": "FAIL", "staging/sm/extensions/inc-dec-functioncall.js": "FAIL", "staging/sm/extensions/mutable-proto-special-form.js": "FAIL", - "staging/sm/extensions/new-cross-compartment.js": "FAIL", "staging/sm/extensions/new-parenthesization.js": "CRASH", "staging/sm/extensions/newer-type-functions-caller-arguments.js": "CRASH", "staging/sm/extensions/proxy-strict.js": "FAIL", @@ -22345,7 +22263,6 @@ "staging/sm/object/getter-name.js": "FAIL", "staging/sm/object/method-non-constructor.js": "FAIL", "staging/sm/object/property-descriptor-order.js": "CRASH", - "staging/sm/object/setPrototypeOf-cross-realm-cycle.js": "FAIL", "staging/sm/object/toLocaleString-01.js": "CRASH", "staging/sm/object/toPrimitive-callers.js": "CRASH", "staging/sm/object/toPrimitive.js": "CRASH", @@ -22382,7 +22299,6 @@ "staging/sm/regress/regress-602621.js": "CRASH", "staging/sm/regress/regress-609617.js": "FAIL", "staging/sm/regress/regress-610026.js": "TIMEOUT", - "staging/sm/regress/regress-636364.js": "FAIL", "staging/sm/regress/regress-665355.js": "FAIL", "staging/sm/regress/regress-672892.js": "CRASH", "staging/sm/statements/for-in-with-gc-and-unvisited-deletion.js": "FAIL", @@ -22403,7 +22319,6 @@ "staging/sm/syntax/linefeed-at-eof-in-unterminated-string-or-template.js": "FAIL", "staging/sm/syntax/omitted-catch-binding.js": "CRASH", "staging/sm/syntax/syntax-parsed-arrow-then-directive.js": "FAIL", - "staging/sm/syntax/yield-as-identifier.js": "FAIL", "staging/sm/types/8.12.5-01.js": "CRASH", "staging/source-phase-imports/import-source-source-text-module.js": "FAIL" } \ No newline at end of file diff --git a/tests/metrics.json b/tests/metrics.json index 73c59cc78..7021f46e4 100644 --- a/tests/metrics.json +++ b/tests/metrics.json @@ -1,8 +1,8 @@ { "results": { - "crash": 13120, - "fail": 9059, - "pass": 24557, + "crash": 13225, + "fail": 8869, + "pass": 24642, "skip": 65, "timeout": 0, "unresolved": 0 diff --git a/tests/nova-harness.js b/tests/nova-harness.js index ec9ea1a3c..3505193f4 100644 --- a/tests/nova-harness.js +++ b/tests/nova-harness.js @@ -16,8 +16,22 @@ // to `$262.global` (needed for old tests, since `globalThis` was only added in // ES2020). -globalThis.$262 = { - global: globalThis, - detachArrayBuffer: __nova__.detachArrayBuffer, -}; -delete globalThis.__nova__; \ No newline at end of file +// This function must be completely independent of the current realm, and it +// should do everything through the `global` argument. This makes sure that +// everything works correctly in realms created from `$262.createRealm()`. +// It's also declared with let to make sure it doesn't pollute the global. +let buildHarness = (global) => { + const novaObj = global.__nova__; + delete global.__nova__; + + global.$262 = global.Object(); + global.$262.global = global; + global.$262.detachArrayBuffer = novaObj.detachArrayBuffer; + global.$262.createRealm = () => { + return buildHarness(novaObj.createRealm()); + }; + global.$262.evalScript = global.eval; + return global.$262; +} + +buildHarness(globalThis);