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

Unified Diff: Source/devtools/front_end/console/ConsoleViewMessage.js

Issue 844563003: DevTools: Fix console not showing array items inherited from prototype. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 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
« no previous file with comments | « Source/core/inspector/InjectedScriptSource.js ('k') | Source/devtools/front_end/sdk/RemoteObject.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/devtools/front_end/console/ConsoleViewMessage.js
diff --git a/Source/devtools/front_end/console/ConsoleViewMessage.js b/Source/devtools/front_end/console/ConsoleViewMessage.js
index 2b79ff628cc2d5f5ebdb7a518e722ac50cc75ad3..d07b7578c76fd977f07e997c723a195d8879707d 100644
--- a/Source/devtools/front_end/console/ConsoleViewMessage.js
+++ b/Source/devtools/front_end/console/ConsoleViewMessage.js
@@ -517,14 +517,44 @@ WebInspector.ConsoleViewMessage.prototype = {
_appendPropertiesPreview: function(parentElement, preview, object)
{
var isArray = preview.subtype === "array";
+ var arrayLength = WebInspector.RemoteObject.arrayLength(preview);
+ var properties = preview.properties;
+ if (isArray)
+ properties = properties.slice().stableSort(compareIndexesFirst);
+
+ /**
+ * @param {!RuntimeAgent.PropertyPreview} a
+ * @param {!RuntimeAgent.PropertyPreview} b
+ */
+ function compareIndexesFirst(a, b)
+ {
+ var index1 = toArrayIndex(a.name);
+ var index2 = toArrayIndex(b.name);
+ if (index1 < 0)
+ return index2 < 0 ? 0 : 1;
+ return index2 < 0 ? -1 : index1 - index2;
+ }
+
+ /**
+ * @param {string} name
+ * @return {number}
+ */
+ function toArrayIndex(name)
+ {
+ var index = name >>> 0;
+ if (String(index) === name && index < arrayLength)
+ return index;
+ return -1;
+ }
+
parentElement.createTextChild(isArray ? "[" : "{");
- for (var i = 0; i < preview.properties.length; ++i) {
+ for (var i = 0; i < properties.length; ++i) {
if (i > 0)
parentElement.createTextChild(", ");
- var property = preview.properties[i];
+ var property = properties[i];
var name = property.name;
- if (!isArray || name != i) {
+ if (!isArray || name != i || i >= arrayLength) {
if (/^\s|\s$|^$|\n/.test(name))
parentElement.createChild("span", "name").createTextChildren("\"", name.replace(/\n/g, "\u21B5"), "\"");
else
@@ -654,11 +684,11 @@ WebInspector.ConsoleViewMessage.prototype = {
return;
}
- const maxFlatArrayLength = 100;
+ var maxFlatArrayLength = 100;
if (this._message.isOutdated || array.arrayLength() > maxFlatArrayLength)
this._formatParameterAsObject(array, elem, false);
else
- array.getOwnProperties(this._printArray.bind(this, array, elem));
+ array.getAllProperties(false, this._printArray.bind(this, array, elem));
},
/**
@@ -750,8 +780,10 @@ WebInspector.ConsoleViewMessage.prototype = {
*/
_printArray: function(array, elem, properties)
{
- if (!properties)
+ if (!properties) {
+ this._formatParameterAsObject(array, elem, false);
return;
+ }
var elements = [];
for (var i = 0; i < properties.length; ++i) {
« no previous file with comments | « Source/core/inspector/InjectedScriptSource.js ('k') | Source/devtools/front_end/sdk/RemoteObject.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698