Compare commits
34 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
429d2b56b7 | ||
|
|
2ea96549c5 | ||
|
|
fba008e298 | ||
|
|
c37a8e927e | ||
|
|
413bbe0480 | ||
|
|
34075fc4c4 | ||
|
|
e5436ca566 | ||
|
|
cfde686eab | ||
|
|
a206964c0a | ||
|
|
c56d89f804 | ||
|
|
c215706350 | ||
|
|
d3b93ec682 | ||
|
|
6fe20dbe33 | ||
|
|
7ccdf3337b | ||
|
|
dafed54764 | ||
|
|
a84beafd1b | ||
|
|
f01cc1e413 | ||
|
|
338dd144b8 | ||
|
|
c719552317 | ||
|
|
855964a87a | ||
|
|
a438e2fca9 | ||
|
|
00833e893a | ||
|
|
f1a77e4fc0 | ||
|
|
b55a2fd531 | ||
|
|
e8a2c0b5bf | ||
|
|
21cd7e3f57 | ||
|
|
5172ba5f2a | ||
|
|
a57b069409 | ||
|
|
4454656c3b | ||
|
|
fa43768ce0 | ||
|
|
a74e600fa0 | ||
|
|
4b21526310 | ||
|
|
a7a7b1daed | ||
|
|
7436977aa5 |
@@ -636,6 +636,9 @@ If you're using the `X-SourceMap` header instead, you can just omit `sourceMap.u
|
|||||||
- `expression` (default: `false`) -- Pass `true` to preserve completion values
|
- `expression` (default: `false`) -- Pass `true` to preserve completion values
|
||||||
from terminal statements without `return`, e.g. in bookmarklets.
|
from terminal statements without `return`, e.g. in bookmarklets.
|
||||||
|
|
||||||
|
- `functions` (default: `true`) -- convert declarations from `var`to `function`
|
||||||
|
whenever possible.
|
||||||
|
|
||||||
- `global_defs` (default: `{}`) -- see [conditional compilation](#conditional-compilation)
|
- `global_defs` (default: `{}`) -- see [conditional compilation](#conditional-compilation)
|
||||||
|
|
||||||
- `hoist_funs` (default: `false`) -- hoist function declarations
|
- `hoist_funs` (default: `false`) -- hoist function declarations
|
||||||
|
|||||||
35
bin/uglifyjs
35
bin/uglifyjs
@@ -63,7 +63,7 @@ if (program.configFile) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!program.output && program.sourceMap && program.sourceMap.url != "inline") {
|
if (!program.output && program.sourceMap && program.sourceMap.url != "inline") {
|
||||||
fatal("ERROR: cannot write source map to STDOUT");
|
fatal("cannot write source map to STDOUT");
|
||||||
}
|
}
|
||||||
[
|
[
|
||||||
"compress",
|
"compress",
|
||||||
@@ -78,6 +78,15 @@ if (!program.output && program.sourceMap && program.sourceMap.url != "inline") {
|
|||||||
options[name] = program[name];
|
options[name] = program[name];
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
if (program.verbose) {
|
||||||
|
options.warnings = "verbose";
|
||||||
|
} else if (program.warn) {
|
||||||
|
options.warnings = true;
|
||||||
|
}
|
||||||
|
if (options.warnings) {
|
||||||
|
UglifyJS.AST_Node.log_function(print_error, options.warnings == "verbose");
|
||||||
|
delete options.warnings;
|
||||||
|
}
|
||||||
if (program.beautify) {
|
if (program.beautify) {
|
||||||
options.output = typeof program.beautify == "object" ? program.beautify : {};
|
options.output = typeof program.beautify == "object" ? program.beautify : {};
|
||||||
if (!("beautify" in options.output)) {
|
if (!("beautify" in options.output)) {
|
||||||
@@ -124,7 +133,7 @@ if (program.parse) {
|
|||||||
if (!program.parse.acorn && !program.parse.spidermonkey) {
|
if (!program.parse.acorn && !program.parse.spidermonkey) {
|
||||||
options.parse = program.parse;
|
options.parse = program.parse;
|
||||||
} else if (program.sourceMap && program.sourceMap.content == "inline") {
|
} else if (program.sourceMap && program.sourceMap.content == "inline") {
|
||||||
fatal("ERROR: inline source map only works with built-in parser");
|
fatal("inline source map only works with built-in parser");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (~program.rawArgs.indexOf("--rename")) {
|
if (~program.rawArgs.indexOf("--rename")) {
|
||||||
@@ -144,15 +153,8 @@ if (typeof program.sourceMap == "object" && "base" in program.sourceMap) {
|
|||||||
};
|
};
|
||||||
}();
|
}();
|
||||||
}
|
}
|
||||||
if (program.verbose) {
|
|
||||||
options.warnings = "verbose";
|
|
||||||
} else if (program.warn) {
|
|
||||||
options.warnings = true;
|
|
||||||
}
|
|
||||||
if (program.self) {
|
if (program.self) {
|
||||||
if (program.args.length) {
|
if (program.args.length) UglifyJS.AST_Node.warn("Ignoring input files since --self was passed");
|
||||||
print_error("WARN: Ignoring input files since --self was passed");
|
|
||||||
}
|
|
||||||
if (!options.wrap) options.wrap = "UglifyJS";
|
if (!options.wrap) options.wrap = "UglifyJS";
|
||||||
simple_glob(UglifyJS.FILES).forEach(function(name) {
|
simple_glob(UglifyJS.FILES).forEach(function(name) {
|
||||||
files[convert_path(name)] = read_file(name);
|
files[convert_path(name)] = read_file(name);
|
||||||
@@ -180,12 +182,9 @@ function convert_ast(fn) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function run() {
|
function run() {
|
||||||
UglifyJS.AST_Node.warn_function = function(msg) {
|
|
||||||
print_error("WARN: " + msg);
|
|
||||||
};
|
|
||||||
var content = program.sourceMap && program.sourceMap.content;
|
var content = program.sourceMap && program.sourceMap.content;
|
||||||
if (content && content != "inline") {
|
if (content && content != "inline") {
|
||||||
print_error("INFO: Using input source map: " + content);
|
UglifyJS.AST_Node.info("Using input source map: " + content);
|
||||||
options.sourceMap.content = read_file(content, content);
|
options.sourceMap.content = read_file(content, content);
|
||||||
}
|
}
|
||||||
if (program.timings) options.timings = true;
|
if (program.timings) options.timings = true;
|
||||||
@@ -293,7 +292,11 @@ function run() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function fatal(message) {
|
function fatal(message) {
|
||||||
if (message instanceof Error) message = message.stack.replace(/^\S*?Error:/, "ERROR:")
|
if (message instanceof Error) {
|
||||||
|
message = message.stack.replace(/^\S*?Error:/, "ERROR:")
|
||||||
|
} else {
|
||||||
|
message = "ERROR: " + message;
|
||||||
|
}
|
||||||
print_error(message);
|
print_error(message);
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
@@ -372,7 +375,7 @@ function parse_js(flag) {
|
|||||||
}));
|
}));
|
||||||
} catch (ex) {
|
} catch (ex) {
|
||||||
if (flag) {
|
if (flag) {
|
||||||
fatal("Error parsing arguments for '" + flag + "': " + value);
|
fatal("cannot parse arguments for '" + flag + "': " + value);
|
||||||
} else {
|
} else {
|
||||||
options[value] = null;
|
options[value] = null;
|
||||||
}
|
}
|
||||||
|
|||||||
22
lib/ast.js
22
lib/ast.js
@@ -118,9 +118,25 @@ var AST_Node = DEFNODE("Node", "start end", {
|
|||||||
}
|
}
|
||||||
}, null);
|
}, null);
|
||||||
|
|
||||||
AST_Node.warn = function(txt, props) {
|
(AST_Node.log_function = function(fn, verbose) {
|
||||||
if (AST_Node.warn_function) AST_Node.warn_function(string_template(txt, props));
|
var printed = Object.create(null);
|
||||||
|
if (fn) {
|
||||||
|
AST_Node.info = verbose ? function(text, props) {
|
||||||
|
log("INFO: " + string_template(text, props));
|
||||||
|
} : noop;
|
||||||
|
AST_Node.warn = function(text, props) {
|
||||||
|
log("WARN: " + string_template(text, props));
|
||||||
};
|
};
|
||||||
|
} else {
|
||||||
|
AST_Node.info = AST_Node.warn = noop;
|
||||||
|
}
|
||||||
|
|
||||||
|
function log(msg) {
|
||||||
|
if (printed[msg]) return;
|
||||||
|
printed[msg] = true;
|
||||||
|
fn(msg);
|
||||||
|
}
|
||||||
|
})();
|
||||||
|
|
||||||
/* -----[ statements ]----- */
|
/* -----[ statements ]----- */
|
||||||
|
|
||||||
@@ -773,7 +789,7 @@ var AST_Label = DEFNODE("Label", "references", {
|
|||||||
}
|
}
|
||||||
}, AST_Symbol);
|
}, AST_Symbol);
|
||||||
|
|
||||||
var AST_SymbolRef = DEFNODE("SymbolRef", null, {
|
var AST_SymbolRef = DEFNODE("SymbolRef", "fixed", {
|
||||||
$documentation: "Reference to some symbol (not definition/declaration)",
|
$documentation: "Reference to some symbol (not definition/declaration)",
|
||||||
}, AST_Symbol);
|
}, AST_Symbol);
|
||||||
|
|
||||||
|
|||||||
591
lib/compress.js
591
lib/compress.js
File diff suppressed because it is too large
Load Diff
@@ -51,7 +51,6 @@ function to_json(cache) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function minify(files, options) {
|
function minify(files, options) {
|
||||||
var warn_function = AST_Node.warn_function;
|
|
||||||
try {
|
try {
|
||||||
options = defaults(options, {
|
options = defaults(options, {
|
||||||
compress: {},
|
compress: {},
|
||||||
@@ -78,7 +77,6 @@ function minify(files, options) {
|
|||||||
set_shorthand("ie8", options, [ "compress", "mangle", "output" ]);
|
set_shorthand("ie8", options, [ "compress", "mangle", "output" ]);
|
||||||
set_shorthand("keep_fnames", options, [ "compress", "mangle" ]);
|
set_shorthand("keep_fnames", options, [ "compress", "mangle" ]);
|
||||||
set_shorthand("toplevel", options, [ "compress", "mangle" ]);
|
set_shorthand("toplevel", options, [ "compress", "mangle" ]);
|
||||||
set_shorthand("warnings", options, [ "compress" ]);
|
|
||||||
var quoted_props;
|
var quoted_props;
|
||||||
if (options.mangle) {
|
if (options.mangle) {
|
||||||
options.mangle = defaults(options.mangle, {
|
options.mangle = defaults(options.mangle, {
|
||||||
@@ -116,11 +114,9 @@ function minify(files, options) {
|
|||||||
}, true);
|
}, true);
|
||||||
}
|
}
|
||||||
var warnings = [];
|
var warnings = [];
|
||||||
if (options.warnings && !AST_Node.warn_function) {
|
if (options.warnings) AST_Node.log_function(function(warning) {
|
||||||
AST_Node.warn_function = function(warning) {
|
|
||||||
warnings.push(warning);
|
warnings.push(warning);
|
||||||
};
|
}, options.warnings == "verbose");
|
||||||
}
|
|
||||||
if (timings) timings.parse = Date.now();
|
if (timings) timings.parse = Date.now();
|
||||||
var source_maps, toplevel;
|
var source_maps, toplevel;
|
||||||
if (files instanceof AST_Toplevel) {
|
if (files instanceof AST_Toplevel) {
|
||||||
@@ -240,7 +236,5 @@ function minify(files, options) {
|
|||||||
return result;
|
return result;
|
||||||
} catch (ex) {
|
} catch (ex) {
|
||||||
return { error: ex };
|
return { error: ex };
|
||||||
} finally {
|
|
||||||
AST_Node.warn_function = warn_function;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -123,7 +123,7 @@ function OutputStream(options) {
|
|||||||
});
|
});
|
||||||
} : function(str) {
|
} : function(str) {
|
||||||
var s = "";
|
var s = "";
|
||||||
for (var i = 0, len = str.length; i < len; i++) {
|
for (var i = 0; i < str.length; i++) {
|
||||||
if (is_surrogate_pair_head(str[i]) && !is_surrogate_pair_tail(str[i + 1])
|
if (is_surrogate_pair_head(str[i]) && !is_surrogate_pair_tail(str[i + 1])
|
||||||
|| is_surrogate_pair_tail(str[i]) && !is_surrogate_pair_head(str[i - 1])) {
|
|| is_surrogate_pair_tail(str[i]) && !is_surrogate_pair_head(str[i - 1])) {
|
||||||
s += "\\u" + str.charCodeAt(i).toString(16);
|
s += "\\u" + str.charCodeAt(i).toString(16);
|
||||||
@@ -217,23 +217,12 @@ function OutputStream(options) {
|
|||||||
|
|
||||||
var flush_mappings = mappings ? function() {
|
var flush_mappings = mappings ? function() {
|
||||||
mappings.forEach(function(mapping) {
|
mappings.forEach(function(mapping) {
|
||||||
try {
|
|
||||||
options.source_map.add(
|
options.source_map.add(
|
||||||
mapping.token.file,
|
mapping.token.file,
|
||||||
mapping.line, mapping.col,
|
mapping.line, mapping.col,
|
||||||
mapping.token.line, mapping.token.col,
|
mapping.token.line, mapping.token.col,
|
||||||
!mapping.name && mapping.token.type == "name" ? mapping.token.value : mapping.name
|
!mapping.name && mapping.token.type == "name" ? mapping.token.value : mapping.name
|
||||||
);
|
);
|
||||||
} catch(ex) {
|
|
||||||
AST_Node.warn("Couldn't figure out mapping for {file}:{line},{col} → {cline},{ccol} [{name}]", {
|
|
||||||
file: mapping.token.file,
|
|
||||||
line: mapping.token.line,
|
|
||||||
col: mapping.token.col,
|
|
||||||
cline: mapping.line,
|
|
||||||
ccol: mapping.col,
|
|
||||||
name: mapping.name || ""
|
|
||||||
})
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
mappings = [];
|
mappings = [];
|
||||||
} : noop;
|
} : noop;
|
||||||
|
|||||||
10
lib/parse.js
10
lib/parse.js
@@ -164,10 +164,6 @@ function is_unicode_connector_punctuation(ch) {
|
|||||||
return UNICODE.connector_punctuation.test(ch);
|
return UNICODE.connector_punctuation.test(ch);
|
||||||
}
|
}
|
||||||
|
|
||||||
function is_identifier(name) {
|
|
||||||
return !RESERVED_WORDS[name] && /^[a-z_$][a-z0-9_$]*$/i.test(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
function is_identifier_start(code) {
|
function is_identifier_start(code) {
|
||||||
return code == 36 || code == 95 || is_letter(code);
|
return code == 36 || code == 95 || is_letter(code);
|
||||||
}
|
}
|
||||||
@@ -272,10 +268,8 @@ function tokenizer($TEXT, filename, html5_comments, shebang) {
|
|||||||
|
|
||||||
function find_eol() {
|
function find_eol() {
|
||||||
var text = S.text;
|
var text = S.text;
|
||||||
for (var i = S.pos, n = S.text.length; i < n; ++i) {
|
for (var i = S.pos; i < S.text.length; ++i) {
|
||||||
var ch = text[i];
|
if (NEWLINE_CHARS[text[i]]) return i;
|
||||||
if (NEWLINE_CHARS[ch])
|
|
||||||
return i;
|
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|||||||
28
lib/scope.js
28
lib/scope.js
@@ -61,8 +61,6 @@ SymbolDef.next_id = 1;
|
|||||||
|
|
||||||
SymbolDef.prototype = {
|
SymbolDef.prototype = {
|
||||||
unmangleable: function(options) {
|
unmangleable: function(options) {
|
||||||
if (!options) options = {};
|
|
||||||
|
|
||||||
return this.global && !options.toplevel
|
return this.global && !options.toplevel
|
||||||
|| this.undeclared
|
|| this.undeclared
|
||||||
|| !options.eval && this.scope.pinned()
|
|| !options.eval && this.scope.pinned()
|
||||||
@@ -198,24 +196,20 @@ AST_Toplevel.DEFMETHOD("figure_out_scope", function(options) {
|
|||||||
}
|
}
|
||||||
if (node instanceof AST_SymbolLambda) {
|
if (node instanceof AST_SymbolLambda) {
|
||||||
var def = node.thedef;
|
var def = node.thedef;
|
||||||
if (def.orig.length == 1) {
|
|
||||||
redefine(node, node.scope.parent_scope);
|
redefine(node, node.scope.parent_scope);
|
||||||
node.thedef.init = def.init;
|
node.thedef.init = def.init;
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
|
|
||||||
function redefine(node, scope) {
|
function redefine(node, scope) {
|
||||||
var name = node.name;
|
var name = node.name;
|
||||||
var refs = node.thedef.references;
|
var old_def = node.thedef;
|
||||||
var def = scope.find_variable(name) || self.globals.get(name) || scope.def_variable(node);
|
var new_def = scope.find_variable(name) || self.globals.get(name) || scope.def_variable(node);
|
||||||
refs.forEach(function(ref) {
|
old_def.orig.concat(old_def.references).forEach(function(node) {
|
||||||
ref.thedef = def;
|
node.thedef = new_def;
|
||||||
ref.reference(options);
|
|
||||||
});
|
|
||||||
node.thedef = def;
|
|
||||||
node.reference(options);
|
node.reference(options);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -300,7 +294,7 @@ AST_Scope.DEFMETHOD("def_variable", function(symbol, init) {
|
|||||||
|
|
||||||
AST_Lambda.DEFMETHOD("resolve", return_this);
|
AST_Lambda.DEFMETHOD("resolve", return_this);
|
||||||
AST_Scope.DEFMETHOD("resolve", function() {
|
AST_Scope.DEFMETHOD("resolve", function() {
|
||||||
return this.parent_scope;
|
return this.parent_scope.resolve();
|
||||||
});
|
});
|
||||||
AST_Toplevel.DEFMETHOD("resolve", return_this);
|
AST_Toplevel.DEFMETHOD("resolve", return_this);
|
||||||
|
|
||||||
@@ -337,7 +331,7 @@ function next_mangled_name(scope, options, def) {
|
|||||||
} while (scope = scope.parent_scope);
|
} while (scope = scope.parent_scope);
|
||||||
});
|
});
|
||||||
var name;
|
var name;
|
||||||
for (var i = 0, len = holes.length; i < len; i++) {
|
for (var i = 0; i < holes.length; i++) {
|
||||||
name = base54(holes[i]);
|
name = base54(holes[i]);
|
||||||
if (names[name]) continue;
|
if (names[name]) continue;
|
||||||
holes.splice(i, 1);
|
holes.splice(i, 1);
|
||||||
@@ -346,7 +340,7 @@ function next_mangled_name(scope, options, def) {
|
|||||||
}
|
}
|
||||||
while (true) {
|
while (true) {
|
||||||
name = base54(++scope.cname);
|
name = base54(++scope.cname);
|
||||||
if (in_use[name] || !is_identifier(name) || options.reserved.has[name]) continue;
|
if (in_use[name] || RESERVED_WORDS[name] || options.reserved.has[name]) continue;
|
||||||
if (!names[name]) break;
|
if (!names[name]) break;
|
||||||
holes.push(scope.cname);
|
holes.push(scope.cname);
|
||||||
}
|
}
|
||||||
@@ -426,7 +420,7 @@ AST_Toplevel.DEFMETHOD("mangle_names", function(options) {
|
|||||||
var name;
|
var name;
|
||||||
do {
|
do {
|
||||||
name = base54(++lname);
|
name = base54(++lname);
|
||||||
} while (!is_identifier(name));
|
} while (RESERVED_WORDS[name]);
|
||||||
node.mangled_name = name;
|
node.mangled_name = name;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -497,7 +491,7 @@ AST_Toplevel.DEFMETHOD("expand_names", function(options) {
|
|||||||
var name;
|
var name;
|
||||||
do {
|
do {
|
||||||
name = base54(cname++);
|
name = base54(cname++);
|
||||||
} while (avoid[name] || !is_identifier(name));
|
} while (avoid[name] || RESERVED_WORDS[name]);
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -559,7 +553,7 @@ var base54 = (function() {
|
|||||||
var freq = Object.create(null);
|
var freq = Object.create(null);
|
||||||
function init(chars) {
|
function init(chars) {
|
||||||
var array = [];
|
var array = [];
|
||||||
for (var i = 0, len = chars.length; i < len; i++) {
|
for (var i = 0; i < chars.length; i++) {
|
||||||
var ch = chars[i];
|
var ch = chars[i];
|
||||||
array.push(ch);
|
array.push(ch);
|
||||||
freq[ch] = -1e-2 * i;
|
freq[ch] = -1e-2 * i;
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
"description": "JavaScript parser, mangler/compressor and beautifier toolkit",
|
"description": "JavaScript parser, mangler/compressor and beautifier toolkit",
|
||||||
"author": "Mihai Bazon <mihai.bazon@gmail.com> (http://lisperator.net/)",
|
"author": "Mihai Bazon <mihai.bazon@gmail.com> (http://lisperator.net/)",
|
||||||
"license": "BSD-2-Clause",
|
"license": "BSD-2-Clause",
|
||||||
"version": "3.5.1",
|
"version": "3.5.10",
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=0.8.0"
|
"node": ">=0.8.0"
|
||||||
},
|
},
|
||||||
@@ -23,12 +23,12 @@
|
|||||||
"LICENSE"
|
"LICENSE"
|
||||||
],
|
],
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"commander": "~2.19.0",
|
"commander": "~2.20.0",
|
||||||
"source-map": "~0.6.1"
|
"source-map": "~0.6.1"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"acorn": "~6.1.1",
|
"acorn": "~6.1.1",
|
||||||
"semver": "~5.6.0"
|
"semver": "~6.0.0"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "node test/run-tests.js"
|
"test": "node test/run-tests.js"
|
||||||
|
|||||||
@@ -289,3 +289,25 @@ increment_decrement_2: {
|
|||||||
}
|
}
|
||||||
expect_stdout: "42"
|
expect_stdout: "42"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
issue_3375: {
|
||||||
|
options = {
|
||||||
|
assignments: true,
|
||||||
|
reduce_vars: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
console.log(typeof function(b) {
|
||||||
|
var a = b += 1;
|
||||||
|
--b;
|
||||||
|
return a;
|
||||||
|
}("object"));
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
console.log(typeof function(b) {
|
||||||
|
var a = b += 1;
|
||||||
|
--b;
|
||||||
|
return a;
|
||||||
|
}("object"));
|
||||||
|
}
|
||||||
|
expect_stdout: "string"
|
||||||
|
}
|
||||||
|
|||||||
@@ -6157,3 +6157,24 @@ sub_property: {
|
|||||||
}
|
}
|
||||||
expect_stdout: "PASS"
|
expect_stdout: "PASS"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
assign_undeclared: {
|
||||||
|
options = {
|
||||||
|
collapse_vars: true,
|
||||||
|
toplevel: true,
|
||||||
|
unused: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
var A = (console.log(42), function() {});
|
||||||
|
B = new A();
|
||||||
|
console.log(typeof B);
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
B = new (console.log(42), function() {})();
|
||||||
|
console.log(typeof B);
|
||||||
|
}
|
||||||
|
expect_stdout: [
|
||||||
|
"42",
|
||||||
|
"object",
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|||||||
@@ -345,3 +345,38 @@ is_boolean_var: {
|
|||||||
}
|
}
|
||||||
expect_stdout: "1"
|
expect_stdout: "1"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
is_defined: {
|
||||||
|
options = {
|
||||||
|
comparisons: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
console.log(function a() {
|
||||||
|
return void 0 === a;
|
||||||
|
}());
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
console.log(function a() {
|
||||||
|
return a, false;
|
||||||
|
}());
|
||||||
|
}
|
||||||
|
expect_stdout: "false"
|
||||||
|
expect_warnings: [
|
||||||
|
"WARN: Expression always defined [test/compress/comparisons.js:2,19]",
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
unsafe_indexOf: {
|
||||||
|
options = {
|
||||||
|
booleans: true,
|
||||||
|
comparisons: true,
|
||||||
|
unsafe: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
if (Object.keys({ foo: 42 }).indexOf("foo") >= 0) console.log("PASS");
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
if (~Object.keys({ foo: 42 }).indexOf("foo")) console.log("PASS");
|
||||||
|
}
|
||||||
|
expect_stdout: "PASS"
|
||||||
|
}
|
||||||
|
|||||||
@@ -1416,3 +1416,58 @@ issue_3271: {
|
|||||||
}
|
}
|
||||||
expect_stdout: "1 1"
|
expect_stdout: "1 1"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
iife_condition: {
|
||||||
|
options = {
|
||||||
|
conditionals: true,
|
||||||
|
side_effects: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
if (function() {
|
||||||
|
return console;
|
||||||
|
}())
|
||||||
|
console.log("PASS");
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
!function() {
|
||||||
|
return console;
|
||||||
|
}() || console.log("PASS");
|
||||||
|
}
|
||||||
|
expect_stdout: "PASS"
|
||||||
|
}
|
||||||
|
|
||||||
|
angularjs_chain: {
|
||||||
|
options = {
|
||||||
|
conditionals: true,
|
||||||
|
passes: 2,
|
||||||
|
side_effects: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
function nonComputedMember(left, right, context, create) {
|
||||||
|
var lhs = left();
|
||||||
|
if (create && create !== 1) {
|
||||||
|
if (lhs && lhs[right] == null) {
|
||||||
|
lhs[right] = {};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
var value = lhs != null ? lhs[right] : undefined;
|
||||||
|
if (context) {
|
||||||
|
return { context: lhs, name: right, value: value };
|
||||||
|
} else {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
function nonComputedMember(left, right, context, create) {
|
||||||
|
var lhs = left();
|
||||||
|
create && 1 !== create && lhs && null == lhs[right] && (lhs[right] = {});
|
||||||
|
var value = null != lhs ? lhs[right] : void 0;
|
||||||
|
return context ? {
|
||||||
|
context: lhs,
|
||||||
|
name: right,
|
||||||
|
value: value
|
||||||
|
} : value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -942,3 +942,21 @@ issue_2929: {
|
|||||||
}
|
}
|
||||||
expect_stdout: "PASS"
|
expect_stdout: "PASS"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unsafe_string_replace: {
|
||||||
|
options = {
|
||||||
|
side_effects: true,
|
||||||
|
unsafe: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
"foo".replace("f", function() {
|
||||||
|
console.log("PASS");
|
||||||
|
});
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
"foo".replace("f", function() {
|
||||||
|
console.log("PASS");
|
||||||
|
});
|
||||||
|
}
|
||||||
|
expect_stdout: "PASS"
|
||||||
|
}
|
||||||
|
|||||||
@@ -2005,3 +2005,24 @@ issue_3233: {
|
|||||||
}
|
}
|
||||||
expect_stdout: "PASS"
|
expect_stdout: "PASS"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
issue_3375: {
|
||||||
|
options = {
|
||||||
|
reduce_vars: true,
|
||||||
|
toplevel: true,
|
||||||
|
unused: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
var b = 1;
|
||||||
|
var a = c = [], c = --b + ("function" == typeof f && f());
|
||||||
|
var a = c && c[a];
|
||||||
|
console.log(a, b);
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
var b = 1;
|
||||||
|
var a = [], c = --b + ("function" == typeof f && f());
|
||||||
|
a = c && c[a];
|
||||||
|
console.log(a, b);
|
||||||
|
}
|
||||||
|
expect_stdout: "0 0"
|
||||||
|
}
|
||||||
|
|||||||
@@ -246,7 +246,7 @@ unsafe_constant: {
|
|||||||
}
|
}
|
||||||
expect: {
|
expect: {
|
||||||
console.log(
|
console.log(
|
||||||
true.a,
|
void 0,
|
||||||
false.a,
|
false.a,
|
||||||
null.a,
|
null.a,
|
||||||
(void 0).a
|
(void 0).a
|
||||||
@@ -278,7 +278,7 @@ unsafe_object: {
|
|||||||
o + 1,
|
o + 1,
|
||||||
2,
|
2,
|
||||||
o.b + 1,
|
o.b + 1,
|
||||||
1..b + 1
|
NaN
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
expect_stdout: true
|
expect_stdout: true
|
||||||
@@ -365,7 +365,7 @@ unsafe_object_repeated: {
|
|||||||
o + 1,
|
o + 1,
|
||||||
2,
|
2,
|
||||||
o.b + 1,
|
o.b + 1,
|
||||||
1..b + 1
|
NaN
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
expect_stdout: true
|
expect_stdout: true
|
||||||
@@ -444,8 +444,8 @@ unsafe_integer_key: {
|
|||||||
2,
|
2,
|
||||||
2,
|
2,
|
||||||
({0:1})[1] + 1,
|
({0:1})[1] + 1,
|
||||||
1[1] + 1,
|
NaN,
|
||||||
1["1"] + 1
|
NaN
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
expect_stdout: true
|
expect_stdout: true
|
||||||
@@ -500,8 +500,8 @@ unsafe_float_key: {
|
|||||||
2,
|
2,
|
||||||
2,
|
2,
|
||||||
({2.72:1})[3.14] + 1,
|
({2.72:1})[3.14] + 1,
|
||||||
1[3.14] + 1,
|
NaN,
|
||||||
1["3.14"] + 1
|
NaN
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
expect_stdout: true
|
expect_stdout: true
|
||||||
@@ -635,12 +635,12 @@ unsafe_string_bad_index: {
|
|||||||
}
|
}
|
||||||
expect: {
|
expect: {
|
||||||
console.log(
|
console.log(
|
||||||
"1234".a + 1,
|
NaN,
|
||||||
"1234"["a"] + 1,
|
NaN,
|
||||||
"1234"[3.14] + 1
|
NaN
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
expect_stdout: true
|
expect_stdout: "NaN NaN NaN"
|
||||||
}
|
}
|
||||||
|
|
||||||
prototype_function: {
|
prototype_function: {
|
||||||
@@ -820,8 +820,8 @@ unsafe_charAt_noop: {
|
|||||||
}
|
}
|
||||||
expect: {
|
expect: {
|
||||||
console.log(
|
console.log(
|
||||||
s.charAt(0),
|
s[0],
|
||||||
"string".charAt(x),
|
"string"[0 | x],
|
||||||
(typeof x)[0]
|
(typeof x)[0]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -1124,14 +1124,14 @@ issue_2207_1: {
|
|||||||
console.log(Math.max(3, 6, 2, 7, 3, 4));
|
console.log(Math.max(3, 6, 2, 7, 3, 4));
|
||||||
console.log(Math.cos(1.2345));
|
console.log(Math.cos(1.2345));
|
||||||
console.log(Math.cos(1.2345) - Math.sin(4.321));
|
console.log(Math.cos(1.2345) - Math.sin(4.321));
|
||||||
console.log(Math.pow(Math.PI, Math.E - Math.LN10));
|
console.log(Math.pow(Math.PI, Math.E - Math.LN10).toFixed(15));
|
||||||
}
|
}
|
||||||
expect: {
|
expect: {
|
||||||
console.log("A");
|
console.log("A");
|
||||||
console.log(7);
|
console.log(7);
|
||||||
console.log(Math.cos(1.2345));
|
console.log(Math.cos(1.2345));
|
||||||
console.log(1.2543732512566947);
|
console.log(1.2543732512566947);
|
||||||
console.log(1.6093984514472044);
|
console.log("1.609398451447204");
|
||||||
}
|
}
|
||||||
expect_stdout: true
|
expect_stdout: true
|
||||||
}
|
}
|
||||||
@@ -1687,3 +1687,73 @@ try_increment: {
|
|||||||
}
|
}
|
||||||
expect_stdout: "1"
|
expect_stdout: "1"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unsafe_escaped: {
|
||||||
|
options = {
|
||||||
|
evaluate: true,
|
||||||
|
inline: true,
|
||||||
|
passes: 3,
|
||||||
|
reduce_vars: true,
|
||||||
|
side_effects: true,
|
||||||
|
unsafe: true,
|
||||||
|
unused: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
(function(a) {
|
||||||
|
console.log(function(index) {
|
||||||
|
return a[index];
|
||||||
|
}(function(term) {
|
||||||
|
return a.indexOf(term);
|
||||||
|
}("PASS")));
|
||||||
|
})([ "PASS" ]);
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
console.log("PASS");
|
||||||
|
}
|
||||||
|
expect_stdout: "PASS"
|
||||||
|
}
|
||||||
|
|
||||||
|
unsafe_string_replace: {
|
||||||
|
options = {
|
||||||
|
evaluate: true,
|
||||||
|
unsafe: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
"foo".replace("f", function() {
|
||||||
|
console.log("PASS");
|
||||||
|
});
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
"foo".replace("f", function() {
|
||||||
|
console.log("PASS");
|
||||||
|
});
|
||||||
|
}
|
||||||
|
expect_stdout: "PASS"
|
||||||
|
}
|
||||||
|
|
||||||
|
issue_3387_1: {
|
||||||
|
options = {
|
||||||
|
evaluate: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
console.log(1 + (2 + "3"[4]));
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
console.log(1 + (2 + "3"[4]));
|
||||||
|
}
|
||||||
|
expect_stdout: "NaN"
|
||||||
|
}
|
||||||
|
|
||||||
|
issue_3387_2: {
|
||||||
|
options = {
|
||||||
|
evaluate: true,
|
||||||
|
unsafe: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
console.log(1 + (2 + "3"[4]));
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
console.log(NaN);
|
||||||
|
}
|
||||||
|
expect_stdout: "NaN"
|
||||||
|
}
|
||||||
|
|||||||
@@ -2703,3 +2703,365 @@ loop_inline: {
|
|||||||
}
|
}
|
||||||
expect_stdout: "undefined"
|
expect_stdout: "undefined"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
functions: {
|
||||||
|
options = {
|
||||||
|
functions: true,
|
||||||
|
reduce_vars: true,
|
||||||
|
unused: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
!function() {
|
||||||
|
var a = function a() {
|
||||||
|
return a && "a";
|
||||||
|
};
|
||||||
|
var b = function x() {
|
||||||
|
return !!x;
|
||||||
|
};
|
||||||
|
var c = function(c) {
|
||||||
|
return c;
|
||||||
|
};
|
||||||
|
if (c(b(a()))) {
|
||||||
|
var d = function() {};
|
||||||
|
var e = function y() {
|
||||||
|
return typeof y;
|
||||||
|
};
|
||||||
|
var f = function(f) {
|
||||||
|
return f;
|
||||||
|
};
|
||||||
|
console.log(a(d()), b(e()), c(f(42)), typeof d, e(), typeof f);
|
||||||
|
}
|
||||||
|
}();
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
!function() {
|
||||||
|
function a() {
|
||||||
|
return a && "a";
|
||||||
|
}
|
||||||
|
function b() {
|
||||||
|
return !!b;
|
||||||
|
}
|
||||||
|
var c = function(c) {
|
||||||
|
return c;
|
||||||
|
};
|
||||||
|
if (c(b(a()))) {
|
||||||
|
function d() {}
|
||||||
|
function e() {
|
||||||
|
return typeof e;
|
||||||
|
}
|
||||||
|
var f = function(f) {
|
||||||
|
return f;
|
||||||
|
};
|
||||||
|
console.log(a(d()), b(e()), c(f(42)), typeof d, e(), typeof f);
|
||||||
|
}
|
||||||
|
}();
|
||||||
|
}
|
||||||
|
expect_stdout: "a true 42 function function function"
|
||||||
|
}
|
||||||
|
|
||||||
|
functions_use_strict: {
|
||||||
|
options = {
|
||||||
|
functions: true,
|
||||||
|
reduce_vars: true,
|
||||||
|
unused: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
"use strict";
|
||||||
|
!function() {
|
||||||
|
var a = function a() {
|
||||||
|
return a && "a";
|
||||||
|
};
|
||||||
|
var b = function x() {
|
||||||
|
return !!x;
|
||||||
|
};
|
||||||
|
var c = function(c) {
|
||||||
|
return c;
|
||||||
|
};
|
||||||
|
if (c(b(a()))) {
|
||||||
|
var d = function() {};
|
||||||
|
var e = function y() {
|
||||||
|
return typeof y;
|
||||||
|
};
|
||||||
|
var f = function(f) {
|
||||||
|
return f;
|
||||||
|
};
|
||||||
|
console.log(a(d()), b(e()), c(f(42)), typeof d, e(), typeof f);
|
||||||
|
}
|
||||||
|
}();
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
"use strict";
|
||||||
|
!function() {
|
||||||
|
function a() {
|
||||||
|
return a && "a";
|
||||||
|
}
|
||||||
|
function b() {
|
||||||
|
return !!b;
|
||||||
|
}
|
||||||
|
var c = function(c) {
|
||||||
|
return c;
|
||||||
|
};
|
||||||
|
if (c(b(a()))) {
|
||||||
|
var d = function() {};
|
||||||
|
var e = function y() {
|
||||||
|
return typeof y;
|
||||||
|
};
|
||||||
|
var f = function(f) {
|
||||||
|
return f;
|
||||||
|
};
|
||||||
|
console.log(a(d()), b(e()), c(f(42)), typeof d, e(), typeof f);
|
||||||
|
}
|
||||||
|
}();
|
||||||
|
}
|
||||||
|
expect_stdout: "a true 42 function function function"
|
||||||
|
}
|
||||||
|
|
||||||
|
issue_2437: {
|
||||||
|
options = {
|
||||||
|
collapse_vars: true,
|
||||||
|
conditionals: true,
|
||||||
|
functions: true,
|
||||||
|
inline: true,
|
||||||
|
join_vars: true,
|
||||||
|
passes: 2,
|
||||||
|
reduce_funcs: true,
|
||||||
|
reduce_vars: true,
|
||||||
|
sequences: true,
|
||||||
|
side_effects: true,
|
||||||
|
toplevel: true,
|
||||||
|
unused: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
function foo() {
|
||||||
|
return bar();
|
||||||
|
}
|
||||||
|
function bar() {
|
||||||
|
if (xhrDesc) {
|
||||||
|
var req = new XMLHttpRequest();
|
||||||
|
var result = !!req.onreadystatechange;
|
||||||
|
Object.defineProperty(XMLHttpRequest.prototype, 'onreadystatechange', xhrDesc || {});
|
||||||
|
return result;
|
||||||
|
} else {
|
||||||
|
var req = new XMLHttpRequest();
|
||||||
|
var detectFunc = function(){};
|
||||||
|
req.onreadystatechange = detectFunc;
|
||||||
|
var result = req[SYMBOL_FAKE_ONREADYSTATECHANGE_1] === detectFunc;
|
||||||
|
req.onreadystatechange = null;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
console.log(foo());
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
console.log(function() {
|
||||||
|
if (xhrDesc) {
|
||||||
|
var result = !!(req = new XMLHttpRequest()).onreadystatechange;
|
||||||
|
return Object.defineProperty(XMLHttpRequest.prototype, "onreadystatechange", xhrDesc || {}),
|
||||||
|
result;
|
||||||
|
}
|
||||||
|
function detectFunc() {}
|
||||||
|
var req;
|
||||||
|
(req = new XMLHttpRequest()).onreadystatechange = detectFunc;
|
||||||
|
result = req[SYMBOL_FAKE_ONREADYSTATECHANGE_1] === detectFunc;
|
||||||
|
return req.onreadystatechange = null, result;
|
||||||
|
}());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
issue_2485: {
|
||||||
|
options = {
|
||||||
|
functions: true,
|
||||||
|
reduce_funcs: true,
|
||||||
|
reduce_vars: true,
|
||||||
|
unused: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
var foo = function(bar) {
|
||||||
|
var n = function(a, b) {
|
||||||
|
return a + b;
|
||||||
|
};
|
||||||
|
var sumAll = function(arg) {
|
||||||
|
return arg.reduce(n, 0);
|
||||||
|
};
|
||||||
|
var runSumAll = function(arg) {
|
||||||
|
return sumAll(arg);
|
||||||
|
};
|
||||||
|
bar.baz = function(arg) {
|
||||||
|
var n = runSumAll(arg);
|
||||||
|
return (n.get = 1), n;
|
||||||
|
};
|
||||||
|
return bar;
|
||||||
|
};
|
||||||
|
var bar = foo({});
|
||||||
|
console.log(bar.baz([1, 2, 3]));
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
var foo = function(bar) {
|
||||||
|
function n(a, b) {
|
||||||
|
return a + b;
|
||||||
|
}
|
||||||
|
function runSumAll(arg) {
|
||||||
|
return function(arg) {
|
||||||
|
return arg.reduce(n, 0);
|
||||||
|
}(arg);
|
||||||
|
}
|
||||||
|
bar.baz = function(arg) {
|
||||||
|
var n = runSumAll(arg);
|
||||||
|
return (n.get = 1), n;
|
||||||
|
};
|
||||||
|
return bar;
|
||||||
|
};
|
||||||
|
var bar = foo({});
|
||||||
|
console.log(bar.baz([1, 2, 3]));
|
||||||
|
}
|
||||||
|
expect_stdout: "6"
|
||||||
|
}
|
||||||
|
|
||||||
|
issue_3364: {
|
||||||
|
options = {
|
||||||
|
functions: true,
|
||||||
|
reduce_vars: true,
|
||||||
|
toplevel: true,
|
||||||
|
unused: true,
|
||||||
|
}
|
||||||
|
mangle = {}
|
||||||
|
input: {
|
||||||
|
var s = 2, a = 100, b = 10, c = 0;
|
||||||
|
function f(p, e, r) {
|
||||||
|
try {
|
||||||
|
for (var i = 1; i-- > 0;)
|
||||||
|
var a = function(x) {
|
||||||
|
function g(y) {
|
||||||
|
y && y[a++];
|
||||||
|
}
|
||||||
|
var x = g(--s >= 0 && f(c++));
|
||||||
|
for (var j = 1; --j > 0;);
|
||||||
|
}();
|
||||||
|
} catch (e) {
|
||||||
|
try {
|
||||||
|
return;
|
||||||
|
} catch (z) {
|
||||||
|
for (var k = 1; --k > 0;) {
|
||||||
|
for (var l = 1; l > 0; --l) {
|
||||||
|
var n = function() {};
|
||||||
|
for (var k in n)
|
||||||
|
var o = (n, k);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
var r = f();
|
||||||
|
console.log(c);
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
var s = 2, c = 0;
|
||||||
|
(function n(r, o, a) {
|
||||||
|
try {
|
||||||
|
for (var f = 1; f-- >0;)
|
||||||
|
var t = function(r) {
|
||||||
|
(function(r) {
|
||||||
|
r && r[t++];
|
||||||
|
})(--s >= 0 && n(c++));
|
||||||
|
for (var o = 1; --o > 0;);
|
||||||
|
}();
|
||||||
|
} catch (o) {
|
||||||
|
try {
|
||||||
|
return;
|
||||||
|
} catch (r) {
|
||||||
|
for (var v = 1; --v > 0;)
|
||||||
|
for (var i = 1; i > 0;--i) {
|
||||||
|
function u() {}
|
||||||
|
for (var v in u);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})();
|
||||||
|
console.log(c);
|
||||||
|
}
|
||||||
|
expect_stdout: "2"
|
||||||
|
}
|
||||||
|
|
||||||
|
issue_3366: {
|
||||||
|
options = {
|
||||||
|
functions: true,
|
||||||
|
inline: true,
|
||||||
|
reduce_vars: true,
|
||||||
|
toplevel: true,
|
||||||
|
unused: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
function f() {
|
||||||
|
function g() {
|
||||||
|
return function() {};
|
||||||
|
}
|
||||||
|
var a = g();
|
||||||
|
(function() {
|
||||||
|
this && a && console.log("PASS");
|
||||||
|
})();
|
||||||
|
}
|
||||||
|
f();
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
void function() {
|
||||||
|
this && a && console.log("PASS");
|
||||||
|
}();
|
||||||
|
function a() {}
|
||||||
|
}
|
||||||
|
expect_stdout: "PASS"
|
||||||
|
}
|
||||||
|
|
||||||
|
issue_3371: {
|
||||||
|
options = {
|
||||||
|
functions: true,
|
||||||
|
inline: true,
|
||||||
|
reduce_vars: true,
|
||||||
|
side_effects: true,
|
||||||
|
unused: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
(function() {
|
||||||
|
var a = function f() {
|
||||||
|
(function() {
|
||||||
|
console.log(typeof f);
|
||||||
|
})();
|
||||||
|
};
|
||||||
|
while (a());
|
||||||
|
})();
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
(function() {
|
||||||
|
function a() {
|
||||||
|
console.log(typeof a);
|
||||||
|
}
|
||||||
|
while (a());
|
||||||
|
})();
|
||||||
|
}
|
||||||
|
expect_stdout: "function"
|
||||||
|
}
|
||||||
|
|
||||||
|
class_iife: {
|
||||||
|
options = {
|
||||||
|
inline: true,
|
||||||
|
sequences: true,
|
||||||
|
toplevel: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
var A = function() {
|
||||||
|
function B() {}
|
||||||
|
B.prototype.m = function() {
|
||||||
|
console.log("PASS");
|
||||||
|
};
|
||||||
|
return B;
|
||||||
|
}();
|
||||||
|
new A().m();
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
var A = (B.prototype.m = function() {
|
||||||
|
console.log("PASS");
|
||||||
|
}, B);
|
||||||
|
function B() {}
|
||||||
|
new A().m();
|
||||||
|
}
|
||||||
|
expect_stdout: "PASS"
|
||||||
|
}
|
||||||
|
|||||||
@@ -861,3 +861,111 @@ issue_3215_4: {
|
|||||||
}
|
}
|
||||||
expect_stdout: "PASS"
|
expect_stdout: "PASS"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
issue_3355_1: {
|
||||||
|
mangle = {
|
||||||
|
ie8: false,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
(function f() {
|
||||||
|
var f;
|
||||||
|
})();
|
||||||
|
(function g() {
|
||||||
|
})();
|
||||||
|
console.log(typeof f === typeof g);
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
(function o() {
|
||||||
|
var o;
|
||||||
|
})();
|
||||||
|
(function o() {
|
||||||
|
})();
|
||||||
|
console.log(typeof f === typeof g);
|
||||||
|
}
|
||||||
|
expect_stdout: "true"
|
||||||
|
}
|
||||||
|
|
||||||
|
issue_3355_2: {
|
||||||
|
mangle = {
|
||||||
|
ie8: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
(function f() {
|
||||||
|
var f;
|
||||||
|
})();
|
||||||
|
(function g() {
|
||||||
|
})();
|
||||||
|
console.log(typeof f === typeof g);
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
(function f() {
|
||||||
|
var f;
|
||||||
|
})();
|
||||||
|
(function g() {
|
||||||
|
})();
|
||||||
|
console.log(typeof f === typeof g);
|
||||||
|
}
|
||||||
|
expect_stdout: "true"
|
||||||
|
}
|
||||||
|
|
||||||
|
issue_3355_3: {
|
||||||
|
mangle = {
|
||||||
|
ie8: false,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
!function(a) {
|
||||||
|
"aaaaaaaaaa";
|
||||||
|
a();
|
||||||
|
var b = function c() {
|
||||||
|
var c = 42;
|
||||||
|
console.log("FAIL");
|
||||||
|
};
|
||||||
|
}(function() {
|
||||||
|
console.log("PASS");
|
||||||
|
});
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
!function(a) {
|
||||||
|
"aaaaaaaaaa";
|
||||||
|
a();
|
||||||
|
var o = function a() {
|
||||||
|
var a = 42;
|
||||||
|
console.log("FAIL");
|
||||||
|
};
|
||||||
|
}(function() {
|
||||||
|
console.log("PASS");
|
||||||
|
});
|
||||||
|
}
|
||||||
|
expect_stdout: "PASS"
|
||||||
|
}
|
||||||
|
|
||||||
|
issue_3355_4: {
|
||||||
|
mangle = {
|
||||||
|
ie8: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
!function(a) {
|
||||||
|
"aaaaaaaaaa";
|
||||||
|
a();
|
||||||
|
var b = function c() {
|
||||||
|
var c = 42;
|
||||||
|
console.log("FAIL");
|
||||||
|
};
|
||||||
|
}(function() {
|
||||||
|
console.log("PASS");
|
||||||
|
});
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
!function(a) {
|
||||||
|
"aaaaaaaaaa";
|
||||||
|
a();
|
||||||
|
var o = function n() {
|
||||||
|
var n = 42;
|
||||||
|
console.log("FAIL");
|
||||||
|
};
|
||||||
|
}(function() {
|
||||||
|
console.log("PASS");
|
||||||
|
});
|
||||||
|
}
|
||||||
|
expect_stdout: "PASS"
|
||||||
|
}
|
||||||
|
|||||||
@@ -59,7 +59,6 @@ non_hoisted_function_after_return_2a: {
|
|||||||
passes: 2,
|
passes: 2,
|
||||||
side_effects: true,
|
side_effects: true,
|
||||||
unused: true,
|
unused: true,
|
||||||
warnings: "verbose",
|
|
||||||
}
|
}
|
||||||
input: {
|
input: {
|
||||||
function foo(x) {
|
function foo(x) {
|
||||||
@@ -91,13 +90,13 @@ non_hoisted_function_after_return_2a: {
|
|||||||
"WARN: Declarations in unreachable code! [test/compress/issue-1034.js:7,16]",
|
"WARN: Declarations in unreachable code! [test/compress/issue-1034.js:7,16]",
|
||||||
"WARN: Dropping unused variable a [test/compress/issue-1034.js:4,20]",
|
"WARN: Dropping unused variable a [test/compress/issue-1034.js:4,20]",
|
||||||
"WARN: Dropping unused function nope [test/compress/issue-1034.js:11,21]",
|
"WARN: Dropping unused function nope [test/compress/issue-1034.js:11,21]",
|
||||||
"WARN: pass 0: last_count: Infinity, count: 37",
|
"INFO: pass 0: last_count: Infinity, count: 37",
|
||||||
"WARN: Dropping unreachable code [test/compress/issue-1034.js:9,12]",
|
"WARN: Dropping unreachable code [test/compress/issue-1034.js:9,12]",
|
||||||
"WARN: Declarations in unreachable code! [test/compress/issue-1034.js:9,12]",
|
"WARN: Declarations in unreachable code! [test/compress/issue-1034.js:9,12]",
|
||||||
"WARN: Dropping unreachable code [test/compress/issue-1034.js:12,12]",
|
"WARN: Dropping unreachable code [test/compress/issue-1034.js:12,12]",
|
||||||
"WARN: Dropping unused variable b [test/compress/issue-1034.js:7,20]",
|
"INFO: Dropping unused variable b [test/compress/issue-1034.js:7,20]",
|
||||||
"WARN: Dropping unused variable c [test/compress/issue-1034.js:9,16]",
|
"INFO: Dropping unused variable c [test/compress/issue-1034.js:9,16]",
|
||||||
"WARN: pass 1: last_count: 37, count: 18",
|
"INFO: pass 1: last_count: 37, count: 18",
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -213,7 +212,6 @@ non_hoisted_function_after_return_2a_strict: {
|
|||||||
passes: 2,
|
passes: 2,
|
||||||
side_effects: true,
|
side_effects: true,
|
||||||
unused: true,
|
unused: true,
|
||||||
warnings: "verbose",
|
|
||||||
}
|
}
|
||||||
input: {
|
input: {
|
||||||
"use strict";
|
"use strict";
|
||||||
@@ -250,13 +248,13 @@ non_hoisted_function_after_return_2a_strict: {
|
|||||||
"WARN: Declarations in unreachable code! [test/compress/issue-1034.js:8,16]",
|
"WARN: Declarations in unreachable code! [test/compress/issue-1034.js:8,16]",
|
||||||
"WARN: Dropping unused variable a [test/compress/issue-1034.js:5,20]",
|
"WARN: Dropping unused variable a [test/compress/issue-1034.js:5,20]",
|
||||||
"WARN: Dropping unused function nope [test/compress/issue-1034.js:12,21]",
|
"WARN: Dropping unused function nope [test/compress/issue-1034.js:12,21]",
|
||||||
"WARN: pass 0: last_count: Infinity, count: 48",
|
"INFO: pass 0: last_count: Infinity, count: 48",
|
||||||
"WARN: Dropping unreachable code [test/compress/issue-1034.js:10,12]",
|
"WARN: Dropping unreachable code [test/compress/issue-1034.js:10,12]",
|
||||||
"WARN: Declarations in unreachable code! [test/compress/issue-1034.js:10,12]",
|
"WARN: Declarations in unreachable code! [test/compress/issue-1034.js:10,12]",
|
||||||
"WARN: Dropping unreachable code [test/compress/issue-1034.js:13,12]",
|
"WARN: Dropping unreachable code [test/compress/issue-1034.js:13,12]",
|
||||||
"WARN: Dropping unused variable b [test/compress/issue-1034.js:8,20]",
|
"INFO: Dropping unused variable b [test/compress/issue-1034.js:8,20]",
|
||||||
"WARN: Dropping unused variable c [test/compress/issue-1034.js:10,16]",
|
"INFO: Dropping unused variable c [test/compress/issue-1034.js:10,16]",
|
||||||
"WARN: pass 1: last_count: 48, count: 29",
|
"INFO: pass 1: last_count: 48, count: 29",
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
issue_1639_1: {
|
issue_1639_1: {
|
||||||
options = {
|
options = {
|
||||||
booleans: true,
|
booleans: true,
|
||||||
@@ -12,7 +11,6 @@ issue_1639_1: {
|
|||||||
}
|
}
|
||||||
input: {
|
input: {
|
||||||
var a = 100, b = 10;
|
var a = 100, b = 10;
|
||||||
|
|
||||||
var L1 = 5;
|
var L1 = 5;
|
||||||
while (--L1 > 0) {
|
while (--L1 > 0) {
|
||||||
if ((--b), false) {
|
if ((--b), false) {
|
||||||
@@ -21,7 +19,6 @@ issue_1639_1: {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log(a, b);
|
console.log(a, b);
|
||||||
}
|
}
|
||||||
expect: {
|
expect: {
|
||||||
@@ -29,7 +26,7 @@ issue_1639_1: {
|
|||||||
if (--b, 0) var ignore = 0;
|
if (--b, 0) var ignore = 0;
|
||||||
console.log(a, b);
|
console.log(a, b);
|
||||||
}
|
}
|
||||||
expect_stdout: true
|
expect_stdout: "100 6"
|
||||||
}
|
}
|
||||||
|
|
||||||
issue_1639_2: {
|
issue_1639_2: {
|
||||||
@@ -44,25 +41,23 @@ issue_1639_2: {
|
|||||||
}
|
}
|
||||||
input: {
|
input: {
|
||||||
var a = 100, b = 10;
|
var a = 100, b = 10;
|
||||||
|
|
||||||
function f19() {
|
function f19() {
|
||||||
if (++a, false)
|
if (++a, false)
|
||||||
if (a)
|
if (a)
|
||||||
if (++a);
|
if (++a);
|
||||||
}
|
}
|
||||||
f19();
|
f19();
|
||||||
|
|
||||||
console.log(a, b);
|
console.log(a, b);
|
||||||
}
|
}
|
||||||
expect: {
|
expect: {
|
||||||
var a = 100, b = 10;
|
var a = 100, b = 10;
|
||||||
function f19() {
|
function f19() {
|
||||||
++a, 0;
|
++a, 1;
|
||||||
}
|
}
|
||||||
f19(),
|
f19(),
|
||||||
console.log(a, b);
|
console.log(a, b);
|
||||||
}
|
}
|
||||||
expect_stdout: true
|
expect_stdout: "101 10"
|
||||||
}
|
}
|
||||||
|
|
||||||
issue_1639_3: {
|
issue_1639_3: {
|
||||||
@@ -84,5 +79,5 @@ issue_1639_3: {
|
|||||||
a++,
|
a++,
|
||||||
console.log(a, b);
|
console.log(a, b);
|
||||||
}
|
}
|
||||||
expect_stdout: true
|
expect_stdout: "101 10"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -646,3 +646,30 @@ issue_2904: {
|
|||||||
}
|
}
|
||||||
expect_stdout: "1"
|
expect_stdout: "1"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
issue_3371: {
|
||||||
|
options = {
|
||||||
|
functions: true,
|
||||||
|
join_vars: true,
|
||||||
|
loops: true,
|
||||||
|
reduce_vars: true,
|
||||||
|
unused: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
(function() {
|
||||||
|
var a = function() {
|
||||||
|
console.log("PASS");
|
||||||
|
};
|
||||||
|
while (a());
|
||||||
|
})();
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
(function() {
|
||||||
|
function a() {
|
||||||
|
console.log("PASS");
|
||||||
|
}
|
||||||
|
for (; a(); );
|
||||||
|
})();
|
||||||
|
}
|
||||||
|
expect_stdout: "PASS"
|
||||||
|
}
|
||||||
|
|||||||
@@ -1862,3 +1862,29 @@ join_expr: {
|
|||||||
}
|
}
|
||||||
expect_stdout: "PASS"
|
expect_stdout: "PASS"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
issue_3389: {
|
||||||
|
options = {
|
||||||
|
evaluate: true,
|
||||||
|
properties: true,
|
||||||
|
reduce_vars: true,
|
||||||
|
unsafe: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
(function() {
|
||||||
|
var a = "PASS";
|
||||||
|
if (delete b)
|
||||||
|
b = a[null] = 42;
|
||||||
|
console.log(a);
|
||||||
|
})();
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
(function() {
|
||||||
|
var a = "PASS";
|
||||||
|
if (delete b)
|
||||||
|
b = a.null = 42;
|
||||||
|
console.log(a);
|
||||||
|
})();
|
||||||
|
}
|
||||||
|
expect_stdout: "PASS"
|
||||||
|
}
|
||||||
|
|||||||
@@ -193,37 +193,34 @@ unsafe_evaluate: {
|
|||||||
}
|
}
|
||||||
input: {
|
input: {
|
||||||
function f0() {
|
function f0() {
|
||||||
var a = {
|
var a = { b: 1 };
|
||||||
b:1
|
|
||||||
};
|
|
||||||
console.log(a.b + 3);
|
console.log(a.b + 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
function f1() {
|
function f1() {
|
||||||
var a = {
|
var a = {
|
||||||
b:{
|
b: { c: 1 },
|
||||||
c:1
|
|
||||||
},
|
|
||||||
d: 2
|
d: 2
|
||||||
};
|
};
|
||||||
console.log(a.b + 3, a.d + 4, a.b.c + 5, a.d.c + 6);
|
console.log(a.b + 3, a.d + 4, a.b.c + 5, a.d.c + 6);
|
||||||
}
|
}
|
||||||
|
f0();
|
||||||
|
f1();
|
||||||
}
|
}
|
||||||
expect: {
|
expect: {
|
||||||
function f0() {
|
function f0() {
|
||||||
console.log(4);
|
console.log(4);
|
||||||
}
|
}
|
||||||
|
|
||||||
function f1() {
|
function f1() {
|
||||||
var a = {
|
var a = {
|
||||||
b:{
|
b: { c: 1 },
|
||||||
c:1
|
|
||||||
},
|
|
||||||
d: 2
|
d: 2
|
||||||
};
|
};
|
||||||
console.log(a.b + 3, 6, 6, 2..c + 6);
|
console.log(a.b + 3, 6, 6, NaN);
|
||||||
}
|
}
|
||||||
|
f0();
|
||||||
|
f1();
|
||||||
}
|
}
|
||||||
|
expect_stdout: true
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe_evaluate_side_effect_free_1: {
|
unsafe_evaluate_side_effect_free_1: {
|
||||||
@@ -281,8 +278,8 @@ unsafe_evaluate_escaped: {
|
|||||||
console.log(function(){ var o={p:3},a=[o]; console.log(a[0].p++); return o.p; }());
|
console.log(function(){ var o={p:3},a=[o]; console.log(a[0].p++); return o.p; }());
|
||||||
}
|
}
|
||||||
expect: {
|
expect: {
|
||||||
console.log(function(){ var o={p:1}; console.log(o, o.p); return o.p; }());
|
console.log(function(){ var o={p:1}; console.log(o, 1); return o.p; }());
|
||||||
console.log(function(){ var o={p:2}; console.log(o.p, o); return o.p; }());
|
console.log(function(){ var o={p:2}; console.log(2, o); return o.p; }());
|
||||||
console.log(function(){ var o={p:3},a=[o]; console.log(a[0].p++); return o.p; }());
|
console.log(function(){ var o={p:3},a=[o]; console.log(a[0].p++); return o.p; }());
|
||||||
}
|
}
|
||||||
expect_stdout: true
|
expect_stdout: true
|
||||||
@@ -6737,3 +6734,21 @@ drop_side_effect_free: {
|
|||||||
}
|
}
|
||||||
expect_stdout: "123"
|
expect_stdout: "123"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
issue_3377: {
|
||||||
|
options = {
|
||||||
|
reduce_vars: true,
|
||||||
|
unused: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
console.log(function f() {
|
||||||
|
return f[0], (f = 42);
|
||||||
|
}());
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
console.log(function f() {
|
||||||
|
return f[0], (f = 42);
|
||||||
|
}());
|
||||||
|
}
|
||||||
|
expect_stdout: "42"
|
||||||
|
}
|
||||||
|
|||||||
@@ -702,7 +702,7 @@ side_effects_cascade_3: {
|
|||||||
}
|
}
|
||||||
expect: {
|
expect: {
|
||||||
function f(a, b) {
|
function f(a, b) {
|
||||||
!(b += a) && ((b = a) || (b -= a, b ^= a)),
|
(b += a) || (b = a) || (b -= a, b ^= a),
|
||||||
a--;
|
a--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -964,3 +964,39 @@ missing_link: {
|
|||||||
console.log(a);
|
console.log(a);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
angularjs_chain: {
|
||||||
|
options = {
|
||||||
|
conditionals: true,
|
||||||
|
sequences: true,
|
||||||
|
side_effects: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
function nonComputedMember(left, right, context, create) {
|
||||||
|
var lhs = left();
|
||||||
|
if (create && create !== 1) {
|
||||||
|
if (lhs && lhs[right] == null) {
|
||||||
|
lhs[right] = {};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
var value = lhs != null ? lhs[right] : undefined;
|
||||||
|
if (context) {
|
||||||
|
return { context: lhs, name: right, value: value };
|
||||||
|
} else {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
function nonComputedMember(left, right, context, create) {
|
||||||
|
var lhs = left();
|
||||||
|
create && 1 !== create && lhs && null == lhs[right] && (lhs[right] = {});
|
||||||
|
var value = null != lhs ? lhs[right] : void 0;
|
||||||
|
return context ? {
|
||||||
|
context: lhs,
|
||||||
|
name: right,
|
||||||
|
value: value
|
||||||
|
} : value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,7 +1,5 @@
|
|||||||
exports["base54"] = base54;
|
|
||||||
exports["Compressor"] = Compressor;
|
exports["Compressor"] = Compressor;
|
||||||
exports["defaults"] = defaults;
|
exports["defaults"] = defaults;
|
||||||
exports["is_identifier"] = is_identifier;
|
|
||||||
exports["JS_Parse_Error"] = JS_Parse_Error;
|
exports["JS_Parse_Error"] = JS_Parse_Error;
|
||||||
exports["mangle_properties"] = mangle_properties;
|
exports["mangle_properties"] = mangle_properties;
|
||||||
exports["minify"] = minify;
|
exports["minify"] = minify;
|
||||||
@@ -9,7 +7,6 @@ exports["OutputStream"] = OutputStream;
|
|||||||
exports["parse"] = parse;
|
exports["parse"] = parse;
|
||||||
exports["push_uniq"] = push_uniq;
|
exports["push_uniq"] = push_uniq;
|
||||||
exports["reserve_quoted_keys"] = reserve_quoted_keys;
|
exports["reserve_quoted_keys"] = reserve_quoted_keys;
|
||||||
exports["SourceMap"] = SourceMap;
|
|
||||||
exports["string_template"] = string_template;
|
exports["string_template"] = string_template;
|
||||||
exports["tokenizer"] = tokenizer;
|
exports["tokenizer"] = tokenizer;
|
||||||
exports["TreeTransformer"] = TreeTransformer;
|
exports["TreeTransformer"] = TreeTransformer;
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
var site = "https://browserbench.org/JetStream";
|
var site = "https://browserbench.org/JetStream1.1";
|
||||||
if (typeof phantom == "undefined") {
|
if (typeof phantom == "undefined") {
|
||||||
require("../tools/exit");
|
require("../tools/exit");
|
||||||
var args = process.argv.slice(2);
|
var args = process.argv.slice(2);
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ describe("bin/uglifyjs", function() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
it("Should give sensible error against invalid input source map", function(done) {
|
it("Should give sensible error against invalid input source map", function(done) {
|
||||||
var command = uglifyjscmd + " test/mocha.js --source-map content=blah,url=inline";
|
var command = uglifyjscmd + " test/mocha.js --source-map content=blah,url=inline --verbose";
|
||||||
exec(command, function(err, stdout, stderr) {
|
exec(command, function(err, stdout, stderr) {
|
||||||
assert.ok(err);
|
assert.ok(err);
|
||||||
assert.deepEqual(stderr.split(/\n/).slice(0, 2), [
|
assert.deepEqual(stderr.split(/\n/).slice(0, 2), [
|
||||||
@@ -83,6 +83,7 @@ describe("bin/uglifyjs", function() {
|
|||||||
"test/input/issue-2082/sample.js",
|
"test/input/issue-2082/sample.js",
|
||||||
"--source-map", "content=test/input/issue-2082/sample.js.map",
|
"--source-map", "content=test/input/issue-2082/sample.js.map",
|
||||||
"--source-map", "url=inline",
|
"--source-map", "url=inline",
|
||||||
|
"--verbose",
|
||||||
].join(" ");
|
].join(" ");
|
||||||
exec(command, function(err, stdout, stderr) {
|
exec(command, function(err, stdout, stderr) {
|
||||||
if (err) throw err;
|
if (err) throw err;
|
||||||
@@ -202,7 +203,7 @@ describe("bin/uglifyjs", function() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
it("Should warn for missing inline source map", function(done) {
|
it("Should warn for missing inline source map", function(done) {
|
||||||
var command = uglifyjscmd + " test/input/issue-1323/sample.js --source-map content=inline,url=inline";
|
var command = uglifyjscmd + " test/input/issue-1323/sample.js --source-map content=inline,url=inline --warn";
|
||||||
exec(command, function(err, stdout, stderr) {
|
exec(command, function(err, stdout, stderr) {
|
||||||
if (err) throw err;
|
if (err) throw err;
|
||||||
assert.strictEqual(stdout, [
|
assert.strictEqual(stdout, [
|
||||||
@@ -221,6 +222,7 @@ describe("bin/uglifyjs", function() {
|
|||||||
"test/input/issue-520/input.js",
|
"test/input/issue-520/input.js",
|
||||||
"test/input/issue-1323/sample.js",
|
"test/input/issue-1323/sample.js",
|
||||||
"--source-map", "content=inline,url=inline",
|
"--source-map", "content=inline,url=inline",
|
||||||
|
"--warn",
|
||||||
].join(" ");
|
].join(" ");
|
||||||
exec(command, function(err, stdout, stderr) {
|
exec(command, function(err, stdout, stderr) {
|
||||||
if (err) throw err;
|
if (err) throw err;
|
||||||
@@ -647,7 +649,7 @@ describe("bin/uglifyjs", function() {
|
|||||||
exec(command, function(err, stdout, stderr) {
|
exec(command, function(err, stdout, stderr) {
|
||||||
assert.ok(err);
|
assert.ok(err);
|
||||||
assert.strictEqual(stdout, "");
|
assert.strictEqual(stdout, "");
|
||||||
assert.strictEqual(stderr, "Error parsing arguments for 'define': a-b\n");
|
assert.strictEqual(stderr, "ERROR: cannot parse arguments for 'define': a-b\n");
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -118,32 +118,17 @@ describe("sourcemaps", function() {
|
|||||||
assert.strictEqual(result.code + "\n", readFileSync("test/input/issue-520/output.js", "utf8"));
|
assert.strictEqual(result.code + "\n", readFileSync("test/input/issue-520/output.js", "utf8"));
|
||||||
});
|
});
|
||||||
it("Should warn for missing inline source map", function() {
|
it("Should warn for missing inline source map", function() {
|
||||||
var warn_function = UglifyJS.AST_Node.warn_function;
|
|
||||||
var warnings = [];
|
|
||||||
UglifyJS.AST_Node.warn_function = function(txt) {
|
|
||||||
warnings.push(txt);
|
|
||||||
};
|
|
||||||
try {
|
|
||||||
var result = UglifyJS.minify(read("./test/input/issue-1323/sample.js"), {
|
var result = UglifyJS.minify(read("./test/input/issue-1323/sample.js"), {
|
||||||
mangle: false,
|
mangle: false,
|
||||||
sourceMap: {
|
sourceMap: {
|
||||||
content: "inline"
|
content: "inline"
|
||||||
}
|
},
|
||||||
|
warnings: true,
|
||||||
});
|
});
|
||||||
assert.strictEqual(result.code, "var bar=function(bar){return bar};");
|
assert.strictEqual(result.code, "var bar=function(bar){return bar};");
|
||||||
assert.strictEqual(warnings.length, 1);
|
assert.deepEqual(result.warnings, [ "WARN: inline source map not found: 0" ]);
|
||||||
assert.strictEqual(warnings[0], "inline source map not found: 0");
|
|
||||||
} finally {
|
|
||||||
UglifyJS.AST_Node.warn_function = warn_function;
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
it("Should handle multiple input and inline source map", function() {
|
it("Should handle multiple input and inline source map", function() {
|
||||||
var warn_function = UglifyJS.AST_Node.warn_function;
|
|
||||||
var warnings = [];
|
|
||||||
UglifyJS.AST_Node.warn_function = function(txt) {
|
|
||||||
warnings.push(txt);
|
|
||||||
};
|
|
||||||
try {
|
|
||||||
var result = UglifyJS.minify([
|
var result = UglifyJS.minify([
|
||||||
read("./test/input/issue-520/input.js"),
|
read("./test/input/issue-520/input.js"),
|
||||||
read("./test/input/issue-1323/sample.js"),
|
read("./test/input/issue-1323/sample.js"),
|
||||||
@@ -151,18 +136,15 @@ describe("sourcemaps", function() {
|
|||||||
sourceMap: {
|
sourceMap: {
|
||||||
content: "inline",
|
content: "inline",
|
||||||
url: "inline",
|
url: "inline",
|
||||||
}
|
},
|
||||||
|
warnings: true,
|
||||||
});
|
});
|
||||||
if (result.error) throw result.error;
|
if (result.error) throw result.error;
|
||||||
assert.strictEqual(result.code, [
|
assert.strictEqual(result.code, [
|
||||||
"var Foo=function(){console.log(3)};new Foo;var bar=function(o){return o};",
|
"var Foo=function(){console.log(3)};new Foo;var bar=function(o){return o};",
|
||||||
"//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInN0ZGluIiwiMSJdLCJuYW1lcyI6WyJGb28iLCJjb25zb2xlIiwibG9nIiwiYmFyIl0sIm1hcHBpbmdzIjoiQUFBQSxJQUFNQSxJQUFJLFdBQWdCQyxRQUFRQyxJQUFJLElBQVMsSUFBSUYsSUNBbkQsSUFBSUcsSUFDQSxTQUFjQSxHQUNWLE9BQU9BIn0=",
|
"//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInN0ZGluIiwiMSJdLCJuYW1lcyI6WyJGb28iLCJjb25zb2xlIiwibG9nIiwiYmFyIl0sIm1hcHBpbmdzIjoiQUFBQSxJQUFNQSxJQUFJLFdBQWdCQyxRQUFRQyxJQUFJLElBQVMsSUFBSUYsSUNBbkQsSUFBSUcsSUFDQSxTQUFjQSxHQUNWLE9BQU9BIn0=",
|
||||||
].join("\n"));
|
].join("\n"));
|
||||||
assert.strictEqual(warnings.length, 1);
|
assert.deepEqual(result.warnings, [ "WARN: inline source map not found: 1" ]);
|
||||||
assert.strictEqual(warnings[0], "inline source map not found: 1");
|
|
||||||
} finally {
|
|
||||||
UglifyJS.AST_Node.warn_function = warn_function;
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
it("Should drop source contents for includeSources=false", function() {
|
it("Should drop source contents for includeSources=false", function() {
|
||||||
var result = UglifyJS.minify(read("./test/input/issue-520/input.js"), {
|
var result = UglifyJS.minify(read("./test/input/issue-520/input.js"), {
|
||||||
|
|||||||
@@ -231,16 +231,15 @@ function run_compress_tests() {
|
|||||||
});
|
});
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
var options = U.defaults(test.options, {
|
|
||||||
warnings: false
|
|
||||||
});
|
|
||||||
var warnings_emitted = [];
|
var warnings_emitted = [];
|
||||||
var original_warn_function = U.AST_Node.warn_function;
|
|
||||||
if (test.expect_warnings) {
|
if (test.expect_warnings) {
|
||||||
U.AST_Node.warn_function = function(text) {
|
var expected_warnings = make_code(test.expect_warnings, {
|
||||||
warnings_emitted.push("WARN: " + text);
|
beautify: false,
|
||||||
};
|
quote_style: 2, // force double quote to match JSON
|
||||||
if (!options.warnings) options.warnings = true;
|
});
|
||||||
|
U.AST_Node.log_function(function(text) {
|
||||||
|
warnings_emitted.push(text);
|
||||||
|
}, /"INFO: /.test(expected_warnings));
|
||||||
}
|
}
|
||||||
if (test.mangle && test.mangle.properties && test.mangle.properties.keep_quoted) {
|
if (test.mangle && test.mangle.properties && test.mangle.properties.keep_quoted) {
|
||||||
var quoted_props = test.mangle.properties.reserved;
|
var quoted_props = test.mangle.properties.reserved;
|
||||||
@@ -252,7 +251,7 @@ function run_compress_tests() {
|
|||||||
input.figure_out_scope(test.mangle);
|
input.figure_out_scope(test.mangle);
|
||||||
input.expand_names(test.mangle);
|
input.expand_names(test.mangle);
|
||||||
}
|
}
|
||||||
var cmp = new U.Compressor(options, true);
|
var cmp = new U.Compressor(test.options, true);
|
||||||
var output = cmp.compress(input);
|
var output = cmp.compress(input);
|
||||||
output.figure_out_scope(test.mangle);
|
output.figure_out_scope(test.mangle);
|
||||||
if (test.mangle) {
|
if (test.mangle) {
|
||||||
@@ -283,11 +282,6 @@ function run_compress_tests() {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (test.expect_warnings) {
|
if (test.expect_warnings) {
|
||||||
U.AST_Node.warn_function = original_warn_function;
|
|
||||||
var expected_warnings = make_code(test.expect_warnings, {
|
|
||||||
beautify: false,
|
|
||||||
quote_style: 2, // force double quote to match JSON
|
|
||||||
});
|
|
||||||
warnings_emitted = warnings_emitted.map(function(input) {
|
warnings_emitted = warnings_emitted.map(function(input) {
|
||||||
return input.split(process.cwd() + path.sep).join("").split(path.sep).join("/");
|
return input.split(process.cwd() + path.sep).join("").split(path.sep).join("/");
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -73,8 +73,10 @@ exports.run_code = function(code, reuse) {
|
|||||||
process.stdout.write = original_write;
|
process.stdout.write = original_write;
|
||||||
if (!reuse || code.indexOf(".prototype") >= 0) {
|
if (!reuse || code.indexOf(".prototype") >= 0) {
|
||||||
context = null;
|
context = null;
|
||||||
} else for (var key in context) {
|
} else {
|
||||||
delete context[key];
|
vm.runInContext(Object.keys(context).map(function(name) {
|
||||||
|
return "delete " + name;
|
||||||
|
}).join("\n"), context);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
1240
tools/domprops.json
1240
tools/domprops.json
File diff suppressed because it is too large
Load Diff
581
tools/props.html
581
tools/props.html
@@ -1,61 +1,540 @@
|
|||||||
|
<!doctype html>
|
||||||
<html>
|
<html>
|
||||||
<head>
|
|
||||||
</head>
|
|
||||||
<body>
|
<body>
|
||||||
<script>(function(){
|
<script>
|
||||||
var props = {};
|
!function() {
|
||||||
|
var names = [];
|
||||||
|
var scanned = [];
|
||||||
|
var to_scan = [];
|
||||||
|
|
||||||
function addObject(obj) {
|
function scan(obj) {
|
||||||
if (obj == null) return;
|
if (obj && typeof obj == "object" && !~scanned.indexOf(obj)) {
|
||||||
|
scanned.push(obj);
|
||||||
|
to_scan.push(obj);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
scan(self);
|
||||||
|
[
|
||||||
|
"a",
|
||||||
|
"abbr",
|
||||||
|
"acronym",
|
||||||
|
"address",
|
||||||
|
"applet",
|
||||||
|
"area",
|
||||||
|
"article",
|
||||||
|
"aside",
|
||||||
|
"audio",
|
||||||
|
"b",
|
||||||
|
"base",
|
||||||
|
"basefont",
|
||||||
|
"bdi",
|
||||||
|
"bdo",
|
||||||
|
"bgsound",
|
||||||
|
"big",
|
||||||
|
"blink",
|
||||||
|
"blockquote",
|
||||||
|
"body",
|
||||||
|
"br",
|
||||||
|
"button",
|
||||||
|
"canvas",
|
||||||
|
"caption",
|
||||||
|
"center",
|
||||||
|
"checked",
|
||||||
|
"cite",
|
||||||
|
"code",
|
||||||
|
"col",
|
||||||
|
"colgroup",
|
||||||
|
"command",
|
||||||
|
"comment",
|
||||||
|
"compact",
|
||||||
|
"content",
|
||||||
|
"data",
|
||||||
|
"datalist",
|
||||||
|
"dd",
|
||||||
|
"declare",
|
||||||
|
"defer",
|
||||||
|
"del",
|
||||||
|
"details",
|
||||||
|
"dfn",
|
||||||
|
"dialog",
|
||||||
|
"dir",
|
||||||
|
"disabled",
|
||||||
|
"div",
|
||||||
|
"dl",
|
||||||
|
"dt",
|
||||||
|
"element",
|
||||||
|
"em",
|
||||||
|
"embed",
|
||||||
|
"fieldset",
|
||||||
|
"figcaption",
|
||||||
|
"figure",
|
||||||
|
"font",
|
||||||
|
"footer",
|
||||||
|
"form",
|
||||||
|
"frame",
|
||||||
|
"frameset",
|
||||||
|
"h1",
|
||||||
|
"h2",
|
||||||
|
"h3",
|
||||||
|
"h4",
|
||||||
|
"h5",
|
||||||
|
"h6",
|
||||||
|
"head",
|
||||||
|
"header",
|
||||||
|
"hgroup",
|
||||||
|
"hr",
|
||||||
|
"html",
|
||||||
|
"i",
|
||||||
|
"iframe",
|
||||||
|
"image",
|
||||||
|
"img",
|
||||||
|
"input",
|
||||||
|
"ins",
|
||||||
|
"isindex",
|
||||||
|
"ismap",
|
||||||
|
"kbd",
|
||||||
|
"keygen",
|
||||||
|
"label",
|
||||||
|
"legend",
|
||||||
|
"li",
|
||||||
|
"link",
|
||||||
|
"listing",
|
||||||
|
"main",
|
||||||
|
"map",
|
||||||
|
"mark",
|
||||||
|
"marquee",
|
||||||
|
"math",
|
||||||
|
"menu",
|
||||||
|
"menuitem",
|
||||||
|
"meta",
|
||||||
|
"meter",
|
||||||
|
"multicol",
|
||||||
|
"multiple",
|
||||||
|
"nav",
|
||||||
|
"nobr",
|
||||||
|
"noembed",
|
||||||
|
"noframes",
|
||||||
|
"nohref",
|
||||||
|
"noresize",
|
||||||
|
"noscript",
|
||||||
|
"noshade",
|
||||||
|
"nowrap",
|
||||||
|
"object",
|
||||||
|
"ol",
|
||||||
|
"optgroup",
|
||||||
|
"option",
|
||||||
|
"output",
|
||||||
|
"p",
|
||||||
|
"param",
|
||||||
|
"picture",
|
||||||
|
"plaintext",
|
||||||
|
"pre",
|
||||||
|
"progress",
|
||||||
|
"q",
|
||||||
|
"rb",
|
||||||
|
"readonly",
|
||||||
|
"rp",
|
||||||
|
"rt",
|
||||||
|
"rtc",
|
||||||
|
"ruby",
|
||||||
|
"s",
|
||||||
|
"samp",
|
||||||
|
"script",
|
||||||
|
"section",
|
||||||
|
"select",
|
||||||
|
"selected",
|
||||||
|
"shadow",
|
||||||
|
"small",
|
||||||
|
"source",
|
||||||
|
"spacer",
|
||||||
|
"span",
|
||||||
|
"strike",
|
||||||
|
"strong",
|
||||||
|
"style",
|
||||||
|
"sub",
|
||||||
|
"summary",
|
||||||
|
"sup",
|
||||||
|
"svg",
|
||||||
|
"table",
|
||||||
|
"tbody",
|
||||||
|
"td",
|
||||||
|
"template",
|
||||||
|
"textarea",
|
||||||
|
"tfoot",
|
||||||
|
"th",
|
||||||
|
"thead",
|
||||||
|
"time",
|
||||||
|
"title",
|
||||||
|
"tr",
|
||||||
|
"track",
|
||||||
|
"tt",
|
||||||
|
"u",
|
||||||
|
"ul",
|
||||||
|
"var",
|
||||||
|
"video",
|
||||||
|
"wbr",
|
||||||
|
"xmp",
|
||||||
|
"XXX",
|
||||||
|
].forEach(function(tag) {
|
||||||
|
scan(document.createElement(tag));
|
||||||
|
});
|
||||||
|
[
|
||||||
|
"abort",
|
||||||
|
"absolutedeviceorientation",
|
||||||
|
"activate",
|
||||||
|
"active",
|
||||||
|
"addsourcebuffer",
|
||||||
|
"addstream",
|
||||||
|
"addtrack",
|
||||||
|
"afterprint",
|
||||||
|
"afterscriptexecute",
|
||||||
|
"afterupdate",
|
||||||
|
"animationcancel",
|
||||||
|
"animationend",
|
||||||
|
"animationiteration",
|
||||||
|
"animationstart",
|
||||||
|
"appinstalled",
|
||||||
|
"audioend",
|
||||||
|
"audioprocess",
|
||||||
|
"audiostart",
|
||||||
|
"autocomplete",
|
||||||
|
"autocompleteerror",
|
||||||
|
"auxclick",
|
||||||
|
"beforeactivate",
|
||||||
|
"beforecopy",
|
||||||
|
"beforecut",
|
||||||
|
"beforedeactivate",
|
||||||
|
"beforeeditfocus",
|
||||||
|
"beforeinstallprompt",
|
||||||
|
"beforepaste",
|
||||||
|
"beforeprint",
|
||||||
|
"beforescriptexecute",
|
||||||
|
"beforeunload",
|
||||||
|
"beforeupdate",
|
||||||
|
"blocked",
|
||||||
|
"blur",
|
||||||
|
"bounce",
|
||||||
|
"boundary",
|
||||||
|
"cached",
|
||||||
|
"cancel",
|
||||||
|
"candidatewindowhide",
|
||||||
|
"candidatewindowshow",
|
||||||
|
"candidatewindowupdate",
|
||||||
|
"canplay",
|
||||||
|
"canplaythrough",
|
||||||
|
"cellchange",
|
||||||
|
"change",
|
||||||
|
"chargingchange",
|
||||||
|
"chargingtimechange",
|
||||||
|
"checking",
|
||||||
|
"click",
|
||||||
|
"close",
|
||||||
|
"compassneedscalibration",
|
||||||
|
"complete",
|
||||||
|
"connect",
|
||||||
|
"connecting",
|
||||||
|
"connectionstatechange",
|
||||||
|
"contextmenu",
|
||||||
|
"controllerchange",
|
||||||
|
"controlselect",
|
||||||
|
"copy",
|
||||||
|
"cuechange",
|
||||||
|
"cut",
|
||||||
|
"dataavailable",
|
||||||
|
"datachannel",
|
||||||
|
"datasetchanged",
|
||||||
|
"datasetcomplete",
|
||||||
|
"dblclick",
|
||||||
|
"deactivate",
|
||||||
|
"devicechange",
|
||||||
|
"devicelight",
|
||||||
|
"devicemotion",
|
||||||
|
"deviceorientation",
|
||||||
|
"deviceorientationabsolute",
|
||||||
|
"deviceproximity",
|
||||||
|
"dischargingtimechange",
|
||||||
|
"disconnect",
|
||||||
|
"display",
|
||||||
|
"downloading",
|
||||||
|
"drag",
|
||||||
|
"dragend",
|
||||||
|
"dragenter",
|
||||||
|
"dragexit",
|
||||||
|
"dragleave",
|
||||||
|
"dragover",
|
||||||
|
"dragstart",
|
||||||
|
"drop",
|
||||||
|
"durationchange",
|
||||||
|
"emptied",
|
||||||
|
"encrypted",
|
||||||
|
"end",
|
||||||
|
"ended",
|
||||||
|
"enter",
|
||||||
|
"enterpictureinpicture",
|
||||||
|
"error",
|
||||||
|
"errorupdate",
|
||||||
|
"exit",
|
||||||
|
"filterchange",
|
||||||
|
"finish",
|
||||||
|
"focus",
|
||||||
|
"focusin",
|
||||||
|
"focusout",
|
||||||
|
"freeze",
|
||||||
|
"fullscreenchange",
|
||||||
|
"fullscreenerror",
|
||||||
|
"gesturechange",
|
||||||
|
"gestureend",
|
||||||
|
"gesturestart",
|
||||||
|
"gotpointercapture",
|
||||||
|
"hashchange",
|
||||||
|
"help",
|
||||||
|
"icecandidate",
|
||||||
|
"iceconnectionstatechange",
|
||||||
|
"icegatheringstatechange",
|
||||||
|
"inactive",
|
||||||
|
"input",
|
||||||
|
"invalid",
|
||||||
|
"keydown",
|
||||||
|
"keypress",
|
||||||
|
"keyup",
|
||||||
|
"languagechange",
|
||||||
|
"layoutcomplete",
|
||||||
|
"leavepictureinpicture",
|
||||||
|
"levelchange",
|
||||||
|
"load",
|
||||||
|
"loadeddata",
|
||||||
|
"loadedmetadata",
|
||||||
|
"loadend",
|
||||||
|
"loading",
|
||||||
|
"loadingdone",
|
||||||
|
"loadingerror",
|
||||||
|
"loadstart",
|
||||||
|
"losecapture",
|
||||||
|
"lostpointercapture",
|
||||||
|
"mark",
|
||||||
|
"message",
|
||||||
|
"messageerror",
|
||||||
|
"mousedown",
|
||||||
|
"mouseenter",
|
||||||
|
"mouseleave",
|
||||||
|
"mousemove",
|
||||||
|
"mouseout",
|
||||||
|
"mouseover",
|
||||||
|
"mouseup",
|
||||||
|
"mousewheel",
|
||||||
|
"move",
|
||||||
|
"moveend",
|
||||||
|
"movestart",
|
||||||
|
"mozfullscreenchange",
|
||||||
|
"mozfullscreenerror",
|
||||||
|
"mozorientationchange",
|
||||||
|
"mozpointerlockchange",
|
||||||
|
"mozpointerlockerror",
|
||||||
|
"mscontentzoom",
|
||||||
|
"msfullscreenchange",
|
||||||
|
"msfullscreenerror",
|
||||||
|
"msgesturechange",
|
||||||
|
"msgesturedoubletap",
|
||||||
|
"msgestureend",
|
||||||
|
"msgesturehold",
|
||||||
|
"msgesturestart",
|
||||||
|
"msgesturetap",
|
||||||
|
"msgotpointercapture",
|
||||||
|
"msinertiastart",
|
||||||
|
"mslostpointercapture",
|
||||||
|
"msmanipulationstatechanged",
|
||||||
|
"msneedkey",
|
||||||
|
"msorientationchange",
|
||||||
|
"mspointercancel",
|
||||||
|
"mspointerdown",
|
||||||
|
"mspointerenter",
|
||||||
|
"mspointerhover",
|
||||||
|
"mspointerleave",
|
||||||
|
"mspointermove",
|
||||||
|
"mspointerout",
|
||||||
|
"mspointerover",
|
||||||
|
"mspointerup",
|
||||||
|
"mssitemodejumplistitemremoved",
|
||||||
|
"msthumbnailclick",
|
||||||
|
"negotiationneeded",
|
||||||
|
"nomatch",
|
||||||
|
"noupdate",
|
||||||
|
"obsolete",
|
||||||
|
"offline",
|
||||||
|
"online",
|
||||||
|
"open",
|
||||||
|
"orientationchange",
|
||||||
|
"pagechange",
|
||||||
|
"pagehide",
|
||||||
|
"pageshow",
|
||||||
|
"paste",
|
||||||
|
"pause",
|
||||||
|
"play",
|
||||||
|
"playing",
|
||||||
|
"pluginstreamstart",
|
||||||
|
"pointercancel",
|
||||||
|
"pointerdown",
|
||||||
|
"pointerenter",
|
||||||
|
"pointerleave",
|
||||||
|
"pointerlockchange",
|
||||||
|
"pointerlockerror",
|
||||||
|
"pointermove",
|
||||||
|
"pointerout",
|
||||||
|
"pointerover",
|
||||||
|
"pointerup",
|
||||||
|
"popstate",
|
||||||
|
"progress",
|
||||||
|
"propertychange",
|
||||||
|
"ratechange",
|
||||||
|
"reading",
|
||||||
|
"readystatechange",
|
||||||
|
"rejectionhandled",
|
||||||
|
"removesourcebuffer",
|
||||||
|
"removestream",
|
||||||
|
"removetrack",
|
||||||
|
"reset",
|
||||||
|
"resize",
|
||||||
|
"resizeend",
|
||||||
|
"resizestart",
|
||||||
|
"resourcetimingbufferfull",
|
||||||
|
"result",
|
||||||
|
"resume",
|
||||||
|
"rowenter",
|
||||||
|
"rowexit",
|
||||||
|
"rowsdelete",
|
||||||
|
"rowsinserted",
|
||||||
|
"scroll",
|
||||||
|
"search",
|
||||||
|
"seeked",
|
||||||
|
"seeking",
|
||||||
|
"select",
|
||||||
|
"selectionchange",
|
||||||
|
"selectstart",
|
||||||
|
"show",
|
||||||
|
"signalingstatechange",
|
||||||
|
"soundend",
|
||||||
|
"soundstart",
|
||||||
|
"sourceclose",
|
||||||
|
"sourceclosed",
|
||||||
|
"sourceended",
|
||||||
|
"sourceopen",
|
||||||
|
"speechend",
|
||||||
|
"speechstart",
|
||||||
|
"stalled",
|
||||||
|
"start",
|
||||||
|
"statechange",
|
||||||
|
"stop",
|
||||||
|
"storage",
|
||||||
|
"storagecommit",
|
||||||
|
"submit",
|
||||||
|
"success",
|
||||||
|
"suspend",
|
||||||
|
"textinput",
|
||||||
|
"timeout",
|
||||||
|
"timeupdate",
|
||||||
|
"toggle",
|
||||||
|
"touchcancel",
|
||||||
|
"touchend",
|
||||||
|
"touchmove",
|
||||||
|
"touchstart",
|
||||||
|
"track",
|
||||||
|
"transitioncancel",
|
||||||
|
"transitionend",
|
||||||
|
"transitionrun",
|
||||||
|
"transitionstart",
|
||||||
|
"unhandledrejection",
|
||||||
|
"unload",
|
||||||
|
"updateready",
|
||||||
|
"upgradeneeded",
|
||||||
|
"userproximity",
|
||||||
|
"versionchange",
|
||||||
|
"visibilitychange",
|
||||||
|
"voiceschanged",
|
||||||
|
"volumechange",
|
||||||
|
"vrdisplayactivate",
|
||||||
|
"vrdisplayconnect",
|
||||||
|
"vrdisplaydeactivate",
|
||||||
|
"vrdisplaydisconnect",
|
||||||
|
"vrdisplaypresentchange",
|
||||||
|
"waiting",
|
||||||
|
"waitingforkey",
|
||||||
|
"warning",
|
||||||
|
"webkitanimationend",
|
||||||
|
"webkitanimationiteration",
|
||||||
|
"webkitanimationstart",
|
||||||
|
"webkitcurrentplaybacktargetiswirelesschanged",
|
||||||
|
"webkitfullscreenchange",
|
||||||
|
"webkitfullscreenerror",
|
||||||
|
"webkitkeyadded",
|
||||||
|
"webkitkeyerror",
|
||||||
|
"webkitkeymessage",
|
||||||
|
"webkitneedkey",
|
||||||
|
"webkitorientationchange",
|
||||||
|
"webkitplaybacktargetavailabilitychanged",
|
||||||
|
"webkitpointerlockchange",
|
||||||
|
"webkitpointerlockerror",
|
||||||
|
"webkitresourcetimingbufferfull",
|
||||||
|
"webkittransitionend",
|
||||||
|
"wheel",
|
||||||
|
"zoom",
|
||||||
|
].forEach(function(type) {
|
||||||
|
[
|
||||||
|
"beforeunloadevent",
|
||||||
|
"compositionevent",
|
||||||
|
"customevent",
|
||||||
|
"devicemotionevent",
|
||||||
|
"deviceorientationevent",
|
||||||
|
"dragevent",
|
||||||
|
"event",
|
||||||
|
"events",
|
||||||
|
"focusevent",
|
||||||
|
"hashchangeevent",
|
||||||
|
"htmlevents",
|
||||||
|
"keyboardevent",
|
||||||
|
"messageevent",
|
||||||
|
"mouseevent",
|
||||||
|
"mouseevents",
|
||||||
|
"storageevent",
|
||||||
|
"svgevents",
|
||||||
|
"textevent",
|
||||||
|
"touchevent",
|
||||||
|
"uievent",
|
||||||
|
"uievents",
|
||||||
|
].forEach(function(interface) {
|
||||||
try {
|
try {
|
||||||
Object.getOwnPropertyNames(obj).forEach(add);
|
var event = document.createEvent(interface);
|
||||||
} catch(ex) {}
|
event.initEvent(type, true, true);
|
||||||
if (obj.prototype) {
|
scan(event);
|
||||||
Object.getOwnPropertyNames(obj.prototype).forEach(add);
|
} catch (e) {}
|
||||||
}
|
});
|
||||||
if (typeof obj == "function") {
|
|
||||||
try {
|
|
||||||
Object.getOwnPropertyNames(new obj).forEach(add);
|
|
||||||
} catch(ex) {}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function add(name) {
|
|
||||||
props[name] = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
Object.getOwnPropertyNames(window).forEach(function(thing){
|
|
||||||
addObject(window[thing]);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
var obj;
|
||||||
|
while (obj = to_scan.shift()) {
|
||||||
|
var proto = obj;
|
||||||
|
do {
|
||||||
|
Object.getOwnPropertyNames(proto).forEach(function(name) {
|
||||||
|
var visited = ~names.indexOf(name);
|
||||||
|
if (!visited) names.push(name);
|
||||||
try {
|
try {
|
||||||
addObject(new Event("click"));
|
scan(obj[name]);
|
||||||
addObject(new Event("contextmenu"));
|
if (visited) return;
|
||||||
addObject(new Event("mouseup"));
|
if (/^create/.test(name)) {
|
||||||
addObject(new Event("mousedown"));
|
scan(obj[name]());
|
||||||
addObject(new Event("keydown"));
|
|
||||||
addObject(new Event("keypress"));
|
|
||||||
addObject(new Event("keyup"));
|
|
||||||
} catch(ex) {}
|
|
||||||
|
|
||||||
var ta = document.createElement("textarea");
|
|
||||||
ta.style.width = "100%";
|
|
||||||
ta.style.height = "20em";
|
|
||||||
ta.style.boxSizing = "border-box";
|
|
||||||
<!-- ta.value = Object.keys(props).sort(cmp).map(function(name){ -->
|
|
||||||
<!-- return JSON.stringify(name); -->
|
|
||||||
<!-- }).join(",\n"); -->
|
|
||||||
ta.value = JSON.stringify({
|
|
||||||
vars: [],
|
|
||||||
props: Object.keys(props).sort(cmp)
|
|
||||||
}, null, 2);
|
|
||||||
document.body.appendChild(ta);
|
|
||||||
|
|
||||||
function cmp(a, b) {
|
|
||||||
a = a.toLowerCase();
|
|
||||||
b = b.toLowerCase();
|
|
||||||
return a < b ? -1 : a > b ? 1 : 0;
|
|
||||||
}
|
}
|
||||||
})();</script>
|
if (/^[A-Z]/.test(name)) {
|
||||||
|
scan(new obj[name]());
|
||||||
|
}
|
||||||
|
} catch (e) {}
|
||||||
|
});
|
||||||
|
} while (proto = Object.getPrototypeOf(proto));
|
||||||
|
}
|
||||||
|
names.sort();
|
||||||
|
document.write('<pre>[\n "');
|
||||||
|
document.write(names.join('",\n "'));
|
||||||
|
document.write('"\n]</pre>');
|
||||||
|
}();
|
||||||
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
Reference in New Issue
Block a user