[inspector] honor order in console.table's filter argument
R=sigurds@chromium.org Bug: chromium:956475 Change-Id: Ie4ccd84e1c239d771fd9238599c687782ddb1356 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1776097 Reviewed-by: Simon Zünd <szuend@chromium.org> Reviewed-by: Sigurd Schneider <sigurds@chromium.org> Commit-Queue: Yang Guo <yangguo@chromium.org> Cr-Commit-Position: refs/heads/master@{#63505}
This commit is contained in:
parent
cbf56ee501
commit
0b403dcbec
@ -493,14 +493,18 @@ std::unique_ptr<protocol::Runtime::RemoteObject> InjectedScript::wrapTable(
|
||||
&limit, &limit, &preview);
|
||||
if (!preview) return nullptr;
|
||||
|
||||
std::unordered_set<String16> selectedColumns;
|
||||
std::vector<String16> selectedColumns;
|
||||
std::unordered_set<String16> columnSet;
|
||||
v8::Local<v8::Array> v8Columns;
|
||||
if (maybeColumns.ToLocal(&v8Columns)) {
|
||||
for (uint32_t i = 0; i < v8Columns->Length(); ++i) {
|
||||
v8::Local<v8::Value> column;
|
||||
if (v8Columns->Get(context, i).ToLocal(&column) && column->IsString()) {
|
||||
selectedColumns.insert(
|
||||
toProtocolString(isolate, column.As<v8::String>()));
|
||||
String16 name = toProtocolString(isolate, column.As<v8::String>());
|
||||
if (columnSet.find(name) == columnSet.end()) {
|
||||
columnSet.insert(name);
|
||||
selectedColumns.push_back(name);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -509,14 +513,18 @@ std::unique_ptr<protocol::Runtime::RemoteObject> InjectedScript::wrapTable(
|
||||
*preview->getProperties()) {
|
||||
ObjectPreview* columnPreview = column->getValuePreview(nullptr);
|
||||
if (!columnPreview) continue;
|
||||
|
||||
auto filtered = v8::base::make_unique<Array<PropertyPreview>>();
|
||||
// Use raw pointer here since the lifetime of each PropertyPreview is
|
||||
// ensured by columnPreview. This saves an additional clone.
|
||||
std::unordered_map<String16, PropertyPreview*> columnMap;
|
||||
for (const std::unique_ptr<PropertyPreview>& property :
|
||||
*columnPreview->getProperties()) {
|
||||
if (selectedColumns.find(property->getName()) !=
|
||||
selectedColumns.end()) {
|
||||
filtered->emplace_back(property->clone());
|
||||
if (columnSet.find(property->getName()) == columnSet.end()) continue;
|
||||
columnMap[property->getName()] = property.get();
|
||||
}
|
||||
auto filtered = v8::base::make_unique<Array<PropertyPreview>>();
|
||||
for (const String16& column : selectedColumns) {
|
||||
if (columnMap.find(column) == columnMap.end()) continue;
|
||||
filtered->push_back(columnMap[column]->clone());
|
||||
}
|
||||
columnPreview->setProperties(std::move(filtered));
|
||||
}
|
||||
|
@ -383,3 +383,97 @@ preview:
|
||||
type : object
|
||||
}
|
||||
|
||||
{
|
||||
description : Array(2)
|
||||
overflow : false
|
||||
properties : [
|
||||
[0] : {
|
||||
name : 0
|
||||
type : object
|
||||
value : Object
|
||||
valuePreview : {
|
||||
description : Object
|
||||
overflow : false
|
||||
properties : [
|
||||
[0] : {
|
||||
name : c
|
||||
type : number
|
||||
value : 3
|
||||
}
|
||||
[1] : {
|
||||
name : b
|
||||
type : number
|
||||
value : 2
|
||||
}
|
||||
]
|
||||
type : object
|
||||
}
|
||||
}
|
||||
[1] : {
|
||||
name : 1
|
||||
type : object
|
||||
value : Object
|
||||
valuePreview : {
|
||||
description : Object
|
||||
overflow : false
|
||||
properties : [
|
||||
[0] : {
|
||||
name : c
|
||||
type : number
|
||||
value : 3
|
||||
}
|
||||
]
|
||||
type : object
|
||||
}
|
||||
}
|
||||
]
|
||||
subtype : array
|
||||
type : object
|
||||
}
|
||||
{
|
||||
description : Array(2)
|
||||
overflow : false
|
||||
properties : [
|
||||
[0] : {
|
||||
name : 0
|
||||
type : object
|
||||
value : Object
|
||||
valuePreview : {
|
||||
description : Object
|
||||
overflow : false
|
||||
properties : [
|
||||
[0] : {
|
||||
name : c
|
||||
type : number
|
||||
value : 3
|
||||
}
|
||||
[1] : {
|
||||
name : b
|
||||
type : number
|
||||
value : 2
|
||||
}
|
||||
]
|
||||
type : object
|
||||
}
|
||||
}
|
||||
[1] : {
|
||||
name : 1
|
||||
type : object
|
||||
value : Object
|
||||
valuePreview : {
|
||||
description : Object
|
||||
overflow : false
|
||||
properties : [
|
||||
[0] : {
|
||||
name : c
|
||||
type : number
|
||||
value : 3
|
||||
}
|
||||
]
|
||||
type : object
|
||||
}
|
||||
}
|
||||
]
|
||||
subtype : array
|
||||
type : object
|
||||
}
|
||||
|
@ -65,6 +65,18 @@ const { session, contextGroup, Protocol } =
|
||||
console.table(bigTable);`
|
||||
});
|
||||
await waitConsoleAPICalledAndDump(true /* concise */);
|
||||
Protocol.Runtime.evaluate({
|
||||
expression: `var table = [{a:1, b:2, c:3}, {c:3}];
|
||||
var filter = ['c', 'b'];
|
||||
console.table(table, filter);`
|
||||
});
|
||||
await waitConsoleAPICalledAndDump();
|
||||
Protocol.Runtime.evaluate({
|
||||
expression: `var table = [{a:1, b:2, c:3}, {c:3}];
|
||||
var filter = ['c', 'b', 'c'];
|
||||
console.table(table, filter);`
|
||||
});
|
||||
await waitConsoleAPICalledAndDump();
|
||||
InspectorTest.completeTest();
|
||||
})()
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user