[inspector] console.table should not crash on empty preview

Types such as "function" have a ValueMirror that does not override
"buildObjectPreview()". This CL updates clients to check that the
preview was actually built after call it.

Bug: chromium:907400
Change-Id: Id569c98363d47b259a40790b596efedb3d14abc2
Reviewed-on: https://chromium-review.googlesource.com/c/1347067
Reviewed-by: Dmitry Gozman <dgozman@chromium.org>
Commit-Queue: Erik Luo <luoe@chromium.org>
Cr-Commit-Position: refs/heads/master@{#57703}
This commit is contained in:
Erik Luo 2018-11-21 11:49:06 -08:00 committed by Commit Bot
parent ad0afdae9f
commit 54f92d52c6
3 changed files with 169 additions and 0 deletions

View File

@ -451,6 +451,7 @@ std::unique_ptr<protocol::Runtime::RemoteObject> InjectedScript::wrapTable(
int limit = 1000;
mirror->buildObjectPreview(context, true /* generatePreviewForTable */,
&limit, &limit, &preview);
if (!preview) return nullptr;
Array<PropertyPreview>* columns = preview->getProperties();
std::unordered_set<String16> selectedColumns;

View File

@ -953,3 +953,166 @@ Checks console methods
type : warning
}
}
{
method : Runtime.consoleAPICalled
params : {
args : [
[0] : {
type : string
value : foo
}
]
executionContextId : <executionContextId>
stackTrace : {
callFrames : [
[0] : {
columnNumber : 10
functionName : testFunction
lineNumber : 41
scriptId : <scriptId>
url : test.js
}
[1] : {
columnNumber : 0
functionName :
lineNumber : 0
scriptId : <scriptId>
url :
}
]
}
timestamp : <timestamp>
type : table
}
}
{
method : Runtime.consoleAPICalled
params : {
args : [
[0] : {
description : 2
type : number
value : 2
}
]
executionContextId : <executionContextId>
stackTrace : {
callFrames : [
[0] : {
columnNumber : 10
functionName : testFunction
lineNumber : 42
scriptId : <scriptId>
url : test.js
}
[1] : {
columnNumber : 0
functionName :
lineNumber : 0
scriptId : <scriptId>
url :
}
]
}
timestamp : <timestamp>
type : table
}
}
{
method : Runtime.consoleAPICalled
params : {
args : [
[0] : {
description : 2n
type : bigint
unserializableValue : 2n
}
]
executionContextId : <executionContextId>
stackTrace : {
callFrames : [
[0] : {
columnNumber : 10
functionName : testFunction
lineNumber : 43
scriptId : <scriptId>
url : test.js
}
[1] : {
columnNumber : 0
functionName :
lineNumber : 0
scriptId : <scriptId>
url :
}
]
}
timestamp : <timestamp>
type : table
}
}
{
method : Runtime.consoleAPICalled
params : {
args : [
[0] : {
description : Symbol(foo)
objectId : <objectId>
type : symbol
}
]
executionContextId : <executionContextId>
stackTrace : {
callFrames : [
[0] : {
columnNumber : 10
functionName : testFunction
lineNumber : 44
scriptId : <scriptId>
url : test.js
}
[1] : {
columnNumber : 0
functionName :
lineNumber : 0
scriptId : <scriptId>
url :
}
]
}
timestamp : <timestamp>
type : table
}
}
{
method : Runtime.consoleAPICalled
params : {
args : [
[0] : {
type : string
value : function() {}
}
]
executionContextId : <executionContextId>
stackTrace : {
callFrames : [
[0] : {
columnNumber : 10
functionName : testFunction
lineNumber : 45
scriptId : <scriptId>
url : test.js
}
[1] : {
columnNumber : 0
functionName :
lineNumber : 0
scriptId : <scriptId>
url :
}
]
}
timestamp : <timestamp>
type : table
}
}

View File

@ -39,6 +39,11 @@ function testFunction() {
console.countReset('default');
console.count();
console.countReset('countReset');
console.table('foo');
console.table(2);
console.table(2n);
console.table(Symbol('foo'));
console.table(function() {});
}
//# sourceURL=test.js`, 7, 26);