diff options
author | Ruben Bridgewater <ruben@bridgewater.de> | 2019-07-05 17:24:28 +0200 |
---|---|---|
committer | Michaƫl Zasso <targos@protonmail.com> | 2019-07-20 11:29:57 +0200 |
commit | d611f5ad3ed189db168820f4ff0fae3bc7afe7fa (patch) | |
tree | b1c0f26afb82404e552492ad9910aad966549330 /lib | |
parent | cbd586aa991b5c352d0d80c3d005de368017efa0 (diff) | |
download | android-node-v8-d611f5ad3ed189db168820f4ff0fae3bc7afe7fa.tar.gz android-node-v8-d611f5ad3ed189db168820f4ff0fae3bc7afe7fa.tar.bz2 android-node-v8-d611f5ad3ed189db168820f4ff0fae3bc7afe7fa.zip |
repl: fix some repl context issues
This partially fixes contexts like `{} instanceof Object === false`
in the REPL. This does not fix all cases, since it's something
fundamental from the REPL's design that things like these can happen.
Refs: https://github.com/nodejs/node/issues/27859
PR-URL: https://github.com/nodejs/node/pull/28561
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Anto Aravinth <anto.aravinth.cse@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/repl.js | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/lib/repl.js b/lib/repl.js index ed0c9fd420..2f82c2ca49 100644 --- a/lib/repl.js +++ b/lib/repl.js @@ -875,8 +875,11 @@ REPLServer.prototype.createContext = function() { context = vm.createContext(); }); for (const name of Object.getOwnPropertyNames(global)) { - Object.defineProperty(context, name, - Object.getOwnPropertyDescriptor(global, name)); + // Only set properties on the context that do not exist as primordial. + if (!(name in primordials)) { + Object.defineProperty(context, name, + Object.getOwnPropertyDescriptor(global, name)); + } } context.global = context; const _console = new Console(this.outputStream); |