diff options
author | Alex Lam S.L <alexlamsl@gmail.com> | 2018-04-27 07:40:34 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-04-27 07:40:34 +0800 |
commit | 70d4477e0532f79b6d9cacb610cce6bb1d0819a0 (patch) | |
tree | 715039c0d20c1cbdbc3cf9179334f3c92d91d1d5 /test/sandbox.js | |
parent | 838f83737904f3067b2e0585034b2f71731d901d (diff) | |
download | tracifyjs-70d4477e0532f79b6d9cacb610cce6bb1d0819a0.tar.gz tracifyjs-70d4477e0532f79b6d9cacb610cce6bb1d0819a0.zip |
workaround `vm` context issue in `node-chakracore` (#3106)
Diffstat (limited to 'test/sandbox.js')
-rw-r--r-- | test/sandbox.js | 28 |
1 files changed, 11 insertions, 17 deletions
diff --git a/test/sandbox.js b/test/sandbox.js index 426ac1fc..ecf95d31 100644 --- a/test/sandbox.js +++ b/test/sandbox.js @@ -2,24 +2,18 @@ var semver = require("semver"); var vm = require("vm"); function createContext() { - var context = Object.create(null); - Object.defineProperty(context, "console", { - value: function() { - var con = Object.create(null); - Object.defineProperty(con, "log", { - value: function(msg) { - if (arguments.length == 1 && typeof msg == "string") { - return console.log("%s", msg); - } - return console.log.apply(console, [].map.call(arguments, function(arg) { - return safe_log(arg, 3); - })); + return vm.createContext(Object.defineProperty({}, "console", { + value: { + log: function(msg) { + if (arguments.length == 1 && typeof msg == "string") { + return console.log("%s", msg); } - }); - return con; - }() - }); - return vm.createContext(context); + return console.log.apply(console, [].map.call(arguments, function(arg) { + return safe_log(arg, 3); + })); + } + } + })); } function safe_log(arg, level) { |