workaround vm context issue in node-chakracore (#3106)

This commit is contained in:
Alex Lam S.L
2018-04-27 07:40:34 +08:00
committed by GitHub
parent 838f837379
commit 70d4477e05
2 changed files with 13 additions and 19 deletions

View File

@@ -3751,7 +3751,7 @@ issue_2506: {
function f0(bar) { function f0(bar) {
function f1(Infinity_2) { function f1(Infinity_2) {
function f13(NaN) { function f13(NaN) {
if (false <= NaN & f0 >> 1 >= 0) { if (false <= NaN & this >> 1 >= 0) {
c++; c++;
} }
} }
@@ -3767,7 +3767,7 @@ issue_2506: {
function f0(bar) { function f0(bar) {
(function(Infinity_2) { (function(Infinity_2) {
(function(NaN) { (function(NaN) {
if (false <= 0/0 & f0 >> 1 >= 0) if (false <= 0/0 & this >> 1 >= 0)
c++; c++;
})(0, c++); })(0, c++);
})(); })();

View File

@@ -2,24 +2,18 @@ var semver = require("semver");
var vm = require("vm"); var vm = require("vm");
function createContext() { function createContext() {
var context = Object.create(null); return vm.createContext(Object.defineProperty({}, "console", {
Object.defineProperty(context, "console", { value: {
value: function() { log: function(msg) {
var con = Object.create(null); if (arguments.length == 1 && typeof msg == "string") {
Object.defineProperty(con, "log", { return console.log("%s", msg);
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 console.log.apply(console, [].map.call(arguments, function(arg) {
return con; return safe_log(arg, 3);
}() }));
}); }
return vm.createContext(context); }
}));
} }
function safe_log(arg, level) { function safe_log(arg, level) {