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 12: Symbol()
CONSOLE MESSAGE: line 11:
......@@ -6,16 +8,20 @@ CONSOLE MESSAGE: line 11: [object Object]
CONSOLE MESSAGE: line 12: [object Object]
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()]0: Symbol()length: 1__proto__: Array[0] console-format-es6.html:12
globals[0]
globals[1]
Symbol()
Symbol(a) console-format-es6.html:11
[Symbol(a)]0: Symbol(a)length: 1__proto__: Array[0] console-format-es6.html:12
globals[1]
globals[2]
Symbol(a)
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
globals[2]
globals[3]
Object {a: Symbol(), Symbol(): 1, Symbol(a): 2}Symbol(): 1Symbol(a): 2a: Symbol()__proto__: Object
......@@ -16,13 +16,13 @@ function onload()
{
var smb1 = Symbol();
var smb2 = Symbol("a");
var obj = new Object();
var obj = {};
obj[Symbol()] = 1;
obj[smb2] = 2;
obj["a"] = smb1;
globals = [
smb1, smb2, obj
Promise.reject(-0), smb1, smb2, obj
];
runTest();
......
......@@ -74,6 +74,10 @@ CONSOLE MESSAGE: line 12: [object Object]
CONSOLE MESSAGE: line 13: [object Object]
CONSOLE MESSAGE: line 12: 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.
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
[function]0: function () {}length: 1__proto__: Array[0] console-format.html:13
globals[30]
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()
regex1, regex2, str, str2, error, errorWithMessage, node, func, multilinefunc, num, linkify,
null, undefined, valuelessAttribute, valuedAttribute, existingAttribute, throwingLengthGetter,
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();
......
......@@ -1108,7 +1108,7 @@ InjectedScript.RemoteObject = function(object, objectGroupName, forceValueType,
this.description = injectedScript._describe(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 = {
......@@ -1117,10 +1117,9 @@ InjectedScript.RemoteObject.prototype = {
* @param {?Array.<string>=} firstLevelKeys
* @param {?Array.<string>=} secondLevelKeys
* @param {boolean=} isTable
* @param {boolean=} isTableRow
* @return {!RuntimeAgent.ObjectPreview} preview
*/
_generatePreview: function(object, firstLevelKeys, secondLevelKeys, isTable, isTableRow)
_generatePreview: function(object, firstLevelKeys, secondLevelKeys, isTable)
{
var preview = { __proto__: null };
preview.lossless = true;
......@@ -1130,8 +1129,8 @@ InjectedScript.RemoteObject.prototype = {
var firstLevelKeysCount = firstLevelKeys ? firstLevelKeys.length : 0;
var propertiesThreshold = {
properties: (isTable || isTableRow) ? 1000 : max(5, firstLevelKeysCount),
indexes: (isTable || isTableRow) ? 1000 : max(100, firstLevelKeysCount)
properties: isTable ? 1000 : max(5, firstLevelKeysCount),
indexes: isTable ? 1000 : max(100, firstLevelKeysCount)
};
try {
......@@ -1148,82 +1147,105 @@ InjectedScript.RemoteObject.prototype = {
descriptors[i] = nameToDescriptors["#" + firstLevelKeys[i]];
}
for (var i = 0; i < descriptors.length; ++i) {
if (propertiesThreshold.indexes < 0 || propertiesThreshold.properties < 0)
break;
this._appendPropertyDescriptors(preview, descriptors, propertiesThreshold, secondLevelKeys, isTable);
if (propertiesThreshold.indexes < 0 || propertiesThreshold.properties < 0)
return preview;
var descriptor = descriptors[i];
if (!descriptor)
continue;
if (descriptor.wasThrown) {
preview.lossless = false;
continue;
}
if (!descriptor.enumerable && !descriptor.isOwn)
continue;
var name = descriptor.name;
if (name === "__proto__")
continue;
if (this.subtype === "array" && name === "length")
continue;
// 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);
if (!("value" in descriptor)) {
preview.lossless = false;
this._appendPropertyPreview(preview, { name: name, type: "accessor", __proto__: null }, propertiesThreshold);
continue;
}
} catch (e) {
preview.lossless = false;
}
var value = descriptor.value;
if (value === null) {
this._appendPropertyPreview(preview, { name: name, type: "object", value: "null", __proto__: null }, propertiesThreshold);
continue;
}
return preview;
},
const maxLength = 100;
var type = typeof value;
if (!descriptor.enumerable && type === "function")
continue;
if (type === "undefined" && injectedScript._isHTMLAllCollection(value))
type = "object";
/**
* @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) {
if (propertiesThreshold.indexes < 0 || propertiesThreshold.properties < 0)
break;
if (InjectedScript.primitiveTypes[type]) {
if (type === "string" && value.length > maxLength) {
value = this._abbreviateString(value, maxLength, true);
preview.lossless = false;
}
this._appendPropertyPreview(preview, { name: name, type: type, value: toStringDescription(value), __proto__: null }, propertiesThreshold);
continue;
}
var descriptor = descriptors[i];
if (!descriptor)
continue;
if (descriptor.wasThrown) {
preview.lossless = false;
continue;
}
if (!descriptor.enumerable && !descriptor.isOwn)
continue;
if (secondLevelKeys === null || secondLevelKeys) {
var subPreview = this._generatePreview(value, secondLevelKeys || undefined, undefined, false, isTable);
var property = { name: name, type: type, valuePreview: subPreview, __proto__: null };
this._appendPropertyPreview(preview, property, propertiesThreshold);
if (!subPreview.lossless)
preview.lossless = false;
if (subPreview.overflow)
preview.overflow = true;
continue;
}
var name = descriptor.name;
if (name === "__proto__")
continue;
if (this.subtype === "array" && name === "length")
continue;
if (!("value" in descriptor)) {
preview.lossless = false;
this._appendPropertyPreview(preview, { name: name, type: "accessor", __proto__: null }, propertiesThreshold);
continue;
}
var subtype = injectedScript._subtype(value);
var description = "";
if (type !== "function")
description = this._abbreviateString(/** @type {string} */ (injectedScript._describe(value)), maxLength, subtype === "regexp");
var value = descriptor.value;
if (value === null) {
this._appendPropertyPreview(preview, { name: name, type: "object", value: "null", __proto__: null }, propertiesThreshold);
continue;
}
var property = { name: name, type: type, value: description, __proto__: null };
if (subtype)
property.subtype = subtype;
const maxLength = 100;
var type = typeof value;
if (!descriptor.enumerable && type === "function")
continue;
if (type === "undefined" && injectedScript._isHTMLAllCollection(value))
type = "object";
if (InjectedScript.primitiveTypes[type]) {
if (type === "string" && value.length > maxLength) {
value = this._abbreviateString(value, maxLength, true);
preview.lossless = false;
}
this._appendPropertyPreview(preview, { name: name, type: type, value: toStringDescription(value), __proto__: null }, propertiesThreshold);
continue;
}
if (secondLevelKeys === null || secondLevelKeys) {
var subPreview = this._generatePreview(value, secondLevelKeys || undefined, undefined, isTable);
var property = { name: name, type: type, valuePreview: subPreview, __proto__: null };
this._appendPropertyPreview(preview, property, propertiesThreshold);
if (!subPreview.lossless)
preview.lossless = false;
if (subPreview.overflow)
preview.overflow = true;
continue;
}
} catch (e) {
preview.lossless = false;
}
return preview;
var subtype = injectedScript._subtype(value);
var description = "";
if (type !== "function")
description = this._abbreviateString(/** @type {string} */ (injectedScript._describe(value)), maxLength, subtype === "regexp");
var property = { name: name, type: type, value: description, __proto__: null };
if (subtype)
property.subtype = subtype;
this._appendPropertyPreview(preview, property, propertiesThreshold);
}
},
/**
......
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