diff --git a/test/common/chromium-cdp-driver.js b/test/common/chromium-cdp-driver.js index 1b5d9eb700fb..eecbfda906df 100755 --- a/test/common/chromium-cdp-driver.js +++ b/test/common/chromium-cdp-driver.js @@ -69,16 +69,20 @@ function clearExceptions() { } function stringifyConsoleArg(arg) { - if (arg.type === 'string') - return arg.value; - if (arg.type === 'object') { - const obj = {}; - arg.preview.properties.forEach(prop => { - obj[prop.name] = prop.value.toString(); - }); - return JSON.stringify(obj); + try { + if (arg.type === 'string') + return arg.value; + if (arg.type === 'object') { + const obj = {}; + arg.preview.properties.forEach(prop => { + obj[prop.name] = prop.value.toString(); + }); + return JSON.stringify(obj); + } + return JSON.stringify(arg); + } catch { + return "???"; } - return JSON.stringify(arg); } function setupLogging(client) {