Commit 02cca56648d for nodejs
commit 02cca56648da4aa101ecb37b618e89968380475f
Author: Yagiz Nizipli <yagiz@nizipli.com>
Date: Sat Nov 28 23:31:41 2026 -0500
src: remove experimental ShadowRealm support
The TC39 ShadowRealm proposal remains unimplemented by browsers,
and WPT removed ShadowRealm test coverage. Remove the Node.js
host integration, the --experimental-shadow-realm CLI flag, and
related tests.
Refs: https://github.com/web-platform-tests/wpt/pull/59794
Refs: https://github.com/nodejs/node/issues/42528
Signed-off-by: Yagiz Nizipli <yagiz@nizipli.com>
Co-authored-by: Yagiz Nizipli <anonrig@users.noreply.github.com>
PR-URL: https://github.com/nodejs/node/pull/65650
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
diff --git a/doc/api/cli.md b/doc/api/cli.md
index 352b2df2d86..26aa4ce9951 100644
--- a/doc/api/cli.md
+++ b/doc/api/cli.md
@@ -1604,16 +1604,6 @@ Use this flag to generate a blob that can be injected into the Node.js
binary to produce a [single executable application][]. See the documentation
about [this configuration][`--experimental-sea-config`] for details.
-### `--experimental-shadow-realm`
-
-<!-- YAML
-added:
- - v19.0.0
- - v18.13.0
--->
-
-Use this flag to enable [ShadowRealm][] support.
-
### `--experimental-storage-inspection`
<!-- YAML
@@ -4412,7 +4402,6 @@ one is included in the list below.
* `--experimental-quic`
* `--experimental-repl-await`
* `--experimental-require-module`
-* `--experimental-shadow-realm`
* `--experimental-specifier-resolution`
* `--experimental-stream-iter`
* `--experimental-strip-private-modules`
@@ -4921,8 +4910,6 @@ documented here:
### `--expose-gc`
-### `--harmony-shadow-realm`
-
### `--heap-snapshot-on-oom`
### `--interpreted-frames-native-stack`
@@ -5029,7 +5016,6 @@ node --stack-trace-limit=12 -p -e "Error.stackTraceLimit" # prints 12
[Permission Model]: permissions.md#permission-model
[REPL]: repl.md
[ScriptCoverage]: https://chromedevtools.github.io/devtools-protocol/tot/Profiler#type-ScriptCoverage
-[ShadowRealm]: https://github.com/tc39/proposal-shadowrealm
[Source Map]: https://tc39.es/ecma426/
[Test tags]: test.md#test-tags
[TypeScript type-stripping]: typescript.md#type-stripping
diff --git a/doc/node-config-schema.json b/doc/node-config-schema.json
index 23bd0795ec0..65d50c4d328 100644
--- a/doc/node-config-schema.json
+++ b/doc/node-config-schema.json
@@ -379,10 +379,6 @@
"type": "boolean",
"description": "Legacy alias for --require-module"
},
- "experimental-shadow-realm": {
- "type": "boolean",
- "description": ""
- },
"experimental-sqlite": {
"type": "boolean",
"description": "experimental node:sqlite module"
diff --git a/doc/node.1 b/doc/node.1
index 4b52511704f..c491f183ad2 100644
--- a/doc/node.1
+++ b/doc/node.1
@@ -909,9 +909,6 @@ Use this flag to generate a blob that can be injected into the Node.js
binary to produce a single executable application. See the documentation
about this configuration for details.
.
-.It Fl -experimental-shadow-realm
-Use this flag to enable ShadowRealm support.
-.
.It Fl -experimental-storage-inspection
Enable experimental support for storage inspection
.
@@ -2358,8 +2355,6 @@ one is included in the list below.
.It
\fB--experimental-require-module\fR
.It
-\fB--experimental-shadow-realm\fR
-.It
\fB--experimental-specifier-resolution\fR
.It
\fB--experimental-stream-iter\fR
diff --git a/eslint.config.mjs b/eslint.config.mjs
index 9c4ad8f0565..45464ffc0d6 100644
--- a/eslint.config.mjs
+++ b/eslint.config.mjs
@@ -144,7 +144,6 @@ export default [
ReadableStreamDefaultReader: 'readonly',
Response: 'readonly',
sessionStorage: 'readonly',
- ShadowRealm: 'readonly',
Storage: 'readonly',
SubtleCrypto: 'readonly',
TextDecoderStream: 'readonly',
diff --git a/lib/eslint.config_partial.mjs b/lib/eslint.config_partial.mjs
index bebcd25fb3d..14554b084d4 100644
--- a/lib/eslint.config_partial.mjs
+++ b/lib/eslint.config_partial.mjs
@@ -250,12 +250,6 @@ export default [
name: 'Response',
message: "Use `const { Response } = require('internal/deps/undici/undici');` instead of the global.",
},
- // ShadowRealm is not available in primordials because it can be
- // disabled with --no-harmony-shadow-realm CLI flag.
- {
- name: 'ShadowRealm',
- message: 'Use `const { ShadowRealm } = globalThis;` instead of the global.',
- },
// SharedArrayBuffer is not available in primordials because it can be
// disabled with --enable-sharedarraybuffer-per-context CLI flag.
{
diff --git a/lib/internal/bootstrap/realm.js b/lib/internal/bootstrap/realm.js
index fd3e4eb64c8..16fbc965bab 100644
--- a/lib/internal/bootstrap/realm.js
+++ b/lib/internal/bootstrap/realm.js
@@ -1,5 +1,5 @@
// This file is executed in every realm that is created by Node.js, including
-// the context of main thread, worker threads, and ShadowRealms.
+// the context of the main thread and worker threads.
// Only per-realm internal states and bindings should be bootstrapped in this
// file and no globals should be exposed to the user code.
//
@@ -233,8 +233,8 @@ const internalBuiltinIds = builtinIds
.filter((id) => StringPrototypeStartsWith(id, 'internal/') && id !== selfId);
// When --expose-internals is on we'll add the internal builtin ids to these.
-let canBeRequiredByUsersList = new SafeSet(publicBuiltinIds);
-let canBeRequiredByUsersWithoutSchemeList =
+const canBeRequiredByUsersList = new SafeSet(publicBuiltinIds);
+const canBeRequiredByUsersWithoutSchemeList =
new SafeSet(publicBuiltinIds.filter((id) => !schemelessBlockList.has(id)));
/**
@@ -302,13 +302,6 @@ class BuiltinModule {
(policy) => ArrayPrototypeSlice(policy));
}
- static setRealmAllowRequireByUsers(ids) {
- canBeRequiredByUsersList =
- new SafeSet(ArrayPrototypeFilter(ids, (id) => ArrayPrototypeIncludes(publicBuiltinIds, id)));
- canBeRequiredByUsersWithoutSchemeList =
- new SafeSet(ArrayPrototypeFilter(ids, (id) => !schemelessBlockList.has(id)));
- }
-
// To be called during pre-execution when --expose-internals is on.
// Enables the user-land module loader to access internal modules.
static exposeInternals() {
diff --git a/lib/internal/bootstrap/shadow_realm.js b/lib/internal/bootstrap/shadow_realm.js
deleted file mode 100644
index b99502355d9..00000000000
--- a/lib/internal/bootstrap/shadow_realm.js
+++ /dev/null
@@ -1,21 +0,0 @@
-'use strict';
-
-// This script sets up the context for shadow realms.
-
-const {
- prepareShadowRealmExecution,
-} = require('internal/process/pre_execution');
-const {
- BuiltinModule,
-} = require('internal/bootstrap/realm');
-
-BuiltinModule.setRealmAllowRequireByUsers([
- /**
- * The built-in modules exposed in the ShadowRealm must each be providing
- * platform capabilities with no authority to cause side effects such as
- * I/O or mutation of values that are shared across different realms within
- * the same Node.js environment.
- */
-]);
-
-prepareShadowRealmExecution();
diff --git a/lib/internal/errors.js b/lib/internal/errors.js
index de552b408f5..000a36c4489 100644
--- a/lib/internal/errors.js
+++ b/lib/internal/errors.js
@@ -187,11 +187,9 @@ function isPermissionModelError(err) {
/**
* Every realm has its own prepareStackTraceCallback. When `error.stack` is
- * accessed, if the error is created in a shadow realm, the shadow realm's
- * prepareStackTraceCallback is invoked. Otherwise, the principal realm's
- * prepareStackTraceCallback is invoked. Note that accessing `error.stack`
- * of error objects created in a VM Context will always invoke the
- * prepareStackTraceCallback of the principal realm.
+ * accessed, the principal realm's prepareStackTraceCallback is invoked.
+ * Note that accessing `error.stack` of error objects created in a VM Context
+ * will always invoke the prepareStackTraceCallback of the principal realm.
* @param {object} globalThis The global object of the realm that the error was
* created in. When the error object is created in a VM Context, this is the
* global object of that VM Context.
diff --git a/lib/internal/process/pre_execution.js b/lib/internal/process/pre_execution.js
index 09c07f427db..0b93bd65329 100644
--- a/lib/internal/process/pre_execution.js
+++ b/lib/internal/process/pre_execution.js
@@ -78,34 +78,6 @@ function prepareWorkerThreadExecution() {
});
}
-function prepareShadowRealmExecution() {
- // Patch the process object with legacy properties and normalizations.
- // Do not expand argv1 as it is not available in ShadowRealm.
- patchProcessObject(false);
- setupDebugEnv();
-
- // Preload modules are not supported in ShadowRealm.
- initializeModuleLoaders({ shouldPreloadModules: false });
- const {
- privateSymbols: {
- host_defined_option_symbol,
- },
- } = internalBinding('util');
- const {
- vm_dynamic_import_default_internal,
- } = internalBinding('symbols');
-
- // For ShadowRealm.prototype.importValue(), the referrer name is
- // always null, so the native ImportModuleDynamically() callback would
- // always fallback to look up the host-defined option from the
- // global object using host_defined_option_symbol. Using
- // vm_dynamic_import_default_internal as the host-defined option
- // instructs the JS-land importModuleDynamicallyCallback() to
- // proxy the request to defaultImportModuleDynamically().
- globalThis[host_defined_option_symbol] =
- vm_dynamic_import_default_internal;
-}
-
function prepareExecution(options) {
const { expandArgv1, initializeModules, isMainThread, shouldPreloadModules } = options;
@@ -339,7 +311,6 @@ function initializeModuleLoaders(options) {
if (getEmbedderOptions().hasEmbedderPreload) {
runEmbedderPreload();
}
- // Preload modules are not supported in ShadowRealm.
if (shouldPreloadModules) {
loadPreloadModules();
}
@@ -880,7 +851,6 @@ module.exports = {
initializeModuleLoaders,
prepareMainThreadExecution,
prepareWorkerThreadExecution,
- prepareShadowRealmExecution,
prepareTestRunnerMainExecution,
markBootstrapComplete,
loadPreloadModules,
diff --git a/node.gyp b/node.gyp
index 86ae0adbeee..c5f3c99dedc 100644
--- a/node.gyp
+++ b/node.gyp
@@ -167,7 +167,6 @@
'src/node_sea.cc',
'src/node_sea_bin.cc',
'src/node_serdes.cc',
- 'src/node_shadow_realm.cc',
'src/node_snapshotable.cc',
'src/node_sockaddr.cc',
'src/node_stat_watcher.cc',
@@ -305,7 +304,6 @@
'src/node_revert.h',
'src/node_root_certs.h',
'src/node_sea.h',
- 'src/node_shadow_realm.h',
'src/node_snapshotable.h',
'src/node_snapshot_builder.h',
'src/node_sockaddr.h',
diff --git a/src/README.md b/src/README.md
index 7cdf099ff81..112c7470fa2 100644
--- a/src/README.md
+++ b/src/README.md
@@ -286,8 +286,7 @@ V8 refers to each of these global objects and their associated builtins as a
Currently, in Node.js there is one main `Context` associated with the
principal [`Realm`][] of an [`Environment`][] instance, and a number of
-subsidiary `Context`s that are created with `vm.Context` or associated with
-[`ShadowRealm`][].
+subsidiary `Context`s that are created with `vm.Context`.
Most Node.js features will only work inside a context associated with a
`Realm`. The only exception at the time of writing are [`MessagePort`][]
@@ -358,14 +357,11 @@ Each ECMAScript realm comes with a global object and a set of intrinsic
objects. An ECMAScript realm has a `[[HostDefined]]` field, which represents
the Node.js [`Realm`][] object.
-Every `Realm` instance is created for a particular [`Context`][]. A `Realm`
-can be a principal realm or a synthetic realm. A principal realm is created
-for each `Environment`'s main [`Context`][]. A synthetic realm is created
-for the [`Context`][] of each [`ShadowRealm`][] constructed from the JS API. No
-`Realm` is created for the [`Context`][] of a `vm.Context`.
+Every `Realm` instance is created for a particular [`Context`][]. A principal
+realm is created for each `Environment`'s main [`Context`][]. No `Realm` is
+created for the [`Context`][] of a `vm.Context`.
-Native bindings and built-in modules can be evaluated in either a principal
-realm or a synthetic realm.
+Native bindings and built-in modules are evaluated in the principal realm.
The `Realm` class contains a large number of different fields for
different built-in modules, for example the memory for a `Uint32Array` that
@@ -861,10 +857,8 @@ and requests are cancelled if possible.
#### Cleanup realms and BaseObjects
-Realm cleanup depends on the realm types. All realms are destroyed when the
-[`Environment`][] is destroyed with the cleanup hook. A [`ShadowRealm`][] can
-also be destroyed by the garbage collection when there is no strong reference
-to it.
+All realms are destroyed when the [`Environment`][] is destroyed with the
+cleanup hook.
Every [`BaseObject`][] is tracked with its creation realm and will be destroyed
when the realm is tearing down.
@@ -1493,7 +1487,6 @@ static void GetUserInfo(const FunctionCallbackInfo<Value>& args) {
[`MessagePort`]: https://nodejs.org/api/worker_threads.html#worker_threads_class_messageport
[`Realm`]: #realm
[`ReqWrap`]: #reqwrap
-[`ShadowRealm`]: https://github.com/tc39/proposal-shadowrealm
[`async_hooks` module]: https://nodejs.org/api/async_hooks.html
[`async_wrap.h`]: async_wrap.h
[`base_object.h`]: base_object.h
diff --git a/src/api/environment.cc b/src/api/environment.cc
index 7e8d95690c2..265ef37cd40 100644
--- a/src/api/environment.cc
+++ b/src/api/environment.cc
@@ -14,7 +14,6 @@
#include "node_options-inl.h"
#include "node_platform.h"
#include "node_realm-inl.h"
-#include "node_shadow_realm.h"
#include "node_snapshot_builder.h"
#include "node_v8_platform-inl.h"
#include "node_wasm_web_api.h"
@@ -273,13 +272,6 @@ void SetIsolateMiscHandlers(v8::Isolate* isolate, const IsolateSettings& s) {
isolate->SetWasmStreamingCallback(wasm_web_api::StartStreamingCompilation);
}
- Mutex::ScopedLock lock(node::per_process::cli_options_mutex);
- if (per_process::cli_options->get_per_isolate_options()
- ->experimental_shadow_realm) {
- isolate->SetHostCreateShadowRealmContextCallback(
- shadow_realm::HostCreateShadowRealmContextCallback);
- }
-
if ((s.flags & SHOULD_NOT_SET_PROMISE_REJECTION_CALLBACK) == 0) {
auto* promise_reject_cb = s.promise_reject_callback ?
s.promise_reject_callback : PromiseRejectCallback;
diff --git a/src/async_wrap.cc b/src/async_wrap.cc
index 3869656eb21..5fcd99a5cdb 100644
--- a/src/async_wrap.cc
+++ b/src/async_wrap.cc
@@ -500,8 +500,6 @@ void AsyncWrap::CreatePerContextProperties(Local<Object> target,
#undef FORCE_SET_TARGET_FIELD
// TODO(legendecas): async hook functions are not realm-aware yet.
- // This simply avoid overriding principal realm's functions when a
- // ShadowRealm initializes the binding.
realm->set_async_hooks_init_function(Local<Function>());
realm->set_async_hooks_before_function(Local<Function>());
realm->set_async_hooks_after_function(Local<Function>());
diff --git a/src/env.cc b/src/env.cc
index 10adc705b93..f75ae9d1d12 100644
--- a/src/env.cc
+++ b/src/env.cc
@@ -16,7 +16,6 @@
#include "node_options-inl.h"
#include "node_process-inl.h"
#include "node_profiling.h"
-#include "node_shadow_realm.h"
#include "node_snapshotable.h"
#include "node_v8_platform-inl.h"
#include "node_worker.h"
@@ -305,14 +304,6 @@ void Environment::UntrackContext(Local<Context> context) {
}
}
-void Environment::TrackShadowRealm(shadow_realm::ShadowRealm* realm) {
- shadow_realms_.insert(realm);
-}
-
-void Environment::UntrackShadowRealm(shadow_realm::ShadowRealm* realm) {
- shadow_realms_.erase(realm);
-}
-
AsyncHooks::DefaultTriggerAsyncIdScope::DefaultTriggerAsyncIdScope(
Environment* env, double default_trigger_async_id)
: async_hooks_(env->async_hooks()) {
@@ -1306,8 +1297,6 @@ Environment::~Environment() {
inspector_agent_.reset();
#endif
- // Sub-realms should have been cleared with Environment's cleanup.
- DCHECK_EQ(shadow_realms_.size(), 0);
principal_realm_.reset();
if (trace_state_observer_) {
@@ -2757,7 +2746,6 @@ void Environment::MemoryInfo(MemoryTracker* tracker) const {
tracker->TrackField("timeout_info", timeout_info_);
tracker->TrackField("tick_info", tick_info_);
tracker->TrackField("principal_realm", principal_realm_);
- tracker->TrackField("shadow_realms", shadow_realms_);
// FIXME(joyeecheung): track other fields in Environment.
// Currently MemoryTracker is unable to track these
diff --git a/src/env.h b/src/env.h
index ae60cceaffb..b45b6737421 100644
--- a/src/env.h
+++ b/src/env.h
@@ -120,9 +120,6 @@ inline constexpr std::array<std::string_view,
"node_sqlite3.BackupJob",
"zlib"};
-namespace shadow_realm {
-class ShadowRealm;
-}
namespace contextify {
class ContextifyScript;
class CompiledFnEntry;
@@ -762,8 +759,7 @@ class Cleanable {
/**
* Environment is a per-isolate data structure that represents an execution
- * environment. Each environment has a principal realm. An environment can
- * create multiple subsidiary synthetic realms.
+ * environment. Each environment has a principal realm.
*/
class Environment final : public MemoryRetainer {
public:
@@ -854,8 +850,6 @@ class Environment final : public MemoryRetainer {
Realm* realm,
const ContextInfo& info);
void UnassignFromContext(v8::Local<v8::Context> context);
- void TrackShadowRealm(shadow_realm::ShadowRealm* realm);
- void UntrackShadowRealm(shadow_realm::ShadowRealm* realm);
void StartProfilerIdleNotifier();
@@ -1364,7 +1358,6 @@ class Environment final : public MemoryRetainer {
size_t async_callback_scope_depth_ = 0;
std::vector<double> destroy_async_id_list_;
- std::unordered_set<shadow_realm::ShadowRealm*> shadow_realms_;
#if HAVE_INSPECTOR
std::unique_ptr<profiler::V8CoverageConnection> coverage_connection_;
diff --git a/src/node_context_data.h b/src/node_context_data.h
index cdeea184912..a8494e27cdf 100644
--- a/src/node_context_data.h
+++ b/src/node_context_data.h
@@ -57,7 +57,7 @@ static_assert(NODE_CONTEXT_TAG < V8_EMBEDDER_DATA_ARRAY_SIZE,
* via v8::Context::SetAlignedPointerInEmbedderDataV2() (for pointers) and
* v8::Context::SetEmbedderDataV3() (for v8::Values).
*
- * There are five types of contexts in Node.js:
+ * There are four types of contexts in Node.js:
* 1. Default V8 context, with nothing Node.js-specific. This is normally only
* created by the embedders that uses v8::Context APIs directly and is not
* available through the Node.js JS APIs. Its context snapshot in the
@@ -85,16 +85,10 @@ static_assert(NODE_CONTEXT_TAG < V8_EMBEDDER_DATA_ARRAY_SIZE,
* the initialization code is in node::ContextifyContext::New().
* Its context snapshot in the built-in V8 startup snapshot is stored at
* node::SnapshotData::kNodeVMContextIndex.
- * 5. ShadowRealm context: When a JS ShadowRealm is created via new ShadowRealm,
- * it gets its own v8::Context. It also shares the thread, the v8::Isolate
- * and the node::Environment with the context where the ShadowRealm
- * constructor is called. The corresponding data structure is
- * node::ShadowRealm and the initialization code is in
- * node::ShadowRealm::New().
*/
enum ContextEmbedderIndex {
// Pointer to the node::Environment associated with the context. Only set for
- // context type 2-5. Used by Environment::GetCurrent(context) to retrieve
+ // context type 2-4. Used by Environment::GetCurrent(context) to retrieve
// the node::Environment associated with any Node.js context in the
// V8 callbacks.
kEnvironment = NODE_CONTEXT_EMBEDDER_DATA_INDEX,
@@ -104,13 +98,13 @@ enum ContextEmbedderIndex {
kSandboxObject = NODE_CONTEXT_SANDBOX_OBJECT_INDEX,
// A v8::Value indicating whether the context allows WebAssembly code
// generation.
- // Only set for context type 2-5, and for them the default is v8::True.
+ // Only set for context type 2-4, and for them the default is v8::True.
// For context type 4 it's configurable via options.codeGeneration.wasm in the
// vm APIs. Used in the default v8::AllowWasmCodeGenerationCallback.
kAllowWasmCodeGeneration = NODE_CONTEXT_ALLOW_WASM_CODE_GENERATION_INDEX,
// A v8::Value indicating whether the context allows code generation via
// eval() or new Function().
- // Only set for context type 2-5, and for them the default is v8::True.
+ // Only set for context type 2-4, and for them the default is v8::True.
// For context type 4 it's configurable via options.codeGeneration.strings in
// the
// vm APIs. Used in the default v8::AllowCodeGenerationFromStringsCallback.
@@ -121,14 +115,14 @@ enum ContextEmbedderIndex {
// to the ContextifyContext from the property interceptors.
kContextifyContext = NODE_CONTEXT_CONTEXTIFY_CONTEXT_INDEX,
// Pointer to the node::Realm associated with the context.
- // Only set for context type 2-3 and 5. For context type 2-3, it points to a
- // node::PrincipalRealm. For context type 5 it points to a node::ShadowRealm.
+ // Only set for context type 2-3. For those types it points to a
+ // node::PrincipalRealm.
// Used by Realm::GetCurrent(context) to retrieve the associated node::Realm
// with any Node.js context in the V8 callbacks.
kRealm = NODE_CONTEXT_REALM_INDEX,
// Pointer to a constant address which is
// node::ContextEmbedderTag::kNodeContextTagPtr.
- // Only set for context type 2-5. Used by ContextEmbedderTag::IsNodeContext()
+ // Only set for context type 2-4. Used by ContextEmbedderTag::IsNodeContext()
// to check whether a context is a Node.js context.
kContextTag = NODE_CONTEXT_TAG,
};
diff --git a/src/node_options.cc b/src/node_options.cc
index 9226832dd68..b5579198eaf 100644
--- a/src/node_options.cc
+++ b/src/node_options.cc
@@ -1628,14 +1628,6 @@ PerIsolateOptionsParser::PerIsolateOptionsParser(
AddOption("--experimental-top-level-await", "", NoOp{}, kAllowedInEnvvar);
- AddOption("--experimental-shadow-realm",
- "",
- BOOL_FIELD(experimental_shadow_realm),
- kAllowedInEnvvar);
- AddOption("--harmony-shadow-realm", "", V8Option{});
- Implies("--experimental-shadow-realm", "--harmony-shadow-realm");
- Implies("--harmony-shadow-realm", "--experimental-shadow-realm");
- ImpliesNot("--no-harmony-shadow-realm", "--experimental-shadow-realm");
AddOption("--build-snapshot",
"Generate a snapshot blob when the process exits.",
BOOL_FIELD(build_snapshot),
diff --git a/src/node_options.h b/src/node_options.h
index 6c67c153198..260d6e43e83 100644
--- a/src/node_options.h
+++ b/src/node_options.h
@@ -357,7 +357,6 @@ class PerIsolateOptions : public Options {
DEFINE_BOOL_FIELD(track_heap_objects) = false;
DEFINE_BOOL_FIELD(report_uncaught_exception) = false;
DEFINE_BOOL_FIELD(report_on_signal) = false;
- DEFINE_BOOL_FIELD(experimental_shadow_realm) = false;
DEFINE_BOOL_FIELD(build_snapshot) = false;
inline EnvironmentOptions* get_per_env_options();
diff --git a/src/node_realm.h b/src/node_realm.h
index 810d48c8e3e..9e7ae82f083 100644
--- a/src/node_realm.h
+++ b/src/node_realm.h
@@ -68,18 +68,14 @@ class CppgcWrapperList
* with a global object and a set of intrinsic objects. An ECMAScript realm has
* a [[HostDefined]] field, which contains the node::Realm object.
*
- * Realm can be a principal realm or a synthetic realm. A principal realm is
- * created with an Environment as its principal global environment to evaluate
- * scripts. A synthetic realm is created with JS APIs like ShadowRealm.
- *
- * Native bindings and builtin modules can be evaluated in either a principal
- * realm or a synthetic realm.
+ * Each Environment has a principal realm used to evaluate scripts. Native
+ * bindings and builtin modules are evaluated in that realm. No Realm is
+ * created for the Context of a vm.Context.
*/
class Realm : public MemoryRetainer {
public:
enum Kind {
kPrincipal,
- kShadowRealm,
};
static inline Realm* GetCurrent(v8::Isolate* isolate);
diff --git a/src/node_shadow_realm.cc b/src/node_shadow_realm.cc
deleted file mode 100644
index 1273555b50c..00000000000
--- a/src/node_shadow_realm.cc
+++ /dev/null
@@ -1,178 +0,0 @@
-#include "node_shadow_realm.h"
-#include "env-inl.h"
-#include "node_errors.h"
-#include "node_process.h"
-
-namespace node {
-namespace shadow_realm {
-using v8::Context;
-using v8::EscapableHandleScope;
-using v8::HandleScope;
-using v8::Local;
-using v8::MaybeLocal;
-using v8::Object;
-using v8::String;
-using v8::Value;
-
-using TryCatchScope = node::errors::TryCatchScope;
-
-// static
-ShadowRealm* ShadowRealm::New(Environment* env) {
- ShadowRealm* realm = new ShadowRealm(env);
- // TODO(legendecas): required by node::PromiseRejectCallback.
- // Remove this once promise rejection doesn't need to be handled across
- // realms.
- realm->context()->SetSecurityToken(
- env->principal_realm()->context()->GetSecurityToken());
-
- // We do not expect the realm bootstrapping to throw any
- // exceptions. If it does, exit the current Node.js instance.
- TryCatchScope try_catch(env, TryCatchScope::CatchMode::kFatal);
- if (realm->RunBootstrapping().IsEmpty()) {
- delete realm;
- return nullptr;
- }
- return realm;
-}
-
-// static
-MaybeLocal<Context> HostCreateShadowRealmContextCallback(
- Local<Context> initiator_context) {
- Environment* env = Environment::GetCurrent(initiator_context);
- EscapableHandleScope scope(env->isolate());
-
- // We do not expect the realm bootstrapping to throw any
- // exceptions. If it does, exit the current Node.js instance.
- TryCatchScope try_catch(env, TryCatchScope::CatchMode::kFatal);
- ShadowRealm* realm = ShadowRealm::New(env);
- if (realm != nullptr) {
- return scope.Escape(realm->context());
- }
- return MaybeLocal<Context>();
-}
-
-// static
-void ShadowRealm::WeakCallback(const v8::WeakCallbackInfo<ShadowRealm>& data) {
- ShadowRealm* realm = data.GetParameter();
- realm->context_.Reset();
-
- // Yield to pending weak callbacks before deleting the realm.
- // This is necessary to avoid cleaning up base objects before their scheduled
- // weak callbacks are invoked, which can lead to accessing to v8 apis during
- // the first pass of the weak callback.
- realm->env()->SetImmediate([realm](Environment* env) { delete realm; });
- // Remove the cleanup hook to avoid deleting the realm again.
- realm->env()->RemoveCleanupHook(DeleteMe, realm);
-}
-
-// static
-void ShadowRealm::DeleteMe(void* data) {
- ShadowRealm* realm = static_cast<ShadowRealm*>(data);
- // Clear the context handle to avoid invoking the weak callback again.
- // Also, the context internal slots are cleared and the context is no longer
- // reference to the realm.
- delete realm;
-}
-
-ShadowRealm::ShadowRealm(Environment* env)
- : Realm(env, NewContext(env->isolate()), kShadowRealm) {
- context_.SetWeak(this, WeakCallback, v8::WeakCallbackType::kParameter);
- CreateProperties();
-
- env->TrackShadowRealm(this);
- env->AddCleanupHook(DeleteMe, this);
-}
-
-ShadowRealm::~ShadowRealm() {
- while (PendingCleanup()) {
- RunCleanup();
- }
-
- env_->UntrackShadowRealm(this);
-
- if (context_.IsEmpty()) {
- // This most likely happened because the weak callback cleared it.
- return;
- }
-
- {
- HandleScope handle_scope(isolate());
- env_->UnassignFromContext(context());
- }
-}
-
-v8::Local<v8::Context> ShadowRealm::context() const {
- Local<Context> ctx = PersistentToLocal::Default(isolate_, context_);
- DCHECK(!ctx.IsEmpty());
- return ctx;
-}
-
-// V8 can not infer reference cycles between global persistent handles, e.g.
-// the Realm's Context handle and the per-realm function handles.
-// Attach the per-realm strong persistent values' lifetime to the context's
-// global object to avoid the strong global references to the per-realm objects
-// keep the context alive indefinitely.
-#define V(PropertyName, TypeName) \
- v8::Local<TypeName> ShadowRealm::PropertyName() const { \
- return PersistentToLocal::Default(isolate_, PropertyName##_); \
- } \
- void ShadowRealm::set_##PropertyName(v8::Local<TypeName> value) { \
- HandleScope scope(isolate_); \
- PropertyName##_.Reset(isolate_, value); \
- v8::Local<v8::Context> ctx = context(); \
- if (value.IsEmpty()) { \
- ctx->Global() \
- ->SetPrivate(ctx, \
- isolate_data()->per_realm_##PropertyName(), \
- v8::Undefined(isolate_)) \
- .ToChecked(); \
- } else { \
- PropertyName##_.SetWeak(); \
- ctx->Global() \
- ->SetPrivate(ctx, isolate_data()->per_realm_##PropertyName(), value) \
- .ToChecked(); \
- } \
- }
-PER_REALM_STRONG_PERSISTENT_VALUES(V)
-#undef V
-
-v8::MaybeLocal<v8::Value> ShadowRealm::BootstrapRealm() {
- HandleScope scope(isolate_);
-
- // Skip "internal/bootstrap/node" as it installs node globals and per-isolate
- // callbacks.
-
- if (!env_->no_browser_globals()) {
- if (ExecuteBootstrapper("internal/bootstrap/web/exposed-wildcard")
- .IsEmpty()) {
- return MaybeLocal<Value>();
- }
- }
-
- // The process object is not exposed globally in ShadowRealm yet.
- // However, the process properties need to be setup for built-in modules.
- // Specifically, process.cwd() is needed by the ESM loader.
- if (ExecuteBootstrapper(
- "internal/bootstrap/switches/does_not_own_process_state")
- .IsEmpty()) {
- return MaybeLocal<Value>();
- }
-
- // Setup process.env proxy.
- Local<String> env_string = FIXED_ONE_BYTE_STRING(isolate_, "env");
- Local<Object> env_proxy;
- if (!isolate_data()->env_proxy_template()->NewInstance(context()).ToLocal(
- &env_proxy) ||
- process_object()->Set(context(), env_string, env_proxy).IsNothing()) {
- return MaybeLocal<Value>();
- }
-
- if (ExecuteBootstrapper("internal/bootstrap/shadow_realm").IsEmpty()) {
- return MaybeLocal<Value>();
- }
-
- return v8::True(isolate_);
-}
-
-} // namespace shadow_realm
-} // namespace node
diff --git a/src/node_shadow_realm.h b/src/node_shadow_realm.h
deleted file mode 100644
index 65844349f7a..00000000000
--- a/src/node_shadow_realm.h
+++ /dev/null
@@ -1,46 +0,0 @@
-#ifndef SRC_NODE_SHADOW_REALM_H_
-#define SRC_NODE_SHADOW_REALM_H_
-
-#if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
-
-#include "node_realm.h"
-#include "v8.h"
-
-namespace node {
-namespace shadow_realm {
-
-class ShadowRealm final : public Realm {
- public:
- static ShadowRealm* New(Environment* env);
-
- SET_MEMORY_INFO_NAME(ShadowRealm)
- SET_SELF_SIZE(ShadowRealm)
-
- v8::Local<v8::Context> context() const override;
-
-#define V(PropertyName, TypeName) \
- v8::Local<TypeName> PropertyName() const override; \
- void set_##PropertyName(v8::Local<TypeName> value) override;
- PER_REALM_STRONG_PERSISTENT_VALUES(V)
-#undef V
-
- protected:
- v8::MaybeLocal<v8::Value> BootstrapRealm() override;
-
- private:
- static void WeakCallback(const v8::WeakCallbackInfo<ShadowRealm>& data);
- static void DeleteMe(void* data);
-
- explicit ShadowRealm(Environment* env);
- ~ShadowRealm();
-};
-
-v8::MaybeLocal<v8::Context> HostCreateShadowRealmContextCallback(
- v8::Local<v8::Context> initiator_context);
-
-} // namespace shadow_realm
-} // namespace node
-
-#endif // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
-
-#endif // SRC_NODE_SHADOW_REALM_H_
diff --git a/test/common/globals.js b/test/common/globals.js
index 4ecc307f765..ab5f5e76fbe 100644
--- a/test/common/globals.js
+++ b/test/common/globals.js
@@ -49,7 +49,6 @@ const intrinsics = new Set([
'WeakSet',
'Proxy',
'Reflect',
- 'ShadowRealm',
'FinalizationRegistry',
'WeakRef',
'decodeURI',
diff --git a/test/fixtures/es-module-shadow-realm/custom-hooks.js b/test/fixtures/es-module-shadow-realm/custom-hooks.js
deleted file mode 100644
index b62d25fb62f..00000000000
--- a/test/fixtures/es-module-shadow-realm/custom-hooks.js
+++ /dev/null
@@ -1,15 +0,0 @@
-// This fixture is used to test that customization hooks are not enabled in the ShadowRealm.
-
-'use strict';
-const assert = require('assert');
-
-async function workInChildProcess() {
- // Assert that the process is running with custom hooks.
- const moduleNamespace = await import('file:///42.mjs');
- assert.strictEqual(moduleNamespace.default, 42);
-
- const realm = new ShadowRealm();
- await assert.rejects(realm.importValue('file:///42.mjs', 'default'), TypeError);
-}
-
-workInChildProcess();
diff --git a/test/fixtures/es-module-shadow-realm/preload-main.js b/test/fixtures/es-module-shadow-realm/preload-main.js
deleted file mode 100644
index 4258b012ad6..00000000000
--- a/test/fixtures/es-module-shadow-realm/preload-main.js
+++ /dev/null
@@ -1,9 +0,0 @@
-// This fixture is used to test that --require preload modules are not enabled in the ShadowRealm.
-
-'use strict';
-const assert = require('assert');
-
-assert.strictEqual(globalThis.preload, 42);
-const realm = new ShadowRealm();
-const value = realm.evaluate(`globalThis.preload`);
-assert.strictEqual(value, undefined);
diff --git a/test/fixtures/es-module-shadow-realm/preload.js b/test/fixtures/es-module-shadow-realm/preload.js
deleted file mode 100644
index dbbcb65e5a1..00000000000
--- a/test/fixtures/es-module-shadow-realm/preload.js
+++ /dev/null
@@ -1 +0,0 @@
-globalThis.preload = 42;
diff --git a/test/fixtures/es-module-shadow-realm/re-export-state-counter.mjs b/test/fixtures/es-module-shadow-realm/re-export-state-counter.mjs
deleted file mode 100644
index 50a6aa3fe1e..00000000000
--- a/test/fixtures/es-module-shadow-realm/re-export-state-counter.mjs
+++ /dev/null
@@ -1,3 +0,0 @@
-// This module verifies that the module specifier is resolved relative to the
-// current module and not the current working directory in the ShadowRealm.
-export { getCounter } from "./state-counter.mjs";
diff --git a/test/fixtures/es-module-shadow-realm/register-hooks.js b/test/fixtures/es-module-shadow-realm/register-hooks.js
deleted file mode 100644
index 46b51a3a842..00000000000
--- a/test/fixtures/es-module-shadow-realm/register-hooks.js
+++ /dev/null
@@ -1,17 +0,0 @@
-'use strict';
-const { registerHooks } = require('node:module');
-
-registerHooks({
- resolve(specifier, context, nextResolve) {
- if (specifier.startsWith('file:///') && specifier.includes('42')) {
- return { shortCircuit: true, url: specifier };
- }
- return nextResolve(specifier, context);
- },
- load(url, context, nextLoad) {
- if (url.startsWith('file:///') && url.includes('42')) {
- return { shortCircuit: true, format: 'module', source: 'export default 42' };
- }
- return nextLoad(url, context);
- },
-});
diff --git a/test/fixtures/es-module-shadow-realm/state-counter.mjs b/test/fixtures/es-module-shadow-realm/state-counter.mjs
deleted file mode 100644
index c547658bf45..00000000000
--- a/test/fixtures/es-module-shadow-realm/state-counter.mjs
+++ /dev/null
@@ -1,4 +0,0 @@
-let counter = 0;
-export const getCounter = () => {
- return counter++;
-};
diff --git a/test/fixtures/wpt/console/console-log-shadowrealm-manual.html b/test/fixtures/wpt/console/console-log-shadowrealm-manual.html
deleted file mode 100644
index b091a850c0c..00000000000
--- a/test/fixtures/wpt/console/console-log-shadowrealm-manual.html
+++ /dev/null
@@ -1,10 +0,0 @@
-<!DOCTYPE html>
-<mete charset=utf-8>
-<title>Console Logging Manual Test</title>
-<p>Open the console inside the developer tools. It should contain one entry saying "test passed".</p>
-<script>
-const sr = new ShadowRealm();
-sr.evaluate(`
- console.log("test passed");
-`);
-</script>
diff --git a/test/fixtures/wpt/console/idlharness-shadowrealm.window.js b/test/fixtures/wpt/console/idlharness-shadowrealm.window.js
deleted file mode 100644
index 8f68252dcd2..00000000000
--- a/test/fixtures/wpt/console/idlharness-shadowrealm.window.js
+++ /dev/null
@@ -1,5 +0,0 @@
-// META: script=/resources/idlharness-shadowrealm.js
-
-// https://console.spec.whatwg.org/
-
-idl_test_shadowrealm(["console"], []);
diff --git a/test/fixtures/wpt/dom/abort/timeout-shadowrealm.any.js b/test/fixtures/wpt/dom/abort/timeout-shadowrealm.any.js
deleted file mode 100644
index c87b047c221..00000000000
--- a/test/fixtures/wpt/dom/abort/timeout-shadowrealm.any.js
+++ /dev/null
@@ -1,5 +0,0 @@
-// META: global=shadowrealm
-
-test(t => {
- assert_not_own_property(AbortSignal, "timeout", "AbortSignal does not have a 'timeout' property");
-}, "AbortSignal.timeout() is not exposed in ShadowRealm");
diff --git a/test/fixtures/wpt/encoding/idlharness-shadowrealm.window.js b/test/fixtures/wpt/encoding/idlharness-shadowrealm.window.js
deleted file mode 100644
index baf3efcbb02..00000000000
--- a/test/fixtures/wpt/encoding/idlharness-shadowrealm.window.js
+++ /dev/null
@@ -1,2 +0,0 @@
-// META: script=/resources/idlharness-shadowrealm.js
-idl_test_shadowrealm(["encoding"], ["streams"]);
diff --git a/test/fixtures/wpt/hr-time/idlharness-shadowrealm.window.js b/test/fixtures/wpt/hr-time/idlharness-shadowrealm.window.js
deleted file mode 100644
index 3209db5f41b..00000000000
--- a/test/fixtures/wpt/hr-time/idlharness-shadowrealm.window.js
+++ /dev/null
@@ -1,2 +0,0 @@
-// META: script=/resources/idlharness-shadowrealm.js
-idl_test_shadowrealm(["hr-time"], ["html", "dom"]);
diff --git a/test/fixtures/wpt/performance-timeline/idlharness-shadowrealm.window.js b/test/fixtures/wpt/performance-timeline/idlharness-shadowrealm.window.js
deleted file mode 100644
index 6caaa330613..00000000000
--- a/test/fixtures/wpt/performance-timeline/idlharness-shadowrealm.window.js
+++ /dev/null
@@ -1,2 +0,0 @@
-// META: script=/resources/idlharness-shadowrealm.js
-idl_test_shadowrealm(["performance-timeline"], ["hr-time", "dom"]);
diff --git a/test/fixtures/wpt/user-timing/idlharness-shadowrealm.window.js b/test/fixtures/wpt/user-timing/idlharness-shadowrealm.window.js
deleted file mode 100644
index 340da96f749..00000000000
--- a/test/fixtures/wpt/user-timing/idlharness-shadowrealm.window.js
+++ /dev/null
@@ -1,2 +0,0 @@
-// META: script=/resources/idlharness-shadowrealm.js
-idl_test_shadowrealm(["user-timing"], ["hr-time", "performance-timeline", "dom"]);
diff --git a/test/parallel/parallel.status b/test/parallel/parallel.status
index 1d183d62249..f20fadaa4ca 100644
--- a/test/parallel/parallel.status
+++ b/test/parallel/parallel.status
@@ -5,9 +5,6 @@ prefix parallel
# sample-test : PASS,FLAKY
[true] # This section applies to all platforms
-# https://github.com/nodejs/node/issues/52273
-test-shadow-realm-gc: SKIP
-test-shadow-realm-gc-module: SKIP
# Until V8 provides a better way to check for flag mismatch without
# making the code cache/snapshot unreproducible, disable the test
diff --git a/test/parallel/test-shadow-realm-allowed-builtin-modules.js b/test/parallel/test-shadow-realm-allowed-builtin-modules.js
deleted file mode 100644
index 2aa550ac7bb..00000000000
--- a/test/parallel/test-shadow-realm-allowed-builtin-modules.js
+++ /dev/null
@@ -1,21 +0,0 @@
-// Flags: --experimental-shadow-realm
-'use strict';
-const common = require('../common');
-const assert = require('assert');
-
-async function main() {
- // Verifies that builtin modules can not be imported in the ShadowRealm.
- const realm = new ShadowRealm();
- // The error object created inside the ShadowRealm with the error code
- // property is not copied on the realm boundary. Only the error message
- // is copied. Simply check the error message here.
- await assert.rejects(realm.importValue('fs', 'readFileSync'), {
- message: /Cannot find package 'fs'/,
- });
- // As above, we can only validate the error message, not the error code.
- await assert.rejects(realm.importValue('node:fs', 'readFileSync'), {
- message: /No such built-in module: node:fs/,
- });
-}
-
-main().then(common.mustCall());
diff --git a/test/parallel/test-shadow-realm-custom-loaders.js b/test/parallel/test-shadow-realm-custom-loaders.js
deleted file mode 100644
index 311a8af9b96..00000000000
--- a/test/parallel/test-shadow-realm-custom-loaders.js
+++ /dev/null
@@ -1,24 +0,0 @@
-'use strict';
-const common = require('../common');
-const fixtures = require('../common/fixtures');
-const assert = require('assert');
-
-const commonArgs = [
- '--experimental-shadow-realm',
- '--no-warnings',
-];
-
-async function main() {
- // Verifies that customization hooks are not enabled in the ShadowRealm.
- const child = await common.spawnPromisified(process.execPath, [
- ...commonArgs,
- '--require',
- fixtures.path('es-module-shadow-realm', 'register-hooks.js'),
- fixtures.path('es-module-shadow-realm', 'custom-hooks.js'),
- ]);
-
- assert.strictEqual(child.stderr, '');
- assert.strictEqual(child.code, 0);
-}
-
-main().then(common.mustCall());
diff --git a/test/parallel/test-shadow-realm-gc-module.js b/test/parallel/test-shadow-realm-gc-module.js
deleted file mode 100644
index 6077bf03146..00000000000
--- a/test/parallel/test-shadow-realm-gc-module.js
+++ /dev/null
@@ -1,18 +0,0 @@
-// Flags: --experimental-shadow-realm --max-old-space-size=20
-'use strict';
-
-/**
- * Verifying modules imported by ShadowRealm instances can be correctly
- * garbage collected.
- */
-
-const common = require('../common');
-const fixtures = require('../common/fixtures');
-const { runAndBreathe } = require('../common/gc');
-
-const mod = fixtures.fileURL('es-module-shadow-realm', 'state-counter.mjs');
-
-runAndBreathe(async () => {
- const realm = new ShadowRealm();
- await realm.importValue(mod, 'getCounter');
-}, 100).then(common.mustCall());
diff --git a/test/parallel/test-shadow-realm-gc.js b/test/parallel/test-shadow-realm-gc.js
deleted file mode 100644
index c6de4a32a88..00000000000
--- a/test/parallel/test-shadow-realm-gc.js
+++ /dev/null
@@ -1,24 +0,0 @@
-// Flags: --experimental-shadow-realm --max-old-space-size=20
-'use strict';
-
-/**
- * Verifying ShadowRealm instances can be correctly garbage collected.
- */
-
-const common = require('../common');
-const { runAndBreathe } = require('../common/gc');
-const assert = require('assert');
-const { isMainThread, Worker } = require('worker_threads');
-
-runAndBreathe(() => {
- const realm = new ShadowRealm();
- realm.evaluate('new TextEncoder(); 1;');
-}, 100).then(common.mustCall());
-
-// Test it in worker too.
-if (isMainThread) {
- const worker = new Worker(__filename);
- worker.on('exit', common.mustCall((code) => {
- assert.strictEqual(code, 0);
- }));
-}
diff --git a/test/parallel/test-shadow-realm-globals.js b/test/parallel/test-shadow-realm-globals.js
deleted file mode 100644
index 8e010759798..00000000000
--- a/test/parallel/test-shadow-realm-globals.js
+++ /dev/null
@@ -1,27 +0,0 @@
-// Flags: --experimental-shadow-realm
-'use strict';
-
-require('../common');
-const { intrinsics, webIdlExposedWildcard } = require('../common/globals');
-const assert = require('assert');
-
-// Validates APIs exposed on the ShadowRealm globalThis.
-const shadowRealm = new ShadowRealm();
-const itemsStr = shadowRealm.evaluate(`
-(() => {
- return Object.getOwnPropertyNames(globalThis).join(',');
-})();
-`);
-const items = itemsStr.split(',');
-const leaks = [];
-for (const item of items) {
- if (intrinsics.has(item)) {
- continue;
- }
- if (webIdlExposedWildcard.has(item)) {
- continue;
- }
- leaks.push(item);
-}
-
-assert.deepStrictEqual(leaks, []);
diff --git a/test/parallel/test-shadow-realm-import-value-resolve.js b/test/parallel/test-shadow-realm-import-value-resolve.js
deleted file mode 100644
index eeb00509d53..00000000000
--- a/test/parallel/test-shadow-realm-import-value-resolve.js
+++ /dev/null
@@ -1,31 +0,0 @@
-// Flags: --experimental-shadow-realm
-'use strict';
-const common = require('../common');
-const assert = require('assert');
-const path = require('path');
-const { isMainThread } = require('worker_threads');
-
-if (!isMainThread) {
- common.skip('This test only works on a main thread');
-}
-
-async function main() {
- const realm = new ShadowRealm();
-
- const dirname = __dirname;
- // Set process cwd to the parent directory of __dirname.
- const cwd = path.dirname(dirname);
- process.chdir(cwd);
- // Hardcode the relative path to ensure the string is still a valid relative
- // URL string.
- const relativePath = './fixtures/es-module-shadow-realm/re-export-state-counter.mjs';
-
- // Make sure that the module can not be resolved relative to __filename.
- assert.throws(() => require.resolve(relativePath), { code: 'MODULE_NOT_FOUND' });
-
- // Resolve relative to the current working directory.
- const getCounter = await realm.importValue(relativePath, 'getCounter');
- assert.strictEqual(typeof getCounter, 'function');
-}
-
-main().then(common.mustCall());
diff --git a/test/parallel/test-shadow-realm-module.js b/test/parallel/test-shadow-realm-module.js
deleted file mode 100644
index bc0c2c04f69..00000000000
--- a/test/parallel/test-shadow-realm-module.js
+++ /dev/null
@@ -1,29 +0,0 @@
-// Flags: --experimental-shadow-realm
-'use strict';
-const common = require('../common');
-const fixtures = require('../common/fixtures');
-const assert = require('assert');
-
-async function main() {
- const realm = new ShadowRealm();
- const mod = fixtures.fileURL('es-module-shadow-realm', 'state-counter.mjs');
- const getCounter = await realm.importValue(mod, 'getCounter');
- assert.strictEqual(getCounter(), 0);
- const getCounter1 = await realm.importValue(mod, 'getCounter');
- // Returned value is a newly wrapped function.
- assert.notStrictEqual(getCounter, getCounter1);
- // Verify that the module state is shared between two `importValue` calls.
- assert.strictEqual(getCounter1(), 1);
- assert.strictEqual(getCounter(), 2);
-
- const { getCounter: getCounterThisRealm } = await import(mod);
- assert.notStrictEqual(getCounterThisRealm, getCounter);
- // Verify that the module state is not shared between two realms.
- assert.strictEqual(getCounterThisRealm(), 0);
- assert.strictEqual(getCounter(), 3);
-
- // Verify that shadow realm rejects to import a non-existing module.
- await assert.rejects(realm.importValue('non-exists', 'exports'), TypeError);
-}
-
-main().then(common.mustCall());
diff --git a/test/parallel/test-shadow-realm-preload-module.js b/test/parallel/test-shadow-realm-preload-module.js
deleted file mode 100644
index ebd29c1c4a8..00000000000
--- a/test/parallel/test-shadow-realm-preload-module.js
+++ /dev/null
@@ -1,20 +0,0 @@
-'use strict';
-const common = require('../common');
-const fixtures = require('../common/fixtures');
-const { spawnSyncAndExitWithoutError } = require('../common/child_process');
-
-const commonArgs = [
- '--experimental-shadow-realm',
-];
-
-async function main() {
- // Verifies that --require preload modules are not enabled in the ShadowRealm.
- spawnSyncAndExitWithoutError(process.execPath, [
- ...commonArgs,
- '--require',
- fixtures.path('es-module-shadow-realm', 'preload.js'),
- fixtures.path('es-module-shadow-realm', 'preload-main.js'),
- ]);
-}
-
-main().then(common.mustCall());
diff --git a/test/parallel/test-shadow-realm-prepare-stack-trace.js b/test/parallel/test-shadow-realm-prepare-stack-trace.js
deleted file mode 100644
index 2460f017ee9..00000000000
--- a/test/parallel/test-shadow-realm-prepare-stack-trace.js
+++ /dev/null
@@ -1,53 +0,0 @@
-// Flags: --experimental-shadow-realm
-'use strict';
-
-require('../common');
-const assert = require('assert');
-
-let principalRealmPrepareStackTraceCalled = false;
-Error.prepareStackTrace = (error, trace) => {
- principalRealmPrepareStackTraceCalled = true;
- return `${String(error)}\n at ${trace.join('\n at ')}`;
-};
-
-{
- // Validates inner Error.prepareStackTrace can not leak into the outer realm.
- const shadowRealm = new ShadowRealm();
-
- const stack = shadowRealm.evaluate(`
-Error.prepareStackTrace = (error, trace) => {
- globalThis.leaked = 'inner';
- return 'from shadow realm';
-};
-
-try {
- throw new Error('boom');
-} catch (e) {
- e.stack;
-}
-`);
- assert.ok(!principalRealmPrepareStackTraceCalled);
- assert.strictEqual(stack, 'from shadow realm');
- assert.strictEqual('leaked' in globalThis, false);
-}
-
-{
- // Validates stacks can be generated in the ShadowRealm.
- const shadowRealm = new ShadowRealm();
-
- const stack = shadowRealm.evaluate(`
-function myFunc() {
- throw new Error('boom');
-}
-
-try {
- myFunc();
-} catch (e) {
- e.stack;
-}
-`);
- assert.ok(!principalRealmPrepareStackTraceCalled);
- const lines = stack.split('\n');
- assert.strictEqual(lines[0], 'Error: boom');
- assert.match(lines[1], /^ {4}at myFunc \(.*\)/);
-}
diff --git a/test/parallel/test-shadow-realm.js b/test/parallel/test-shadow-realm.js
deleted file mode 100644
index 0b20265537f..00000000000
--- a/test/parallel/test-shadow-realm.js
+++ /dev/null
@@ -1,12 +0,0 @@
-// Flags: --experimental-shadow-realm
-'use strict';
-
-require('../common');
-const assert = require('assert');
-
-// Validates we can construct ShadowRealm successfully.
-const shadowRealm = new ShadowRealm();
-
-const getter = shadowRealm.evaluate('globalThis.realmValue = "inner"; () => globalThis.realmValue;');
-assert.strictEqual(getter(), 'inner');
-assert.strictEqual('realmValue' in globalThis, false);
diff --git a/test/pummel/test-heapdump-shadow-realm.js b/test/pummel/test-heapdump-shadow-realm.js
deleted file mode 100644
index 66c32986b4c..00000000000
--- a/test/pummel/test-heapdump-shadow-realm.js
+++ /dev/null
@@ -1,39 +0,0 @@
-// Flags: --experimental-shadow-realm
-// This tests heap snapshot integration of ShadowRealm
-
-'use strict';
-require('../common');
-const { validateByRetainingPath } = require('../common/heap');
-const assert = require('assert');
-
-// Before shadow realm is created, no ShadowRealm should be captured.
-{
- const nodes = validateByRetainingPath('Node / ShadowRealm', []);
- assert.strictEqual(nodes.length, 0);
-}
-
-let realm;
-let counter = 0;
-// Create a bunch of un-referenced ShadowRealms to make sure the heap
-// snapshot can handle it.
-function createRealms() {
- // Use setImmediate to give GC some time to kick in to avoid OOM.
- if (counter++ < 10) {
- realm = new ShadowRealm();
- realm.evaluate('undefined');
- setImmediate(createRealms);
- } else {
- validateHeap();
- // Keep the realm alive.
- realm.evaluate('undefined');
- }
-}
-
-function validateHeap() {
- validateByRetainingPath('Node / Environment', [
- { node_name: 'Node / shadow_realms', edge_name: 'shadow_realms' },
- { node_name: 'Node / ShadowRealm' },
- ]);
-}
-
-createRealms();
diff --git a/test/wpt/status/compression.json b/test/wpt/status/compression.json
index 5c73f02a587..0538767b6c0 100644
--- a/test/wpt/status/compression.json
+++ b/test/wpt/status/compression.json
@@ -2,9 +2,6 @@
"compression-with-detach.window.js": {
"requires": ["crypto"]
},
- "idlharness-shadowrealm.window.js": {
- "skip": "ShadowRealm support is not enabled"
- },
"third_party/pako/pako_inflate.min.js": {
"skip": "This is not a test file."
}
diff --git a/test/wpt/status/console.json b/test/wpt/status/console.json
index ba74911d66f..b8f63556399 100644
--- a/test/wpt/status/console.json
+++ b/test/wpt/status/console.json
@@ -2,8 +2,5 @@
"idlharness.any.js": {
"note": "https://github.com/nodejs/node/issues/44185",
"requires": ["crypto", "inspector", "small-icu"]
- },
- "idlharness-shadowrealm.window.js": {
- "skip": "ShadowRealm support is not enabled"
}
}
diff --git a/test/wpt/status/dom/abort.json b/test/wpt/status/dom/abort.json
index 2ff9cc355d6..0967ef424bc 100644
--- a/test/wpt/status/dom/abort.json
+++ b/test/wpt/status/dom/abort.json
@@ -1,5 +1 @@
-{
- "timeout-shadowrealm.any.js": {
- "skip": "ShadowRealm support is not enabled"
- }
-}
+{}
diff --git a/test/wpt/status/encoding.json b/test/wpt/status/encoding.json
index c258031e485..4f5144f4223 100644
--- a/test/wpt/status/encoding.json
+++ b/test/wpt/status/encoding.json
@@ -39,9 +39,6 @@
"idlharness.any.js": {
"requires": ["small-icu"]
},
- "idlharness-shadowrealm.window.js": {
- "skip": "ShadowRealm support is not enabled"
- },
"replacement-encodings.any.js": {
"skip": "decoding-helpers.js needs XMLHttpRequest"
},
diff --git a/test/wpt/status/hr-time.cjs b/test/wpt/status/hr-time.cjs
index 35b82c87a1e..534822b4d31 100644
--- a/test/wpt/status/hr-time.cjs
+++ b/test/wpt/status/hr-time.cjs
@@ -27,10 +27,6 @@ module.exports = {
},
},
- 'idlharness-shadowrealm.window.js': {
- skip: 'ShadowRealm support is not enabled',
- },
-
'window-worker-timeOrigin.window.js': {
skip: 'depends on URL.createObjectURL(blob)',
},
diff --git a/test/wpt/status/performance-timeline.json b/test/wpt/status/performance-timeline.json
index 799ee97538d..d350b5437fe 100644
--- a/test/wpt/status/performance-timeline.json
+++ b/test/wpt/status/performance-timeline.json
@@ -69,9 +69,6 @@
]
}
},
- "idlharness-shadowrealm.window.js": {
- "skip": "ShadowRealm support is not enabled"
- },
"droppedentriescount.any.js": {
"skip": "WPTRunner does not support fetch()"
}
diff --git a/test/wpt/status/streams.json b/test/wpt/status/streams.json
index 5be444999b0..bca0e96bb8f 100644
--- a/test/wpt/status/streams.json
+++ b/test/wpt/status/streams.json
@@ -1,7 +1,4 @@
{
- "idlharness-shadowrealm.window.js": {
- "skip": "ShadowRealm support is not enabled"
- },
"queuing-strategies-size-function-per-global.window.js": {
"skip": "Browser-specific test"
},
diff --git a/test/wpt/status/user-timing.json b/test/wpt/status/user-timing.json
index 7e0e70dcf20..6e2b6e276cc 100644
--- a/test/wpt/status/user-timing.json
+++ b/test/wpt/status/user-timing.json
@@ -1,7 +1,4 @@
{
- "idlharness-shadowrealm.window.js": {
- "skip": "ShadowRealm support is not enabled"
- },
"invoke_with_timing_attributes.worker.js": {
"skip": "importScripts not supported"
},