improve global context enumeration under sandbox (#4812)

fixes #4811
This commit is contained in:
Alex Lam S.L
2021-03-22 14:43:33 +00:00
committed by GitHub
parent 9c01511f84
commit 51bdb7281b
3 changed files with 57 additions and 4 deletions

View File

@@ -361,4 +361,22 @@ describe("test/reduce.js", function() {
if (result.error) throw result.error;
assert.strictEqual(result.code, read("test/input/reduce/destructured_catch.reduced.js"));
});
it("Should not enumerate `toString` over global context", function() {
if (semver.satisfies(process.version, "<8")) return;
var code = [
"(async function() {});",
"for (var k in this);",
"console.log(k);",
].join("\n");
var result = reduce_test(code, {
mangle: false,
});
if (result.error) throw result.error;
assert.strictEqual(result.code, [
"// Can't reproduce test failure",
"// minify options: {",
'// "mangle": false',
"// }",
].join("\n"));
});
});