aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Lam S.L <alexlamsl@gmail.com>2020-08-18 23:14:41 +0100
committerGitHub <noreply@github.com>2020-08-19 06:14:41 +0800
commite8db526f513ba324535fff040d651d4faacd89ae (patch)
treecf3cbd49f37c85a8c649fdcaa9265dadceb7f543
parentfa13ed439138f9652ccb045e04965d336de0fd70 (diff)
downloadtracifyjs-e8db526f513ba324535fff040d651d4faacd89ae.tar.gz
tracifyjs-e8db526f513ba324535fff040d651d4faacd89ae.zip
avoid setters during `console.log()` in sandbox (#4055)
fixes #4054
-rw-r--r--test/compress/sandbox.js18
-rw-r--r--test/sandbox.js2
2 files changed, 19 insertions, 1 deletions
diff --git a/test/compress/sandbox.js b/test/compress/sandbox.js
index 02097c1e..9356f6f3 100644
--- a/test/compress/sandbox.js
+++ b/test/compress/sandbox.js
@@ -80,3 +80,21 @@ log_global: {
}
expect_stdout: "[object global]"
}
+
+issue_4054: {
+ input: {
+ console.log({
+ set p(v) {
+ throw "FAIL";
+ },
+ });
+ }
+ expect: {
+ console.log({
+ set p(v) {
+ throw "FAIL";
+ },
+ });
+ }
+ expect_stdout: "{ p: [Setter] }"
+}
diff --git a/test/sandbox.js b/test/sandbox.js
index 2f9ec677..c1575783 100644
--- a/test/sandbox.js
+++ b/test/sandbox.js
@@ -40,7 +40,7 @@ function createContext() {
arg.constructor.toString();
if (level--) for (var key in arg) {
var desc = Object.getOwnPropertyDescriptor(arg, key);
- if (!desc || !desc.get) arg[key] = safe_log(arg[key], level);
+ if (!desc || !desc.get && !desc.set) arg[key] = safe_log(arg[key], level);
}
}
return arg;