[inspector] restore console.table limits
`console.table` used to have a 1k limit on preview properties, which regressed to 100 during refactoring. This CL restores the 1k limit, and ensures that `buildEntryPreview` does not use the 1k limit. Bug: chromium:903623 Change-Id: I8fab3182a79d1bb6b662e2ff9b229db3d3a889ca Reviewed-on: https://chromium-review.googlesource.com/c/1332127 Reviewed-by: Dmitry Gozman <dgozman@chromium.org> Commit-Queue: Erik Luo <luoe@chromium.org> Cr-Commit-Position: refs/heads/master@{#57518}
This commit is contained in:
parent
fa306d4372
commit
b11cedb472
@ -448,8 +448,8 @@ std::unique_ptr<protocol::Runtime::RemoteObject> InjectedScript::wrapTable(
|
||||
|
||||
auto mirror = ValueMirror::create(context, table);
|
||||
std::unique_ptr<ObjectPreview> preview;
|
||||
int limit = 100;
|
||||
mirror->buildObjectPreview(context, true /* generatePreviewForProperties */,
|
||||
int limit = 1000;
|
||||
mirror->buildObjectPreview(context, true /* generatePreviewForTable */,
|
||||
&limit, &limit, &preview);
|
||||
|
||||
Array<PropertyPreview>* columns = preview->getProperties();
|
||||
|
@ -277,7 +277,7 @@ String16 descriptionForEntry(v8::Local<v8::Context> context,
|
||||
if (wrapper) {
|
||||
std::unique_ptr<ObjectPreview> preview;
|
||||
int limit = 5;
|
||||
wrapper->buildEntryPreview(context, false, &limit, &limit, &preview);
|
||||
wrapper->buildEntryPreview(context, &limit, &limit, &preview);
|
||||
if (preview) {
|
||||
key = preview->getDescription(String16());
|
||||
if (preview->getType() == RemoteObject::TypeEnum::String) {
|
||||
@ -294,7 +294,7 @@ String16 descriptionForEntry(v8::Local<v8::Context> context,
|
||||
if (wrapper) {
|
||||
std::unique_ptr<ObjectPreview> preview;
|
||||
int limit = 5;
|
||||
wrapper->buildEntryPreview(context, false, &limit, &limit, &preview);
|
||||
wrapper->buildEntryPreview(context, &limit, &limit, &preview);
|
||||
if (preview) {
|
||||
value = preview->getDescription(String16());
|
||||
if (preview->getType() == RemoteObject::TypeEnum::String) {
|
||||
@ -337,8 +337,7 @@ class PrimitiveValueMirror final : public ValueMirror {
|
||||
return Response::OK();
|
||||
}
|
||||
|
||||
void buildEntryPreview(v8::Local<v8::Context> context,
|
||||
bool generatePreviewForProperties, int* nameLimit,
|
||||
void buildEntryPreview(v8::Local<v8::Context> context, int* nameLimit,
|
||||
int* indexLimit,
|
||||
std::unique_ptr<ObjectPreview>* preview) override {
|
||||
*preview =
|
||||
@ -401,8 +400,7 @@ class NumberMirror final : public ValueMirror {
|
||||
.setValue(description(&unserializable))
|
||||
.build();
|
||||
}
|
||||
void buildEntryPreview(v8::Local<v8::Context> context,
|
||||
bool generatePreviewForProperties, int* nameLimit,
|
||||
void buildEntryPreview(v8::Local<v8::Context> context, int* nameLimit,
|
||||
int* indexLimit,
|
||||
std::unique_ptr<ObjectPreview>* preview) override {
|
||||
bool unserializable = false;
|
||||
@ -457,8 +455,7 @@ class BigIntMirror final : public ValueMirror {
|
||||
}
|
||||
|
||||
void buildEntryPreview(
|
||||
v8::Local<v8::Context> context, bool generatePreviewForProperties,
|
||||
int* nameLimit, int* indexLimit,
|
||||
v8::Local<v8::Context> context, int* nameLimit, int* indexLimit,
|
||||
std::unique_ptr<protocol::Runtime::ObjectPreview>* preview) override {
|
||||
*preview = ObjectPreview::create()
|
||||
.setType(RemoteObject::TypeEnum::Bigint)
|
||||
@ -611,8 +608,7 @@ class FunctionMirror final : public ValueMirror {
|
||||
.setValue(String16())
|
||||
.build();
|
||||
}
|
||||
void buildEntryPreview(v8::Local<v8::Context> context,
|
||||
bool generatePreviewForProperties, int* nameLimit,
|
||||
void buildEntryPreview(v8::Local<v8::Context> context, int* nameLimit,
|
||||
int* indexLimit,
|
||||
std::unique_ptr<ObjectPreview>* preview) override {
|
||||
*preview = ObjectPreview::create()
|
||||
@ -845,20 +841,19 @@ class ObjectMirror final : public ValueMirror {
|
||||
}
|
||||
|
||||
void buildObjectPreview(v8::Local<v8::Context> context,
|
||||
bool generatePreviewForProperties, int* nameLimit,
|
||||
bool generatePreviewForTable, int* nameLimit,
|
||||
int* indexLimit,
|
||||
std::unique_ptr<ObjectPreview>* result) override {
|
||||
buildObjectPreviewInternal(context, false /* forEntry */,
|
||||
generatePreviewForProperties, nameLimit,
|
||||
indexLimit, result);
|
||||
generatePreviewForTable, nameLimit, indexLimit,
|
||||
result);
|
||||
}
|
||||
|
||||
void buildEntryPreview(v8::Local<v8::Context> context,
|
||||
bool generatePreviewForProperties, int* nameLimit,
|
||||
void buildEntryPreview(v8::Local<v8::Context> context, int* nameLimit,
|
||||
int* indexLimit,
|
||||
std::unique_ptr<ObjectPreview>* result) override {
|
||||
buildObjectPreviewInternal(context, true /* forEntry */,
|
||||
generatePreviewForProperties, nameLimit,
|
||||
false /* generatePreviewForTable */, nameLimit,
|
||||
indexLimit, result);
|
||||
}
|
||||
|
||||
@ -878,8 +873,8 @@ class ObjectMirror final : public ValueMirror {
|
||||
|
||||
private:
|
||||
void buildObjectPreviewInternal(v8::Local<v8::Context> context, bool forEntry,
|
||||
bool generatePreviewForProperties,
|
||||
int* nameLimit, int* indexLimit,
|
||||
bool generatePreviewForTable, int* nameLimit,
|
||||
int* indexLimit,
|
||||
std::unique_ptr<ObjectPreview>* result) {
|
||||
std::unique_ptr<protocol::Array<PropertyPreview>> properties =
|
||||
protocol::Array<PropertyPreview>::create();
|
||||
@ -911,9 +906,10 @@ class ObjectMirror final : public ValueMirror {
|
||||
if (mirrors[i].value) {
|
||||
mirrors[i].value->buildPropertyPreview(context, mirrors[i].name,
|
||||
&preview);
|
||||
if (generatePreviewForProperties) {
|
||||
mirrors[i].value->buildObjectPreview(context, false, nameLimit,
|
||||
indexLimit, &valuePreview);
|
||||
if (generatePreviewForTable) {
|
||||
int tableLimit = 1000;
|
||||
mirrors[i].value->buildObjectPreview(context, false, &tableLimit,
|
||||
&tableLimit, &valuePreview);
|
||||
}
|
||||
} else {
|
||||
preview = PropertyPreview::create()
|
||||
@ -937,15 +933,13 @@ class ObjectMirror final : public ValueMirror {
|
||||
entriesPreview = protocol::Array<EntryPreview>::create();
|
||||
for (const auto& entry : entries) {
|
||||
std::unique_ptr<ObjectPreview> valuePreview;
|
||||
entry.value->buildEntryPreview(
|
||||
context, generatePreviewForProperties, nameLimit, indexLimit,
|
||||
&valuePreview);
|
||||
entry.value->buildEntryPreview(context, nameLimit, indexLimit,
|
||||
&valuePreview);
|
||||
if (!valuePreview) continue;
|
||||
std::unique_ptr<ObjectPreview> keyPreview;
|
||||
if (entry.key) {
|
||||
entry.key->buildEntryPreview(context,
|
||||
generatePreviewForProperties,
|
||||
nameLimit, indexLimit, &keyPreview);
|
||||
entry.key->buildEntryPreview(context, nameLimit, indexLimit,
|
||||
&keyPreview);
|
||||
if (!keyPreview) continue;
|
||||
}
|
||||
std::unique_ptr<EntryPreview> entryPreview =
|
||||
|
@ -52,12 +52,11 @@ class ValueMirror {
|
||||
v8::Local<v8::Context> context, const String16& name,
|
||||
std::unique_ptr<protocol::Runtime::PropertyPreview>*) {}
|
||||
virtual void buildObjectPreview(
|
||||
v8::Local<v8::Context> context, bool generatePreviewForProperties,
|
||||
v8::Local<v8::Context> context, bool generatePreviewForTable,
|
||||
int* nameLimit, int* indexLimit,
|
||||
std::unique_ptr<protocol::Runtime::ObjectPreview>*) {}
|
||||
virtual void buildEntryPreview(
|
||||
v8::Local<v8::Context> context, bool generatePreviewForProperties,
|
||||
int* nameLimit, int* indexLimit,
|
||||
v8::Local<v8::Context> context, int* nameLimit, int* indexLimit,
|
||||
std::unique_ptr<protocol::Runtime::ObjectPreview>*) {}
|
||||
virtual v8::Local<v8::Value> v8Value() = 0;
|
||||
|
||||
|
@ -325,3 +325,61 @@ console.table
|
||||
subtype : array
|
||||
type : object
|
||||
}
|
||||
last value property:
|
||||
{
|
||||
name : 1
|
||||
type : string
|
||||
value : b
|
||||
}
|
||||
last property:
|
||||
{
|
||||
name : 998
|
||||
subtype : array
|
||||
type : object
|
||||
value : Array(2)
|
||||
valuePreview : {
|
||||
description : Array(2)
|
||||
overflow : false
|
||||
properties : <ValuePreviewPropertiesArray(2)>
|
||||
subtype : array
|
||||
type : object
|
||||
}
|
||||
}
|
||||
preview:
|
||||
{
|
||||
description : Array(999)
|
||||
overflow : false
|
||||
properties : <PropertiesArray(999)>
|
||||
subtype : array
|
||||
type : object
|
||||
}
|
||||
|
||||
last value property:
|
||||
{
|
||||
name : 1
|
||||
type : string
|
||||
value : b
|
||||
}
|
||||
last property:
|
||||
{
|
||||
name : 999
|
||||
subtype : array
|
||||
type : object
|
||||
value : Array(2)
|
||||
valuePreview : {
|
||||
description : Array(2)
|
||||
overflow : false
|
||||
properties : <ValuePreviewPropertiesArray(2)>
|
||||
subtype : array
|
||||
type : object
|
||||
}
|
||||
}
|
||||
preview:
|
||||
{
|
||||
description : Array(1001)
|
||||
overflow : true
|
||||
properties : <PropertiesArray(1000)>
|
||||
subtype : array
|
||||
type : object
|
||||
}
|
||||
|
||||
|
@ -53,12 +53,50 @@ const { session, contextGroup, Protocol } =
|
||||
expression: `console.table([john, jane, emily], ['firstName'])`
|
||||
});
|
||||
await waitConsoleAPICalledAndDump();
|
||||
Protocol.Runtime.evaluate({
|
||||
expression: `var bigTable = new Array(999);
|
||||
bigTable.fill(['a', 'b']);
|
||||
console.table(bigTable);`
|
||||
});
|
||||
await waitConsoleAPICalledAndDump(true /* concise */);
|
||||
Protocol.Runtime.evaluate({
|
||||
expression: `var bigTable = new Array(1001);
|
||||
bigTable.fill(['a', 'b']);
|
||||
console.table(bigTable);`
|
||||
});
|
||||
await waitConsoleAPICalledAndDump(true /* concise */);
|
||||
InspectorTest.completeTest();
|
||||
})()
|
||||
|
||||
async function waitConsoleAPICalledAndDump() {
|
||||
/**
|
||||
* @param {boolean=} concise
|
||||
*/
|
||||
async function waitConsoleAPICalledAndDump(concise) {
|
||||
const { params : {
|
||||
args: [ arg ]
|
||||
} } = await Protocol.Runtime.onceConsoleAPICalled();
|
||||
InspectorTest.logMessage(arg.preview);
|
||||
const preview = arg.preview;
|
||||
if (concise)
|
||||
simplifyAndPrintLast(preview);
|
||||
else
|
||||
InspectorTest.logMessage(arg.preview);
|
||||
|
||||
function simplifyAndPrintLast(preview) {
|
||||
if (!Array.isArray(preview.properties))
|
||||
return;
|
||||
const properties = preview.properties;
|
||||
const lastProperty = properties[properties.length - 1];
|
||||
if (lastProperty.valuePreview && lastProperty.valuePreview.properties) {
|
||||
const innerProperties = lastProperty.valuePreview.properties;
|
||||
InspectorTest.logMessage(`last value property:`);
|
||||
InspectorTest.logMessage(innerProperties[innerProperties.length - 1]);
|
||||
lastProperty.valuePreview.properties = `<ValuePreviewPropertiesArray(${innerProperties.length})>`;
|
||||
}
|
||||
InspectorTest.logMessage(`last property:`);
|
||||
InspectorTest.logMessage(lastProperty);
|
||||
preview.properties = `<PropertiesArray(${properties.length})>`;
|
||||
InspectorTest.logMessage(`preview:`);
|
||||
InspectorTest.logMessage(preview);
|
||||
InspectorTest.logMessage(``);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user