Skip to content

Commit

Permalink
workaround vm context issue in node-chakracore (#3106)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexlamsl authored Apr 26, 2018
1 parent 838f837 commit 70d4477
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 19 deletions.
4 changes: 2 additions & 2 deletions test/compress/collapse_vars.js
Original file line number Diff line number Diff line change
Expand Up @@ -3751,7 +3751,7 @@ issue_2506: {
function f0(bar) {
function f1(Infinity_2) {
function f13(NaN) {
if (false <= NaN & f0 >> 1 >= 0) {
if (false <= NaN & this >> 1 >= 0) {
c++;
}
}
Expand All @@ -3767,7 +3767,7 @@ issue_2506: {
function f0(bar) {
(function(Infinity_2) {
(function(NaN) {
if (false <= 0/0 & f0 >> 1 >= 0)
if (false <= 0/0 & this >> 1 >= 0)
c++;
})(0, c++);
})();
Expand Down
28 changes: 11 additions & 17 deletions test/sandbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 70d4477

Please sign in to comment.