File tree Expand file tree Collapse file tree 3 files changed +43
-3
lines changed Expand file tree Collapse file tree 3 files changed +43
-3
lines changed Original file line number Diff line number Diff line change @@ -25,6 +25,7 @@ const {
25
25
const {
26
26
getOptionValue,
27
27
refreshOptions,
28
+ getEmbedderOptions,
28
29
} = require ( 'internal/options' ) ;
29
30
const { reconnectZeroFillToggle } = require ( 'internal/buffer' ) ;
30
31
const {
@@ -241,7 +242,7 @@ function setupWarningHandler() {
241
242
242
243
// https://fetch.spec.whatwg.org/
243
244
function setupFetch ( ) {
244
- if ( process . config . variables . node_no_browser_globals ||
245
+ if ( getEmbedderOptions ( ) . noBrowserGlobals ||
245
246
getOptionValue ( '--no-experimental-fetch' ) ) {
246
247
return ;
247
248
}
@@ -291,7 +292,7 @@ function setupFetch() {
291
292
// TODO(aduh95): move this to internal/bootstrap/web/* when the CLI flag is
292
293
// removed.
293
294
function setupWebCrypto ( ) {
294
- if ( process . config . variables . node_no_browser_globals ||
295
+ if ( getEmbedderOptions ( ) . noBrowserGlobals ||
295
296
getOptionValue ( '--no-experimental-global-webcrypto' ) ) {
296
297
return ;
297
298
}
@@ -339,7 +340,7 @@ function setupCodeCoverage() {
339
340
// TODO(daeyeon): move this to internal/bootstrap/web/* when the CLI flag is
340
341
// removed.
341
342
function setupCustomEvent ( ) {
342
- if ( process . config . variables . node_no_browser_globals ||
343
+ if ( getEmbedderOptions ( ) . noBrowserGlobals ||
343
344
getOptionValue ( '--no-experimental-global-customevent' ) ) {
344
345
return ;
345
346
}
Original file line number Diff line number Diff line change @@ -1243,6 +1243,12 @@ void GetEmbedderOptions(const FunctionCallbackInfo<Value>& args) {
1243
1243
Boolean::New (isolate, env->no_global_search_paths ()))
1244
1244
.IsNothing ()) return ;
1245
1245
1246
+ if (ret->Set (context,
1247
+ FIXED_ONE_BYTE_STRING (env->isolate (), " noBrowserGlobals" ),
1248
+ Boolean::New (isolate, env->no_browser_globals ()))
1249
+ .IsNothing ())
1250
+ return ;
1251
+
1246
1252
args.GetReturnValue ().Set (ret);
1247
1253
}
1248
1254
Original file line number Diff line number Diff line change @@ -38,6 +38,39 @@ class EnvironmentTest : public EnvironmentTestFixture {
38
38
}
39
39
};
40
40
41
+ TEST_F (EnvironmentTest, EnvironmentWithoutBrowserGlobals) {
42
+ const v8::HandleScope handle_scope (isolate_);
43
+ Argv argv;
44
+ Env env{handle_scope, argv, node::EnvironmentFlags::kNoBrowserGlobals };
45
+
46
+ SetProcessExitHandler (*env, [&](node::Environment* env_, int exit_code) {
47
+ EXPECT_EQ (*env, env_);
48
+ EXPECT_EQ (exit_code, 0 );
49
+ node::Stop (*env);
50
+ });
51
+
52
+ node::LoadEnvironment (
53
+ *env,
54
+ " const assert = require('assert');"
55
+ " const path = require('path');"
56
+ " const relativeRequire = "
57
+ " require('module').createRequire(path.join(process.cwd(), 'stub.js'));"
58
+ " const { intrinsics, nodeGlobals } = "
59
+ " relativeRequire('./test/common/globals');"
60
+ " const items = Object.getOwnPropertyNames(globalThis);"
61
+ " const leaks = [];"
62
+ " for (const item of items) {"
63
+ " if (intrinsics.has(item)) {"
64
+ " continue;"
65
+ " }"
66
+ " if (nodeGlobals.has(item)) {"
67
+ " continue;"
68
+ " }"
69
+ " leaks.push(item);"
70
+ " }"
71
+ " assert.deepStrictEqual(leaks, []);" );
72
+ }
73
+
41
74
TEST_F (EnvironmentTest, EnvironmentWithESMLoader) {
42
75
const v8::HandleScope handle_scope (isolate_);
43
76
Argv argv;
You can’t perform that action at this time.
0 commit comments