Commit e2d0195 1 parent dff6c25 commit e2d0195 Copy full SHA for e2d0195
File tree 3 files changed +43
-3
lines changed
3 files changed +43
-3
lines changed Original file line number Diff line number Diff line change @@ -17,6 +17,7 @@ const {
17
17
const {
18
18
getOptionValue,
19
19
refreshOptions,
20
+ getEmbedderOptions,
20
21
} = require ( 'internal/options' ) ;
21
22
const { reconnectZeroFillToggle } = require ( 'internal/buffer' ) ;
22
23
const {
@@ -233,7 +234,7 @@ function setupWarningHandler() {
233
234
234
235
// https://fetch.spec.whatwg.org/
235
236
function setupFetch ( ) {
236
- if ( process . config . variables . node_no_browser_globals ||
237
+ if ( getEmbedderOptions ( ) . noBrowserGlobals ||
237
238
getOptionValue ( '--no-experimental-fetch' ) ) {
238
239
return ;
239
240
}
@@ -283,7 +284,7 @@ function setupFetch() {
283
284
// TODO(aduh95): move this to internal/bootstrap/web/* when the CLI flag is
284
285
// removed.
285
286
function setupWebCrypto ( ) {
286
- if ( process . config . variables . node_no_browser_globals ||
287
+ if ( getEmbedderOptions ( ) . noBrowserGlobals ||
287
288
getOptionValue ( '--no-experimental-global-webcrypto' ) ) {
288
289
return ;
289
290
}
@@ -331,7 +332,7 @@ function setupCodeCoverage() {
331
332
// TODO(daeyeon): move this to internal/bootstrap/web/* when the CLI flag is
332
333
// removed.
333
334
function setupCustomEvent ( ) {
334
- if ( process . config . variables . node_no_browser_globals ||
335
+ if ( getEmbedderOptions ( ) . noBrowserGlobals ||
335
336
getOptionValue ( '--no-experimental-global-customevent' ) ) {
336
337
return ;
337
338
}
Original file line number Diff line number Diff line change @@ -1239,6 +1239,12 @@ void GetEmbedderOptions(const FunctionCallbackInfo<Value>& args) {
1239
1239
Boolean::New (isolate, env->no_global_search_paths ()))
1240
1240
.IsNothing ()) return ;
1241
1241
1242
+ if (ret->Set (context,
1243
+ FIXED_ONE_BYTE_STRING (env->isolate (), " noBrowserGlobals" ),
1244
+ Boolean::New (isolate, env->no_browser_globals ()))
1245
+ .IsNothing ())
1246
+ return ;
1247
+
1242
1248
args.GetReturnValue ().Set (ret);
1243
1249
}
1244
1250
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