Skip to content

Commit 0d810b7

Browse files
joyeecheungBridgeAR
authored andcommitted
src: use the config binding to carry --no-browser-globals
Instead of setting it in the process object, since this is a configure-time option. Also added a shim that can be deprecated and removed some time later. PR-URL: #26228 Reviewed-By: Daniel Bevenius <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]>
1 parent fe6c419 commit 0d810b7

File tree

4 files changed

+22
-7
lines changed

4 files changed

+22
-7
lines changed

Diff for: lib/internal/bootstrap/node.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -180,8 +180,7 @@ if (config.hasInspector) {
180180
internalBinding('inspector').registerAsyncHook(enable, disable);
181181
}
182182

183-
const browserGlobals = !process._noBrowserGlobals;
184-
if (browserGlobals) {
183+
if (!config.noBrowserGlobals) {
185184
// Override global console from the one provided by the VM
186185
// to the one implemented by Node.js
187186
// https://console.spec.whatwg.org/#console-namespace

Diff for: lib/internal/bootstrap/pre_execution.js

+14
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,20 @@ function initializeDeprecations() {
135135
'DEP0103') :
136136
types[name];
137137
}
138+
139+
// TODO(joyeecheung): this is a legacy property exposed to process.
140+
// Now that we use the config binding to carry this information, remove
141+
// it from the process. We may consider exposing it properly in
142+
// process.features.
143+
const { noBrowserGlobals } = internalBinding('config');
144+
if (noBrowserGlobals) {
145+
Object.defineProperty(process, '_noBrowserGlobals', {
146+
writable: false,
147+
enumerable: true,
148+
configurable: true,
149+
value: noBrowserGlobals
150+
});
151+
}
138152
}
139153

140154
function setupChildProcessIpcChannel() {

Diff for: src/node_config.cc

+7
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,13 @@ static void Initialize(Local<Object> target,
7070
READONLY_FALSE_PROPERTY(target, "hasInspector");
7171
#endif
7272

73+
// configure --no-browser-globals
74+
#ifdef NODE_NO_BROWSER_GLOBALS
75+
READONLY_TRUE_PROPERTY(target, "noBrowserGlobals");
76+
#else
77+
READONLY_FALSE_PROPERTY(target, "noBrowserGlobals");
78+
#endif // NODE_NO_BROWSER_GLOBALS
79+
7380
READONLY_PROPERTY(target,
7481
"bits",
7582
Number::New(env->isolate(), 8 * sizeof(intptr_t)));

Diff for: src/node_process_object.cc

-5
Original file line numberDiff line numberDiff line change
@@ -233,11 +233,6 @@ MaybeLocal<Object> CreateProcessObject(
233233
READONLY_PROPERTY(process, "throwDeprecation", True(env->isolate()));
234234
}
235235

236-
#ifdef NODE_NO_BROWSER_GLOBALS
237-
// configure --no-browser-globals
238-
READONLY_PROPERTY(process, "_noBrowserGlobals", True(env->isolate()));
239-
#endif // NODE_NO_BROWSER_GLOBALS
240-
241236
// --prof-process
242237
// TODO(addaleax): Remove this.
243238
if (env->options()->prof_process) {

0 commit comments

Comments
 (0)