diff options
author | Ruben Bridgewater <ruben@bridgewater.de> | 2019-07-05 17:24:28 +0200 |
---|---|---|
committer | Rich Trott <rtrott@gmail.com> | 2019-07-17 20:59:12 -0700 |
commit | 7e977d7cd41cd57ce6bc6b7b639e88377d725cf3 (patch) | |
tree | 09f91cc22d278a5a965586e7b008d4a3b10632fe /lib | |
parent | 6874aa1fb15e815bacf0b0f7e18a434d72de0b4d (diff) | |
download | android-node-v8-7e977d7cd41cd57ce6bc6b7b639e88377d725cf3.tar.gz android-node-v8-7e977d7cd41cd57ce6bc6b7b639e88377d725cf3.tar.bz2 android-node-v8-7e977d7cd41cd57ce6bc6b7b639e88377d725cf3.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 85692d718f..d1b9a91df6 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); |