Web Inspector: console doesn't show properly arrays from which tail values have been...
authorpfeldman@chromium.org <pfeldman@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 22 Feb 2012 17:39:03 +0000 (17:39 +0000)
committerpfeldman@chromium.org <pfeldman@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 22 Feb 2012 17:39:03 +0000 (17:39 +0000)
https://bugs.webkit.org/show_bug.cgi?id=79242

Reviewed by Yury Semikhatsky.

Source/WebCore:

* English.lproj/localizedStrings.js:
* inspector/front-end/ConsoleMessage.js:
(WebInspector.ConsoleMessageImpl.prototype._printArray.appendUndefined):
(WebInspector.ConsoleMessageImpl.prototype._printArray):

LayoutTests:

* inspector/console/console-format-expected.txt:
* inspector/console/console-format.html:
* platform/chromium/inspector/console/console-format-collections-expected.txt:
* platform/chromium/inspector/console/console-format-expected.txt:

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@108511 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/inspector/console/console-format-expected.txt
LayoutTests/inspector/console/console-format.html
LayoutTests/platform/chromium/inspector/console/console-format-collections-expected.txt
LayoutTests/platform/chromium/inspector/console/console-format-expected.txt
Source/WebCore/ChangeLog
Source/WebCore/English.lproj/localizedStrings.js
Source/WebCore/inspector/front-end/ConsoleMessage.js

index 40fb0e4..7eb622a 100644 (file)
@@ -1,3 +1,15 @@
+2012-02-22  Pavel Feldman  <pfeldman@google.com>
+
+        Web Inspector: console doesn't show properly arrays from which tail values have been deleted
+        https://bugs.webkit.org/show_bug.cgi?id=79242
+
+        Reviewed by Yury Semikhatsky.
+
+        * inspector/console/console-format-expected.txt:
+        * inspector/console/console-format.html:
+        * platform/chromium/inspector/console/console-format-collections-expected.txt:
+        * platform/chromium/inspector/console/console-format-expected.txt:
+
 2012-02-22  Vsevolod Vlasov  <vsevik@chromium.org>
 
         Web Inspector: [REGRESSION] Console xhr logging is broken for async xhrs since r107672.
index a325997..247371f 100644 (file)
@@ -1,7 +1,7 @@
 CONSOLE MESSAGE: line 12: Message format number %i, %d and %f
 CONSOLE MESSAGE: line 13: Message %s for %s
 CONSOLE MESSAGE: line 14: Object %o
-CONSOLE MESSAGE: line 20: test,test2,,,test4
+CONSOLE MESSAGE: line 20: test,test2,,,test4,,,,,
 CONSOLE MESSAGE: line 21: %o
 CONSOLE MESSAGE: line 22: %O
 CONSOLE MESSAGE: line 54: /^url\(\s*(?:(?:"(?:[^\\\"]|(?:\\[\da-f]{1,6}\s?|\.))*"|'(?:[^\\\']|(?:\\[\da-f]{1,6}\s?|\.))*')|(?:[!#$%&*-~\w]|(?:\\[\da-f]{1,6}\s?|\.))*)\s*\)/i
@@ -51,9 +51,9 @@ Tests that console logging dumps proper messages.
 console-format.html:12Message format number 1, 2 and 3.5
 console-format.html:13Message format for string
 console-format.html:14Object Object
-console-format.html:20["test", "test2", undefined, undefined, "test4"]
-console-format.html:21["test", "test2", undefined, undefined, "test4"]
-console-format.html:22Array[5]
+console-format.html:20["test", "test2", undefined × 2, "test4", undefined × 5]
+console-format.html:21["test", "test2", undefined × 2, "test4", undefined × 5]
+console-format.html:22Array[10]
 console-format.html:54/^url\(\s*(?:(?:"(?:[^\\\"]|(?:\\[\da-f]{1,6}\s?|\.))*"|'(?:[^\\\']|(?:\\[\da-f]{1,6}\s?|\.))*')|(?:[!#$%&*-~\w]|(?:\\[\da-f]{1,6}\s?|\.))*)\s*\)/i
 console-format.html:55[/^url\(\s*(?:(?:"(?:[^\\\"]|(?:\\[\da-f]{1,6}\s?|\.))*"|'(?:[^\\\']|(?:\\[\da-f]{1,6}\s?|\.))*')|(?:[!#$%&*-~\w]|(?:\\[\da-f]{1,6}\s?|\.))*)\s*\)/i]
 globals[0]
index 28772d6..e6440a9 100644 (file)
@@ -13,7 +13,7 @@ function onload()
     console.log('Message %s for %s', 'format', 'string');
     console.log('Object %o', {'foo' : 'bar' });
 
-    var array = ["test", "test2"];
+    var array = ["test", "test2"]; array.length = 10;
     array.foo = "bar"; 
     array[4] = "test4";
 
index c94a54a..a4c03ae 100644 (file)
@@ -9,7 +9,7 @@ Tests that console nicely formats HTML Collections and NodeLists.
 
 console-format-collections.html:15[<select id="sel" name="sel">…</select>]
 console-format-collections.html:19[<script src="../../http/tests/inspector/inspector-test.js"></script>, <script src="../../http/tests/inspector/console-test.js"></script>, <script>…</script>]
-console-format-collections.html:23[]
+console-format-collections.html:23[undefined × 2]
 console-format-collections.html:27[<html>…</html>, <head>…</head>, <script src="../../http/tests/inspector/inspector-test.js"></script>, <script src="../../http/tests/inspector/console-test.js"></script>, <script>…</script>, <body onload="onload()">…</body>, <p>
 Tests that console nicely formats HTML Collections and NodeLists.
 </p>, <div style="display:none">…</div>, <form id="f">…</form>, <select id="sel" name="sel">…</select>, <option value="1">one</option>, <option value="2">two</option>, <input type="radio" name="x" value="x1">, <input type="radio" name="x" value="x2">]
index a325997..247371f 100644 (file)
@@ -1,7 +1,7 @@
 CONSOLE MESSAGE: line 12: Message format number %i, %d and %f
 CONSOLE MESSAGE: line 13: Message %s for %s
 CONSOLE MESSAGE: line 14: Object %o
-CONSOLE MESSAGE: line 20: test,test2,,,test4
+CONSOLE MESSAGE: line 20: test,test2,,,test4,,,,,
 CONSOLE MESSAGE: line 21: %o
 CONSOLE MESSAGE: line 22: %O
 CONSOLE MESSAGE: line 54: /^url\(\s*(?:(?:"(?:[^\\\"]|(?:\\[\da-f]{1,6}\s?|\.))*"|'(?:[^\\\']|(?:\\[\da-f]{1,6}\s?|\.))*')|(?:[!#$%&*-~\w]|(?:\\[\da-f]{1,6}\s?|\.))*)\s*\)/i
@@ -51,9 +51,9 @@ Tests that console logging dumps proper messages.
 console-format.html:12Message format number 1, 2 and 3.5
 console-format.html:13Message format for string
 console-format.html:14Object Object
-console-format.html:20["test", "test2", undefined, undefined, "test4"]
-console-format.html:21["test", "test2", undefined, undefined, "test4"]
-console-format.html:22Array[5]
+console-format.html:20["test", "test2", undefined × 2, "test4", undefined × 5]
+console-format.html:21["test", "test2", undefined × 2, "test4", undefined × 5]
+console-format.html:22Array[10]
 console-format.html:54/^url\(\s*(?:(?:"(?:[^\\\"]|(?:\\[\da-f]{1,6}\s?|\.))*"|'(?:[^\\\']|(?:\\[\da-f]{1,6}\s?|\.))*')|(?:[!#$%&*-~\w]|(?:\\[\da-f]{1,6}\s?|\.))*)\s*\)/i
 console-format.html:55[/^url\(\s*(?:(?:"(?:[^\\\"]|(?:\\[\da-f]{1,6}\s?|\.))*"|'(?:[^\\\']|(?:\\[\da-f]{1,6}\s?|\.))*')|(?:[!#$%&*-~\w]|(?:\\[\da-f]{1,6}\s?|\.))*)\s*\)/i]
 globals[0]
index 549de96..64f5218 100644 (file)
@@ -1,5 +1,17 @@
 2012-02-22  Pavel Feldman  <pfeldman@google.com>
 
+        Web Inspector: console doesn't show properly arrays from which tail values have been deleted
+        https://bugs.webkit.org/show_bug.cgi?id=79242
+
+        Reviewed by Yury Semikhatsky.
+
+        * English.lproj/localizedStrings.js:
+        * inspector/front-end/ConsoleMessage.js:
+        (WebInspector.ConsoleMessageImpl.prototype._printArray.appendUndefined):
+        (WebInspector.ConsoleMessageImpl.prototype._printArray):
+
+2012-02-22  Pavel Feldman  <pfeldman@google.com>
+
         Web Inspector: warning external font mime (font/font/woff).
         https://bugs.webkit.org/show_bug.cgi?id=79244
 
index 1f5a22c..6dcbfa8 100644 (file)
Binary files a/Source/WebCore/English.lproj/localizedStrings.js and b/Source/WebCore/English.lproj/localizedStrings.js differ
index 82efcde..f2a74ef 100644 (file)
@@ -310,22 +310,44 @@ WebInspector.ConsoleMessageImpl.prototype = {
             return;
 
         var elements = [];
+        var length = 0;
         for (var i = 0; i < properties.length; ++i) {
-            var name = properties[i].name;
+            var property = properties[i];
+            var name = property.name;
+            if (name === "length")
+                length = parseInt(property.value.description, 10);
             if (name == parseInt(name, 10))
-                elements[name] = this._formatAsArrayEntry(properties[i].value);
+                elements[name] = this._formatAsArrayEntry(property.value);
         }
 
         elem.appendChild(document.createTextNode("["));
-        for (var i = 0; i < elements.length; ++i) {
+        var lastNonEmptyIndex = -1;
+
+        function appendUndefined(elem, index)
+        {
+            if (index - lastNonEmptyIndex <= 1)
+                return;
+            var span = elem.createChild(span, "console-formatted-undefined");
+            span.textContent = WebInspector.UIString("undefined × %d", index - lastNonEmptyIndex - 1);
+        }
+
+        for (var i = 0; i < length; ++i) {
             var element = elements[i];
-            if (element)
-                elem.appendChild(element);
-            else
-                elem.appendChild(document.createTextNode("undefined"))
-            if (i < elements.length - 1)
+            if (!element)
+                continue;
+
+            if (i - lastNonEmptyIndex > 1) {
+                appendUndefined(elem, i);
                 elem.appendChild(document.createTextNode(", "));
-        }
+            }
+
+            elem.appendChild(element);
+            lastNonEmptyIndex = i;
+            if (i < length - 1)
+                elem.appendChild(document.createTextNode(", "));
+        }       
+        appendUndefined(elem, length);
+
         elem.appendChild(document.createTextNode("]"));
     },