Commit c7c19c86 authored by luoe's avatar luoe Committed by Commit bot

Show functions in object previews

Due to the isOwn check, functions inherited through prototype will not be
included in a preview.

BUG=645053

Review-Url: https://codereview.chromium.org/2554623003
Cr-Commit-Position: refs/heads/master@{#41566}
parent 80bcbccc
......@@ -946,10 +946,6 @@ InjectedScript.RemoteObject.prototype = {
var value = descriptor.value;
var type = typeof value;
// Never render functions in object preview.
if (type === "function" && (this.subtype !== "array" || !isUInt32(name)))
continue;
// Special-case HTMLAll.
if (type === "undefined" && injectedScript._isHTMLAllCollection(value))
type = "object";
......
......@@ -17,10 +17,15 @@ Running test: testObjectPropertiesPreview
}
[2] : {
name : p3
type : accessor
type : function
value :
}
[3] : {
name : p5
name : p4
type : accessor
}
[4] : {
name : p6
type : accessor
}
]
......@@ -29,7 +34,7 @@ Running test: testObjectPropertiesPreview
Running test: testArrayPropertiesPreview
{
description : Array(7)
description : Array(8)
overflow : false
properties : [
[0] : {
......@@ -45,13 +50,53 @@ Running test: testArrayPropertiesPreview
}
[2] : {
name : 4
type : accessor
type : function
value :
}
[3] : {
name : 6
name : nonEntryFunction
type : function
value :
}
[4] : {
name : 5
type : accessor
}
[5] : {
name : 7
type : accessor
}
]
subtype : array
type : object
}
Running test: testInheritingObjectPropertiesPreview
{
description : Object
overflow : false
properties : [
[0] : {
name : prototype
type : object
value : Object
}
]
type : object
}
Running test: testInheritingArrayPropertiesPreview
{
description : Array(0)
overflow : false
properties : [
[0] : {
name : prototype
subtype : array
type : object
value : Array(8)
}
]
subtype : array
type : object
}
......@@ -6,35 +6,43 @@ print("Tests that Runtime.evaluate will generate correct previews.");
InspectorTest.addScript(
`
var f1 = function(){};
Object.prototype[0] = 'default-first';
var obj = {p1: {a:1}, p2: {b:'foo'}};
var obj = {p1: {a:1}, p2: {b:'foo'}, p3: f1};
Object.defineProperties(obj, {
p3: {
p4: {
get() { return 2 }
},
p4: {
p5: {
set(x) { return x }
},
p5: {
p6: {
get() { return 2 },
set(x) { return x }
}
});
Array.prototype[0] = 'default-first';
var arr = [,, 1, [2]];
var arr = [,, 1, [2], f1];
Object.defineProperties(arr, {
4: {
5: {
get() { return 2 }
},
5: {
6: {
set(x) { return x }
},
6: {
7: {
get() { return 2 },
set(x) { return x }
}
});
arr.nonEntryFunction = f1;
var inheritingObj = {};
var inheritingArr = [];
inheritingObj.prototype = obj;
inheritingArr.prototype = arr;
`);
InspectorTest.runTestSuite([
......@@ -50,5 +58,19 @@ InspectorTest.runTestSuite([
Protocol.Runtime.evaluate({ "expression": "arr", "generatePreview": true })
.then(result => InspectorTest.logMessage(result.result.result.preview))
.then(next);
},
function testInheritingObjectPropertiesPreview(next)
{
Protocol.Runtime.evaluate({ "expression": "inheritingObj", "generatePreview": true })
.then(result => InspectorTest.logMessage(result.result.result.preview))
.then(next);
},
function testInheritingArrayPropertiesPreview(next)
{
Protocol.Runtime.evaluate({ "expression": "inheritingArr", "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