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

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 022f48c7ef07551db8550e64ccb369deb775f787..37932a8efd7c7cc0c4f860aabc6d3b086c524a70 100644
--- a/Source/core/inspector/InjectedScriptSource.js
+++ b/Source/core/inspector/InjectedScriptSource.js
@@ -98,6 +98,17 @@ function bind(func, thisObject, var_args)
}
/**
+ * @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()
@@ -996,7 +1007,7 @@ InjectedScript.RemoteObject.prototype = {
}
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];
@@ -1006,8 +1017,6 @@ InjectedScript.RemoteObject.prototype = {
preview.lossless = false;
continue;
}
- if (!descriptor.enumerable && !descriptor.isOwn)
- continue;
var name = descriptor.name;
if (name === "__proto__")
@@ -1015,6 +1024,10 @@ InjectedScript.RemoteObject.prototype = {
if (this.subtype === "array" && name === "length")
continue;
+ var isArrayIndex = (this.subtype === "array" && isArrayIndexPropertyName(name));
pfeldman 2014/01/23 16:19:02 Move subtype check to outside of the loop?
aandrey 2014/01/24 06:22:04 Done.
+ if (!descriptor.enumerable && !descriptor.isOwn && !isArrayIndex)
+ continue;
+
if (!("value" in descriptor)) {
preview.lossless = false;
this._appendPropertyPreview(preview, { name: name, type: "accessor" }, propertiesThreshold);
@@ -1080,11 +1093,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 {

Powered by Google App Engine
This is Rietveld 408576698