Commit 9c385e19 authored by aandrey@chromium.org's avatar aandrey@chromium.org

DevTools: Show internal properties in object preview in console.

BUG=380312
R=yurys, pfeldman@chromium.org, amikhaylova@google.com

Review URL: https://codereview.chromium.org/317703003

git-svn-id: svn://svn.chromium.org/blink/trunk@175789 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent e7cb864f
CONSOLE MESSAGE: line 11: [object Object]
CONSOLE MESSAGE: line 12: [object Object]
CONSOLE MESSAGE: line 11: CONSOLE MESSAGE: line 11:
CONSOLE MESSAGE: line 12: Symbol() CONSOLE MESSAGE: line 12: Symbol()
CONSOLE MESSAGE: line 11: CONSOLE MESSAGE: line 11:
...@@ -6,16 +8,20 @@ CONSOLE MESSAGE: line 11: [object Object] ...@@ -6,16 +8,20 @@ CONSOLE MESSAGE: line 11: [object Object]
CONSOLE MESSAGE: line 12: [object Object] CONSOLE MESSAGE: line 12: [object Object]
Tests that console properly displays information about ES6 features. Tests that console properly displays information about ES6 features.
Promise {[[PromiseStatus]]: "rejected", [[PromiseValue]]: -0} console-format-es6.html:11
[Promise]0: Promiselength: 1__proto__: Array[0] console-format-es6.html:12
globals[0]
Promise {[[PromiseStatus]]: "rejected", [[PromiseValue]]: -0}
Symbol() console-format-es6.html:11 Symbol() console-format-es6.html:11
[Symbol()]0: Symbol()length: 1__proto__: Array[0] console-format-es6.html:12 [Symbol()]0: Symbol()length: 1__proto__: Array[0] console-format-es6.html:12
globals[0] globals[1]
Symbol() Symbol()
Symbol(a) console-format-es6.html:11 Symbol(a) console-format-es6.html:11
[Symbol(a)]0: Symbol(a)length: 1__proto__: Array[0] console-format-es6.html:12 [Symbol(a)]0: Symbol(a)length: 1__proto__: Array[0] console-format-es6.html:12
globals[1] globals[2]
Symbol(a) Symbol(a)
Object {a: Symbol(), Symbol(): 1, Symbol(a): 2}Symbol(): 1Symbol(a): 2a: Symbol()__proto__: Object console-format-es6.html:11 Object {a: Symbol(), Symbol(): 1, Symbol(a): 2}Symbol(): 1Symbol(a): 2a: Symbol()__proto__: Object console-format-es6.html:11
[Object]0: Objectlength: 1__proto__: Array[0] console-format-es6.html:12 [Object]0: Objectlength: 1__proto__: Array[0] console-format-es6.html:12
globals[2] globals[3]
Object {a: Symbol(), Symbol(): 1, Symbol(a): 2}Symbol(): 1Symbol(a): 2a: Symbol()__proto__: Object Object {a: Symbol(), Symbol(): 1, Symbol(a): 2}Symbol(): 1Symbol(a): 2a: Symbol()__proto__: Object
...@@ -16,13 +16,13 @@ function onload() ...@@ -16,13 +16,13 @@ function onload()
{ {
var smb1 = Symbol(); var smb1 = Symbol();
var smb2 = Symbol("a"); var smb2 = Symbol("a");
var obj = new Object(); var obj = {};
obj[Symbol()] = 1; obj[Symbol()] = 1;
obj[smb2] = 2; obj[smb2] = 2;
obj["a"] = smb1; obj["a"] = smb1;
globals = [ globals = [
smb1, smb2, obj Promise.reject(-0), smb1, smb2, obj
]; ];
runTest(); runTest();
......
...@@ -74,6 +74,10 @@ CONSOLE MESSAGE: line 12: [object Object] ...@@ -74,6 +74,10 @@ CONSOLE MESSAGE: line 12: [object Object]
CONSOLE MESSAGE: line 13: [object Object] CONSOLE MESSAGE: line 13: [object Object]
CONSOLE MESSAGE: line 12: function () {} CONSOLE MESSAGE: line 12: function () {}
CONSOLE MESSAGE: line 13: function () {} CONSOLE MESSAGE: line 13: function () {}
CONSOLE MESSAGE: line 12: 42
CONSOLE MESSAGE: line 13: 42
CONSOLE MESSAGE: line 12: abc
CONSOLE MESSAGE: line 13: abc
Tests that console logging dumps proper messages. Tests that console logging dumps proper messages.
Array[10]0: "test"1: "test2"4: "test4"foo: Objectlength: 10__proto__: Array[0] console-format.html:26 Array[10]0: "test"1: "test2"4: "test4"foo: Objectlength: 10__proto__: Array[0] console-format.html:26
...@@ -214,4 +218,12 @@ function () {} console-format.html:12 ...@@ -214,4 +218,12 @@ function () {} console-format.html:12
[function]0: function () {}length: 1__proto__: Array[0] console-format.html:13 [function]0: function () {}length: 1__proto__: Array[0] console-format.html:13
globals[30] globals[30]
function () {} console-format.html:62 function () {} console-format.html:62
Number {[[PrimitiveValue]]: 42} console-format.html:12
[Number]0: Numberlength: 1__proto__: Array[0] console-format.html:13
globals[31]
Number {[[PrimitiveValue]]: 42}
String {0: "a", 1: "b", 2: "c", length: 3, [[PrimitiveValue]]: "abc"} console-format.html:12
[String]0: Stringlength: 1__proto__: Array[0] console-format.html:13
globals[32]
String {0: "a", 1: "b", 2: "c", length: 3, [[PrimitiveValue]]: "abc"}
...@@ -66,7 +66,8 @@ function onload() ...@@ -66,7 +66,8 @@ function onload()
regex1, regex2, str, str2, error, errorWithMessage, node, func, multilinefunc, num, linkify, regex1, regex2, str, str2, error, errorWithMessage, node, func, multilinefunc, num, linkify,
null, undefined, valuelessAttribute, valuedAttribute, existingAttribute, throwingLengthGetter, null, undefined, valuelessAttribute, valuedAttribute, existingAttribute, throwingLengthGetter,
NaN, Number.POSITIVE_INFINITY, Number.NEGATIVE_INFINITY, array, {}, [function() {}], bar, svg, NaN, Number.POSITIVE_INFINITY, Number.NEGATIVE_INFINITY, array, {}, [function() {}], bar, svg,
objectWithNonEnumerables, negZero, Object.create(null), Object, Object.prototype, arrayLikeFunction objectWithNonEnumerables, negZero, Object.create(null), Object, Object.prototype, arrayLikeFunction,
new Number(42), new String("abc")
]; ];
runTest(); runTest();
......
...@@ -1108,7 +1108,7 @@ InjectedScript.RemoteObject = function(object, objectGroupName, forceValueType, ...@@ -1108,7 +1108,7 @@ InjectedScript.RemoteObject = function(object, objectGroupName, forceValueType,
this.description = injectedScript._describe(object); this.description = injectedScript._describe(object);
if (generatePreview && (this.type === "object" || injectedScript._isHTMLAllCollection(object))) if (generatePreview && (this.type === "object" || injectedScript._isHTMLAllCollection(object)))
this.preview = this._generatePreview(object, undefined, columnNames, isTable, false); this.preview = this._generatePreview(object, undefined, columnNames, isTable);
} }
InjectedScript.RemoteObject.prototype = { InjectedScript.RemoteObject.prototype = {
...@@ -1117,10 +1117,9 @@ InjectedScript.RemoteObject.prototype = { ...@@ -1117,10 +1117,9 @@ InjectedScript.RemoteObject.prototype = {
* @param {?Array.<string>=} firstLevelKeys * @param {?Array.<string>=} firstLevelKeys
* @param {?Array.<string>=} secondLevelKeys * @param {?Array.<string>=} secondLevelKeys
* @param {boolean=} isTable * @param {boolean=} isTable
* @param {boolean=} isTableRow
* @return {!RuntimeAgent.ObjectPreview} preview * @return {!RuntimeAgent.ObjectPreview} preview
*/ */
_generatePreview: function(object, firstLevelKeys, secondLevelKeys, isTable, isTableRow) _generatePreview: function(object, firstLevelKeys, secondLevelKeys, isTable)
{ {
var preview = { __proto__: null }; var preview = { __proto__: null };
preview.lossless = true; preview.lossless = true;
...@@ -1130,8 +1129,8 @@ InjectedScript.RemoteObject.prototype = { ...@@ -1130,8 +1129,8 @@ InjectedScript.RemoteObject.prototype = {
var firstLevelKeysCount = firstLevelKeys ? firstLevelKeys.length : 0; var firstLevelKeysCount = firstLevelKeys ? firstLevelKeys.length : 0;
var propertiesThreshold = { var propertiesThreshold = {
properties: (isTable || isTableRow) ? 1000 : max(5, firstLevelKeysCount), properties: isTable ? 1000 : max(5, firstLevelKeysCount),
indexes: (isTable || isTableRow) ? 1000 : max(100, firstLevelKeysCount) indexes: isTable ? 1000 : max(100, firstLevelKeysCount)
}; };
try { try {
...@@ -1148,6 +1147,34 @@ InjectedScript.RemoteObject.prototype = { ...@@ -1148,6 +1147,34 @@ InjectedScript.RemoteObject.prototype = {
descriptors[i] = nameToDescriptors["#" + firstLevelKeys[i]]; descriptors[i] = nameToDescriptors["#" + firstLevelKeys[i]];
} }
this._appendPropertyDescriptors(preview, descriptors, propertiesThreshold, secondLevelKeys, isTable);
if (propertiesThreshold.indexes < 0 || propertiesThreshold.properties < 0)
return preview;
// Add internal properties to preview.
var internalProperties = InjectedScriptHost.getInternalProperties(object) || [];
for (var i = 0; i < internalProperties.length; ++i) {
internalProperties[i] = nullifyObjectProto(internalProperties[i]);
internalProperties[i].enumerable = true;
}
this._appendPropertyDescriptors(preview, internalProperties, propertiesThreshold, secondLevelKeys, isTable);
} catch (e) {
preview.lossless = false;
}
return preview;
},
/**
* @param {!RuntimeAgent.ObjectPreview} preview
* @param {!Array.<Object>} descriptors
* @param {!Object} propertiesThreshold
* @param {?Array.<string>=} secondLevelKeys
* @param {boolean=} isTable
*/
_appendPropertyDescriptors: function(preview, descriptors, propertiesThreshold, secondLevelKeys, isTable)
{
for (var i = 0; i < descriptors.length; ++i) { for (var i = 0; i < descriptors.length; ++i) {
if (propertiesThreshold.indexes < 0 || propertiesThreshold.properties < 0) if (propertiesThreshold.indexes < 0 || propertiesThreshold.properties < 0)
break; break;
...@@ -1197,7 +1224,7 @@ InjectedScript.RemoteObject.prototype = { ...@@ -1197,7 +1224,7 @@ InjectedScript.RemoteObject.prototype = {
} }
if (secondLevelKeys === null || secondLevelKeys) { if (secondLevelKeys === null || secondLevelKeys) {
var subPreview = this._generatePreview(value, secondLevelKeys || undefined, undefined, false, isTable); var subPreview = this._generatePreview(value, secondLevelKeys || undefined, undefined, isTable);
var property = { name: name, type: type, valuePreview: subPreview, __proto__: null }; var property = { name: name, type: type, valuePreview: subPreview, __proto__: null };
this._appendPropertyPreview(preview, property, propertiesThreshold); this._appendPropertyPreview(preview, property, propertiesThreshold);
if (!subPreview.lossless) if (!subPreview.lossless)
...@@ -1219,11 +1246,6 @@ InjectedScript.RemoteObject.prototype = { ...@@ -1219,11 +1246,6 @@ InjectedScript.RemoteObject.prototype = {
property.subtype = subtype; property.subtype = subtype;
this._appendPropertyPreview(preview, property, propertiesThreshold); this._appendPropertyPreview(preview, property, propertiesThreshold);
} }
} catch (e) {
preview.lossless = false;
}
return preview;
}, },
/** /**
......
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