Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 2fa959b

Browse filesBrowse files
indutnyevanlucas
authored andcommitted
node: --no-browser-globals configure flag
Introduce `--no-browser-globals` configure flag. With this flag set, following globals won't be exported: - `setTimeout`, `clearTimeout`, `setInterval`, `clearInterval`, `setImmediate`, `clearImmediate` - `console` These are provided by the DOM implementation in browser, so the `--no-browser-globals` flag may be helpful when embedding node.js within chromium/webkit. Inspired-By: atom/node@82e10ce PR-URL: #5853 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Rod Vagg <rod@vagg.org>
1 parent 8e8768e commit 2fa959b
Copy full SHA for 2fa959b

File tree

Expand file treeCollapse file tree

4 files changed

+21
-2
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

4 files changed

+21
-2
lines changed
Open diff view settings
Collapse file

‎configure‎

Copy file name to clipboardExpand all lines: configure
+8Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -373,6 +373,12 @@ parser.add_option('--enable-static',
373373
dest='enable_static',
374374
help='build as static library')
375375

376+
parser.add_option('--no-browser-globals',
377+
action='store_true',
378+
dest='no_browser_globals',
379+
help='do not export browser globals like setTimeout, console, etc. ' +
380+
'(This mode is not officially supported for regular applications)')
381+
376382
(options, args) = parser.parse_args()
377383

378384
# Expand ~ in the install prefix now, it gets written to multiple files.
@@ -765,6 +771,8 @@ def configure_node(o):
765771
if options.enable_static:
766772
o['variables']['node_target_type'] = 'static_library'
767773

774+
o['variables']['node_no_browser_globals'] = b(options.no_browser_globals)
775+
768776
if options.linked_module:
769777
o['variables']['library_files'] = options.linked_module
770778

Collapse file

‎lib/internal/bootstrap_node.js‎

Copy file name to clipboardExpand all lines: lib/internal/bootstrap_node.js
+4-2Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,10 @@
3030
setupProcessFatal();
3131

3232
setupGlobalVariables();
33-
setupGlobalTimeouts();
34-
setupGlobalConsole();
33+
if (!process._noBrowserGlobals) {
34+
setupGlobalTimeouts();
35+
setupGlobalConsole();
36+
}
3537

3638
const _process = NativeModule.require('internal/process');
3739

Collapse file

‎node.gyp‎

Copy file name to clipboardExpand all lines: node.gyp
+4Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
'node_use_lttng%': 'false',
66
'node_use_etw%': 'false',
77
'node_use_perfctr%': 'false',
8+
'node_no_browser_globals%': 'false',
89
'node_has_winsdk%': 'false',
910
'node_shared_zlib%': 'false',
1011
'node_shared_http_parser%': 'false',
@@ -366,6 +367,9 @@
366367
'tools/msvs/genfiles/node_perfctr_provider.rc',
367368
]
368369
} ],
370+
[ 'node_no_browser_globals=="true"', {
371+
'defines': [ 'NODE_NO_BROWSER_GLOBALS' ],
372+
} ],
369373
[ 'v8_postmortem_support=="true"', {
370374
'dependencies': [ 'deps/v8/tools/gyp/v8.gyp:postmortem-metadata' ],
371375
'conditions': [
Collapse file

‎src/node.cc‎

Copy file name to clipboardExpand all lines: src/node.cc
+5Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3059,6 +3059,11 @@ void SetupProcessObject(Environment* env,
30593059
READONLY_PROPERTY(process, "throwDeprecation", True(env->isolate()));
30603060
}
30613061

3062+
#ifdef NODE_NO_BROWSER_GLOBALS
3063+
// configure --no-browser-globals
3064+
READONLY_PROPERTY(process, "_noBrowserGlobals", True(env->isolate()));
3065+
#endif // NODE_NO_BROWSER_GLOBALS
3066+
30623067
// --prof-process
30633068
if (prof_process) {
30643069
READONLY_PROPERTY(process, "profProcess", True(env->isolate()));

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.