From e8db526f513ba324535fff040d651d4faacd89ae Mon Sep 17 00:00:00 2001 From: "Alex Lam S.L" Date: Tue, 18 Aug 2020 23:14:41 +0100 Subject: avoid setters during `console.log()` in sandbox (#4055) fixes #4054 --- test/compress/sandbox.js | 18 ++++++++++++++++++ test/sandbox.js | 2 +- 2 files changed, 19 insertions(+), 1 deletion(-) 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; -- cgit v1.2.3