diff --git a/src/chrome/consoleHelper.ts b/src/chrome/consoleHelper.ts index a68f1573c..7483f6f3e 100644 --- a/src/chrome/consoleHelper.ts +++ b/src/chrome/consoleHelper.ts @@ -72,11 +72,14 @@ function resolveParams(m: Crdp.Runtime.ConsoleAPICalledEvent): string { formatted = Math.floor(+param.value); } else if (formatSpecifiers[i] === 'f') { formatted = +param.value; - } else if (['o', 'O', 'c'].indexOf(formatSpecifiers[i]) >= 0) { + } else if (formatSpecifiers[i] === 'c') { + // %c - Applies CSS color rules + // Could use terminal color codes in the future + formatted = ''; + } else if (['o', 'O'].indexOf(formatSpecifiers[i]) >= 0) { // Not supported - // %o - expandable DOM element // %O - expandable JS object - // %c - Applies CSS color rules formatted = param.value; } diff --git a/test/chrome/consoleHelper.test.ts b/test/chrome/consoleHelper.test.ts index 8fe4de52f..3970e4bbb 100644 --- a/test/chrome/consoleHelper.test.ts +++ b/test/chrome/consoleHelper.test.ts @@ -47,6 +47,10 @@ suite('ConsoleHelper', () => { doAssert(Runtime.makeLog('test', null, undefined), 'test null undefined'); }); + test('strips %c patterns', () => { + doAssert(Runtime.makeLog('foo %cbar', 'color: red'), 'foo bar'); + }); + test('network error - need Log domain'); test('objects- waiting on Microsoft/vscode-node-debug#4');