Commit 80bcbccc authored by luoe's avatar luoe Committed by Commit bot

Add getter properties to array entry previews

Getter properties are not currently included in the protocol's
Runtime.ObjectPreview. DevTools currently shows getter properties
when evaluating arrays in the console, and this CL brings them into
the preview generated for RemoteObjects.

Corresponding DevTools CL: https://codereview.chromium.org/2521513006/

BUG=666882

Review-Url: https://codereview.chromium.org/2508423002
Cr-Commit-Position: refs/heads/master@{#41565}
parent 87b84a34
......@@ -936,9 +936,12 @@ InjectedScript.RemoteObject.prototype = {
if (!descriptor.isOwn)
continue;
// Ignore computed properties.
if (!("value" in descriptor))
// Ignore computed properties unless they have getters.
if (!("value" in descriptor)) {
if (descriptor.get)
this._appendPropertyPreview(preview, { name: name, type: "accessor", __proto__: null }, propertiesThreshold);
continue;
}
var value = descriptor.value;
var type = typeof value;
......
Tests that Runtime.evaluate will generate correct previews.
Running test: testObjectPropertiesPreview
{
description : Object
overflow : false
properties : [
[0] : {
name : p1
type : object
value : Object
}
[1] : {
name : p2
type : object
value : Object
}
[2] : {
name : p3
type : accessor
}
[3] : {
name : p5
type : accessor
}
]
type : object
}
Running test: testArrayPropertiesPreview
{
description : Array(7)
overflow : false
properties : [
[0] : {
name : 2
type : number
value : 1
}
[1] : {
name : 3
subtype : array
type : object
value : Array(1)
}
[2] : {
name : 4
type : accessor
}
[3] : {
name : 6
type : accessor
}
]
subtype : array
type : object
}
// Copyright 2016 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
print("Tests that Runtime.evaluate will generate correct previews.");
InspectorTest.addScript(
`
Object.prototype[0] = 'default-first';
var obj = {p1: {a:1}, p2: {b:'foo'}};
Object.defineProperties(obj, {
p3: {
get() { return 2 }
},
p4: {
set(x) { return x }
},
p5: {
get() { return 2 },
set(x) { return x }
}
});
Array.prototype[0] = 'default-first';
var arr = [,, 1, [2]];
Object.defineProperties(arr, {
4: {
get() { return 2 }
},
5: {
set(x) { return x }
},
6: {
get() { return 2 },
set(x) { return x }
}
});
`);
InspectorTest.runTestSuite([
function testObjectPropertiesPreview(next)
{
Protocol.Runtime.evaluate({ "expression": "obj", "generatePreview": true })
.then(result => InspectorTest.logMessage(result.result.result.preview))
.then(next);
},
function testArrayPropertiesPreview(next)
{
Protocol.Runtime.evaluate({ "expression": "arr", "generatePreview": true })
.then(result => InspectorTest.logMessage(result.result.result.preview))
.then(next);
}
]);
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