Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

src: use the config binding to carry --no-browser-globals #26228

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions lib/internal/bootstrap/node.js
Original file line number Diff line number Diff line change
Expand Up @@ -180,8 +180,7 @@ if (config.hasInspector) {
internalBinding('inspector').registerAsyncHook(enable, disable);
}

const browserGlobals = !process._noBrowserGlobals;
if (browserGlobals) {
if (!config.noBrowserGlobals) {
// Override global console from the one provided by the VM
// to the one implemented by Node.js
// https://console.spec.whatwg.org/#console-namespace
Expand Down
14 changes: 14 additions & 0 deletions lib/internal/bootstrap/pre_execution.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,20 @@ function initializeDeprecations() {
'DEP0103') :
types[name];
}

// TODO(joyeecheung): this is a legacy property exposed to process.
// Now that we use the config binding to carry this information, remove
// it from the process. We may consider exposing it properly in
// process.features.
const { noBrowserGlobals } = internalBinding('config');
if (noBrowserGlobals) {
Object.defineProperty(process, '_noBrowserGlobals', {
writable: false,
enumerable: true,
configurable: true,
value: noBrowserGlobals
});
}
}

function setupChildProcessIpcChannel() {
Expand Down
7 changes: 7 additions & 0 deletions src/node_config.cc
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,13 @@ static void Initialize(Local<Object> target,
READONLY_FALSE_PROPERTY(target, "hasInspector");
#endif

// configure --no-browser-globals
#ifdef NODE_NO_BROWSER_GLOBALS
READONLY_TRUE_PROPERTY(target, "noBrowserGlobals");
#else
READONLY_FALSE_PROPERTY(target, "noBrowserGlobals");
#endif // NODE_NO_BROWSER_GLOBALS

READONLY_PROPERTY(target,
"bits",
Number::New(env->isolate(), 8 * sizeof(intptr_t)));
Expand Down
5 changes: 0 additions & 5 deletions src/node_process_object.cc
Original file line number Diff line number Diff line change
Expand Up @@ -233,11 +233,6 @@ MaybeLocal<Object> CreateProcessObject(
READONLY_PROPERTY(process, "throwDeprecation", True(env->isolate()));
}

#ifdef NODE_NO_BROWSER_GLOBALS
// configure --no-browser-globals
READONLY_PROPERTY(process, "_noBrowserGlobals", True(env->isolate()));
#endif // NODE_NO_BROWSER_GLOBALS

// --prof-process
// TODO(addaleax): Remove this.
if (env->options()->prof_process) {
Expand Down