aboutsummaryrefslogtreecommitdiff
path: root/test/mocha/minify.js
diff options
context:
space:
mode:
authorAlex Lam S.L <alexlamsl@gmail.com>2017-06-08 03:27:03 +0800
committerGitHub <noreply@github.com>2017-06-08 03:27:03 +0800
commit9c306406f14087ad0a62141bf7bb9e12afcc1a75 (patch)
tree282cf98cc57a3aa0982f6adcddfaffbe2fefbb84 /test/mocha/minify.js
parent9db0695b10799349c005fc14ab1268c2478c25fd (diff)
downloadtracifyjs-9c306406f14087ad0a62141bf7bb9e12afcc1a75.tar.gz
tracifyjs-9c306406f14087ad0a62141bf7bb9e12afcc1a75.zip
fix iteration over object with inherited properties (#2068)
fixes #2055
Diffstat (limited to 'test/mocha/minify.js')
-rw-r--r--test/mocha/minify.js19
1 files changed, 19 insertions, 0 deletions
diff --git a/test/mocha/minify.js b/test/mocha/minify.js
index 519b725c..638e79f7 100644
--- a/test/mocha/minify.js
+++ b/test/mocha/minify.js
@@ -13,6 +13,13 @@ describe("minify", function() {
assert.strictEqual(result.code, 'function foo(n){return n?3:7}');
});
+ it("Should skip inherited keys from `files`", function() {
+ var files = Object.create({ skip: this });
+ files[0] = "alert(1 + 1)";
+ var result = Uglify.minify(files);
+ assert.strictEqual(result.code, "alert(2);");
+ });
+
describe("keep_quoted_props", function() {
it("Should preserve quotes in object literals", function() {
var js = 'var foo = {"x": 1, y: 2, \'z\': 3};';
@@ -207,5 +214,17 @@ describe("minify", function() {
assert.ok(err instanceof Error);
assert.strictEqual(err.stack.split(/\n/)[0], "Error: Can't handle expression: debugger");
});
+ it("should skip inherited properties", function() {
+ var foo = Object.create({ skip: this });
+ foo.bar = 42;
+ var result = Uglify.minify("alert(FOO);", {
+ compress: {
+ global_defs: {
+ FOO: foo
+ }
+ }
+ });
+ assert.strictEqual(result.code, "alert({bar:42});");
+ });
});
});