From a758b40e3f92e54dbb806291fb1d3c38b5c0d336 Mon Sep 17 00:00:00 2001 From: "Alex Lam S.L" Date: Tue, 7 Jun 2022 16:28:06 +0100 Subject: [PATCH] suppress false positives in `ufuzz` (#5497) --- test/reduce.js | 7 ++++++- test/ufuzz/index.js | 33 ++++++++++++++++++++++++++++++--- 2 files changed, 36 insertions(+), 4 deletions(-) diff --git a/test/reduce.js b/test/reduce.js index 83c174b0..ed76beed 100644 --- a/test/reduce.js +++ b/test/reduce.js @@ -776,7 +776,12 @@ function compare_run_code(code, minify_options, result_cache, max_timeout) { }; function run(code, timeout) { - if (minify_options.module) code = "(async function(){\n" + code + "\n})();"; + if (minify_options.module) code = [ + '"use strict";', + "(async function(){", + code, + "})();" + ].join("\n"); return run_code(code, toplevel, result_cache, timeout); } } diff --git a/test/ufuzz/index.js b/test/ufuzz/index.js index b32cd81b..1a13c691 100644 --- a/test/ufuzz/index.js +++ b/test/ufuzz/index.js @@ -2102,7 +2102,12 @@ if (require.main !== module) { } function run_code(code, toplevel, timeout) { - if (async && has_await) code = "(async function(){\n" + code + "\n})();"; + if (async && has_await) code = [ + '"use strict";', + "(async function(){", + code, + "})();" + ].join("\n"); return sandbox.run_code(sandbox.patch_module_statements(code), toplevel, timeout); } @@ -2275,12 +2280,27 @@ function log(options) { } function sort_globals(code) { - var globals = run_code("throw Object.keys(this).sort(" + function(global) { + var injected = "throw Object.keys(this).sort(" + function(global) { return function(m, n) { return (typeof global[n] == "function") - (typeof global[m] == "function") || (m < n ? -1 : m > n ? 1 : 0); }; - } + "(this));\n" + code); + } + "(this));"; + var save_async = async; + if (async && has_await) { + async = false; + injected = [ + '"use strict";', + injected, + "(async function(){", + code, + "})();" + ].join("\n"); + } else { + injected += "\n" + code; + } + var globals = run_code(injected); + async = save_async; if (!Array.isArray(globals)) { errorln(); errorln(); @@ -2482,6 +2502,9 @@ var bug_class_static_await = SUPPORT.async && SUPPORT.class_field && sandbox.is_ var bug_class_static_nontrivial = SUPPORT.class_field && sandbox.is_error(sandbox.run_code("class A { static 42; static get 42() {} }")); var bug_for_of_async = SUPPORT.for_await_of && sandbox.is_error(sandbox.run_code("var async; for (async of []);")); var bug_for_of_var = SUPPORT.for_of && SUPPORT.let && sandbox.is_error(sandbox.run_code("try {} catch (e) { for (var e of []); }")); +var bug_proto_stream = function(ex) { + return ex.name == "TypeError" && ex.message == "callback is not a function"; +} if (SUPPORT.destructuring && sandbox.is_error(sandbox.run_code("console.log([ 1 ], {} = 2);"))) { beautify_options.output.v8 = true; minify_options.forEach(function(o) { @@ -2512,6 +2535,8 @@ for (var round = 1; round <= num_iterations; round++) { println(); // ignore v8 parser bug return bug_async_arrow_rest(result) + // ignore Node.js `__proto__` quirks + || bug_proto_stream(result) // ignore runtime platform bugs || result.message == "Script execution aborted."; })) continue; @@ -2533,6 +2558,8 @@ for (var round = 1; round <= num_iterations; round++) { var uglify_erred = sandbox.is_error(uglify_result); // ignore v8 parser bug if (!ok && uglify_erred && bug_async_arrow_rest(uglify_result)) ok = true; + // ignore Node.js `__proto__` quirks + if (!ok && uglify_erred && bug_proto_stream(uglify_result)) ok = true; // ignore runtime platform bugs if (!ok && uglify_erred && uglify_result.message == "Script execution aborted.") ok = true; // handle difference caused by time-outs