aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Lam S.L <alexlamsl@gmail.com>2017-03-26 18:18:44 +0800
committerGitHub <noreply@github.com>2017-03-26 18:18:44 +0800
commit00996afd2ce1f05fa973016e793495f69b524d5b (patch)
treec77ac1683f150261dc748dc08dd3669f03db6e7e
parente76fb354eb62d8e7b6968f1f77cfbb219814cea3 (diff)
downloadtracifyjs-00996afd2ce1f05fa973016e793495f69b524d5b.tar.gz
tracifyjs-00996afd2ce1f05fa973016e793495f69b524d5b.zip
ufuzz: workaround function name and toString() (#1688)
fixes #1686
-rw-r--r--test/ufuzz.js12
1 files changed, 11 insertions, 1 deletions
diff --git a/test/ufuzz.js b/test/ufuzz.js
index 49236253..491526d7 100644
--- a/test/ufuzz.js
+++ b/test/ufuzz.js
@@ -121,6 +121,8 @@ var TYPEOF_OUTCOMES = [
'symbol',
'crap' ];
+var FUNC_TOSTRING = 'Function.prototype.toString=function(){return"function(){}"};';
+
function run_code(code) {
var stdout = "";
var original_write = process.stdout.write;
@@ -128,7 +130,15 @@ function run_code(code) {
stdout += chunk;
};
try {
- new vm.Script(code).runInNewContext({ console: console }, { timeout: 5000 });
+ new vm.Script(FUNC_TOSTRING + code).runInNewContext({
+ console: {
+ log: function() {
+ return console.log.apply(console, [].map.call(arguments, function(arg) {
+ return typeof arg == "function" ? "[Function]" : arg;
+ }));
+ }
+ }
+ }, { timeout: 5000 });
return stdout;
} catch (ex) {
return ex;