Title: [137091] trunk
Revision
137091
Author
[email protected]
Date
2012-12-09 11:28:23 -0800 (Sun, 09 Dec 2012)

Log Message

Web Inspector: do not treat object as equal to itself when logging to console
https://bugs.webkit.org/show_bug.cgi?id=104487

Reviewed by Alexander Pavlov.

Source/WebCore:

Otherwise, mutating object in a loop results in the repeat count update instead of generation of the new preview.

Test: inspector/console/console-object-preview.html

* inspector/ConsoleMessage.cpp:
(WebCore::ConsoleMessage::isEqual):

LayoutTests:

* inspector/console/console-object-preview-expected.txt: Added.
* inspector/console/console-object-preview.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (137090 => 137091)


--- trunk/LayoutTests/ChangeLog	2012-12-09 19:28:23 UTC (rev 137090)
+++ trunk/LayoutTests/ChangeLog	2012-12-09 19:28:23 UTC (rev 137091)
@@ -1,3 +1,13 @@
+2012-12-09  Pavel Feldman  <[email protected]>
+
+        Web Inspector: do not treat object as equal to itself when logging to console
+        https://bugs.webkit.org/show_bug.cgi?id=104487
+
+        Reviewed by Alexander Pavlov.
+
+        * inspector/console/console-object-preview-expected.txt: Added.
+        * inspector/console/console-object-preview.html: Added.
+
 2012-12-09  Joanmarie Diggs  <[email protected]>
 
         [GTK] accessibility/canvas-fallback-content.html is failing

Added: trunk/LayoutTests/inspector/console/console-object-preview-expected.txt (0 => 137091)


--- trunk/LayoutTests/inspector/console/console-object-preview-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/inspector/console/console-object-preview-expected.txt	2012-12-09 19:28:23 UTC (rev 137091)
@@ -0,0 +1,39 @@
+CONSOLE MESSAGE: line 9: Mutating object in a loop
+CONSOLE MESSAGE: line 13: [object Object]
+CONSOLE MESSAGE: line 13: [object Object]
+CONSOLE MESSAGE: line 13: [object Object]
+CONSOLE MESSAGE: line 16: Mutating array in a loop
+CONSOLE MESSAGE: line 20: 0,0,0
+CONSOLE MESSAGE: line 20: 0,0,1
+CONSOLE MESSAGE: line 20: 0,0,2
+CONSOLE MESSAGE: line 23: Object with many properties
+CONSOLE MESSAGE: line 28: [object Object]
+CONSOLE MESSAGE: line 30: Array with many properties
+CONSOLE MESSAGE: line 35: 0,1
+CONSOLE MESSAGE: line 37: Object with proto
+CONSOLE MESSAGE: line 40: [object Object]
+CONSOLE MESSAGE: line 42: Sparse array
+CONSOLE MESSAGE: line 45: ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,50,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
+CONSOLE MESSAGE: line 47: Dense array with indexes and propeties
+CONSOLE MESSAGE: line 53: 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149
+Tests that console produces instant previews for arrays and objects.
+
+Mutating object in a loop console-object-preview.html:9
+Object {a: 0, b: 0, c: 0} console-object-preview.html:13
+Object {a: 0, b: 0, c: 1} console-object-preview.html:13
+Object {a: 0, b: 0, c: 2} console-object-preview.html:13
+Mutating array in a loop console-object-preview.html:16
+[0, 0, 0] console-object-preview.html:20
+[0, 0, 1] console-object-preview.html:20
+[0, 0, 2] console-object-preview.html:20
+Object with many properties console-object-preview.html:23
+Object {property_0: 0, property_1: 1, property_2: 2, property_3: 3, property_4: 4…} console-object-preview.html:28
+Array with many properties console-object-preview.html:30
+[0, 1, property_0: 0, property_1: 1, property_2: 2, property_3: 3, property_4: 4…] console-object-preview.html:35
+Object with proto console-object-preview.html:37
+Object {d: 1, a: 0, b: 0, c: 2} console-object-preview.html:40
+Sparse array console-object-preview.html:42
+[50: 50] console-object-preview.html:45
+Dense array with indexes and propeties console-object-preview.html:47
+[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99…] console-object-preview.html:53
+

Added: trunk/LayoutTests/inspector/console/console-object-preview.html (0 => 137091)


--- trunk/LayoutTests/inspector/console/console-object-preview.html	                        (rev 0)
+++ trunk/LayoutTests/inspector/console/console-object-preview.html	2012-12-09 19:28:23 UTC (rev 137091)
@@ -0,0 +1,75 @@
+<html>
+<head>
+<script src=""
+<script src=""
+<script>
+
+function logToConsole()
+{
+    console.log("Mutating object in a loop");
+    var object = { a: 0, b: 0 };
+    for (var i = 0; i < 3; ++i) {
+        object.c = i;
+        console.log(object);
+    }
+
+    console.log("Mutating array in a loop");
+    var array = [0, 0, 0];
+    for (var i = 0; i < 3; ++i) {
+        array[2] = i;
+        console.log(array);
+    }
+
+    console.log("Object with many properties");
+    var objectWithManyProperties = {};
+    for (var i = 0; i < 10; ++i) {
+        objectWithManyProperties["property_" + i] = i;
+    }
+    console.log(objectWithManyProperties);
+
+    console.log("Array with many properties");
+    var arrayWithManyProperties = [0, 1];
+    for (var i = 0; i < 10; ++i) {
+        arrayWithManyProperties["property_" + i] = i;
+    }
+    console.log(arrayWithManyProperties);
+
+    console.log("Object with proto");
+    var objectWithProto = { d: 1 };
+    objectWithProto.__proto__ = object;
+    console.log(objectWithProto);
+
+    console.log("Sparse array");
+    var sparseArray = new Array(150);
+    sparseArray[50] = 50;
+    console.log(sparseArray);
+
+    console.log("Dense array with indexes and propeties");
+    var denseArray = new Array(150);
+    for (var i = 0; i < 150; ++i) {
+        denseArray[i] = i;
+        denseArray["property_" + i] = i;
+    }
+    console.log(denseArray);
+}
+
+function test()
+{
+    InspectorTest.evaluateInPage("logToConsole()", callback);
+
+    function callback()
+    {
+        InspectorTest.dumpConsoleMessages();
+        InspectorTest.completeTest();
+    }
+}
+</script>
+</head>
+
+<body _onload_="runTest()">
+<p>
+Tests that console produces instant previews for arrays and objects.
+</p>
+
+</body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (137090 => 137091)


--- trunk/Source/WebCore/ChangeLog	2012-12-09 19:28:23 UTC (rev 137090)
+++ trunk/Source/WebCore/ChangeLog	2012-12-09 19:28:23 UTC (rev 137091)
@@ -1,3 +1,17 @@
+2012-12-09  Pavel Feldman  <[email protected]>
+
+        Web Inspector: do not treat object as equal to itself when logging to console
+        https://bugs.webkit.org/show_bug.cgi?id=104487
+
+        Reviewed by Alexander Pavlov.
+
+        Otherwise, mutating object in a loop results in the repeat count update instead of generation of the new preview.
+
+        Test: inspector/console/console-object-preview.html
+
+        * inspector/ConsoleMessage.cpp:
+        (WebCore::ConsoleMessage::isEqual):
+
 2012-12-09  Carlos Garcia Campos  <[email protected]>
 
         Remove unused code in GObject DOM bindings generator

Modified: trunk/Source/WebCore/inspector/ConsoleMessage.cpp (137090 => 137091)


--- trunk/Source/WebCore/inspector/ConsoleMessage.cpp	2012-12-09 19:28:23 UTC (rev 137090)
+++ trunk/Source/WebCore/inspector/ConsoleMessage.cpp	2012-12-09 19:28:23 UTC (rev 137091)
@@ -219,6 +219,11 @@
     if (m_arguments) {
         if (!m_arguments->isEqual(msg->m_arguments.get()))
             return false;
+        // Never treat objects as equal - their properties might change over time.
+        for (size_t i = 0; i < m_arguments->argumentCount(); ++i) {
+            if (m_arguments->argumentAt(i).isObject())
+                return false;
+        }
     } else if (msg->m_arguments)
         return false;
 
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to