Skip to content
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
9 changes: 9 additions & 0 deletions src/env-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -892,6 +892,15 @@ inline bool Environment::no_global_search_paths() const {
!options_->global_search_paths;
}

inline bool Environment::no_browser_globals() const {
// configure --no-browser-globals
#ifdef NODE_NO_BROWSER_GLOBALS
return true;
#else
return flags_ & EnvironmentFlags::kNoBrowserGlobals;
#endif
}

bool Environment::filehandle_close_warning() const {
return emit_filehandle_warning_;
}
Expand Down
1 change: 1 addition & 0 deletions src/env.h
Original file line number Diff line number Diff line change
Expand Up @@ -1204,6 +1204,7 @@ class Environment : public MemoryRetainer {
inline bool tracks_unmanaged_fds() const;
inline bool hide_console_windows() const;
inline bool no_global_search_paths() const;
inline bool no_browser_globals() const;
inline uint64_t thread_id() const;
inline worker::Worker* worker_context() const;
Environment* worker_parent_env() const;
Expand Down
4 changes: 3 additions & 1 deletion src/node.h
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,9 @@ enum Flags : uint64_t {
// $HOME/.node_modules and $NODE_PATH. This is used by standalone apps that
// do not expect to have their behaviors changed because of globally
// installed modules.
kNoGlobalSearchPaths = 1 << 7
kNoGlobalSearchPaths = 1 << 7,
// Do not export browser globals like setTimeout, console, etc.
kNoBrowserGlobals = 1 << 8,
};
} // namespace EnvironmentFlags

Expand Down
10 changes: 4 additions & 6 deletions src/node_config.cc
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,10 @@ 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
if (env->no_browser_globals())
READONLY_TRUE_PROPERTY(target, "noBrowserGlobals");
else
READONLY_FALSE_PROPERTY(target, "noBrowserGlobals");

READONLY_PROPERTY(target,
"bits",
Expand Down