Commit fc2558d4 authored by Erik Luo's avatar Erik Luo Committed by Commit Bot

DevTools: improper console.table calls should have fallback

Before, console.table would print an empty message when it could not
produce a table. Now, it follows the spec, which says to fall back to
"logging the argument if it can’t be parsed as tabular".

https://console.spec.whatwg.org/#table

Bug: 895077
Change-Id: I2e9394127321307b2516050270be6cde2e45e7b3
Reviewed-on: https://chromium-review.googlesource.com/c/1327464Reviewed-by: default avatarAndrey Lushnikov <lushnikov@chromium.org>
Commit-Queue: Andrey Lushnikov <lushnikov@chromium.org>
Cr-Commit-Position: refs/heads/master@{#606718}
parent fbc399f3
Tests console.table. Tests console.table.
console-format-table.js:11 console-format-table.js:11 null
console-format-table.js:13 Array of arrays console-format-table.js:13 Array of arrays
HEADER (index) | 0 | 1 | 2 | HEADER (index) | 0 | 1 | 2 |
ROW 1 | 2 | 3 | ROW 1 | 2 | 3 |
...@@ -61,4 +61,6 @@ HEADER (index) | Value | 0 | ...@@ -61,4 +61,6 @@ HEADER (index) | Value | 0 |
ROW 1 | ROW 1 |
ROW "foo" | ROW "foo" |
ROW 2 | ROW 2 |
console-format-table.js:55 Non-standard call should use fallback
console-format-table.js:56 foo (3) [1, 2, 3]
...@@ -51,6 +51,9 @@ ...@@ -51,6 +51,9 @@
console.log("Deep and shallow array"); console.log("Deep and shallow array");
console.table([1, "foo", [2]]); console.table([1, "foo", [2]]);
console.log("Non-standard call should use fallback");
console.table("foo", [1,2,3]);
`); `);
ConsoleTestRunner.dumpConsoleMessages(); ConsoleTestRunner.dumpConsoleMessages();
......
...@@ -141,7 +141,7 @@ Console.ConsoleViewMessage = class { ...@@ -141,7 +141,7 @@ Console.ConsoleViewMessage = class {
if (table) if (table)
table = this._parameterToRemoteObject(table); table = this._parameterToRemoteObject(table);
if (!table || !table.preview) if (!table || !table.preview)
return formattedMessage; return this._buildMessage();
const rawValueColumnSymbol = Symbol('rawValueColumn'); const rawValueColumnSymbol = Symbol('rawValueColumn');
const columnNames = []; const columnNames = [];
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment