Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(680)

Unified Diff: Source/core/inspector/InjectedScriptSource.js

Issue 143263003: DevTools: Fix console.log for arrays in some corner cases. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: Source/core/inspector/InjectedScriptSource.js
diff --git a/Source/core/inspector/InjectedScriptSource.js b/Source/core/inspector/InjectedScriptSource.js
index f19222580644d20339a30fabdfe6b4d83301d94a..e63edab3f577d8fb751d991f9aef0ebfa039b8e3 100644
--- a/Source/core/inspector/InjectedScriptSource.js
+++ b/Source/core/inspector/InjectedScriptSource.js
@@ -110,6 +110,17 @@ function nullifyObjectProto(obj)
}
/**
+ * @param {string} name
+ * @return {boolean}
+ */
+function isArrayIndexPropertyName(name)
+{
+ // Array index check according to the ES5-15.4.
+ var index = name >>> 0;
+ return toString(index) === name && index !== 0xffffffff;
+}
+
+/**
* @constructor
*/
var InjectedScript = function()
@@ -1012,8 +1023,9 @@ InjectedScript.RemoteObject.prototype = {
descriptors.push(nameToDescriptors["#" + firstLevelKeys[i]]);
}
+ var isArray = (this.subtype === "array");
for (var i = 0; i < descriptors.length; ++i) {
- if (propertiesThreshold.indexes < 0 || propertiesThreshold.properties < 0)
+ if (propertiesThreshold.indexes < 0 && propertiesThreshold.properties < 0)
break;
var descriptor = descriptors[i];
@@ -1023,13 +1035,15 @@ InjectedScript.RemoteObject.prototype = {
preview.lossless = false;
continue;
}
- if (!descriptor.enumerable && !descriptor.isOwn)
- continue;
var name = descriptor.name;
if (name === "__proto__")
continue;
- if (this.subtype === "array" && name === "length")
+ if (isArray && name === "length")
+ continue;
+
+ var isArrayIndex = isArray && isArrayIndexPropertyName(name);
+ if (!descriptor.enumerable && !descriptor.isOwn && !isArrayIndex)
continue;
if (!("value" in descriptor)) {
@@ -1097,11 +1111,12 @@ InjectedScript.RemoteObject.prototype = {
*/
_appendPropertyPreview: function(preview, property, propertiesThreshold)
{
- if (toString(property.name >>> 0) === property.name)
- propertiesThreshold.indexes--;
+ var threshold;
+ if (isArrayIndexPropertyName(property.name))
+ threshold = --propertiesThreshold.indexes;
else
- propertiesThreshold.properties--;
- if (propertiesThreshold.indexes < 0 || propertiesThreshold.properties < 0) {
+ threshold = --propertiesThreshold.properties;
+ if (threshold < 0) {
preview.overflow = true;
preview.lossless = false;
} else {
« no previous file with comments | « LayoutTests/inspector/console/console-object-preview-expected.txt ('k') | Source/devtools/front_end/ConsoleMessage.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698