Title: [134053] trunk
Revision
134053
Author
pfeld...@chromium.org
Date
2012-11-09 05:05:13 -0800 (Fri, 09 Nov 2012)

Log Message

Web Inspector: wrong output for empty object {}
https://bugs.webkit.org/show_bug.cgi?id=101356

Reviewed by Vsevolod Vlasov.

Changed preview formatting to iterate over enumerable properties only + visit the prototypes.

Source/WebCore:

* inspector/InjectedScriptSource.js:
(.):
* inspector/front-end/ConsoleMessage.js:
(WebInspector.ConsoleMessageImpl.prototype._appendObjectPreview):

LayoutTests:

* inspector/console/command-line-api-expected.txt:
* inspector/console/command-line-api-inspect-expected.txt:
* inspector/console/console-format-collections-expected.txt:
* inspector/console/console-format-expected.txt:
* platform/chromium/inspector/console/console-format-collections-expected.txt:

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (134052 => 134053)


--- trunk/LayoutTests/ChangeLog	2012-11-09 12:54:35 UTC (rev 134052)
+++ trunk/LayoutTests/ChangeLog	2012-11-09 13:05:13 UTC (rev 134053)
@@ -1,3 +1,18 @@
+2012-11-07  Pavel Feldman  <pfeld...@chromium.org>
+
+        Web Inspector: wrong output for empty object {}
+        https://bugs.webkit.org/show_bug.cgi?id=101356
+
+        Reviewed by Vsevolod Vlasov.
+
+        Changed preview formatting to iterate over enumerable properties only + visit the prototypes.
+
+        * inspector/console/command-line-api-expected.txt:
+        * inspector/console/command-line-api-inspect-expected.txt:
+        * inspector/console/console-format-collections-expected.txt:
+        * inspector/console/console-format-expected.txt:
+        * platform/chromium/inspector/console/console-format-collections-expected.txt:
+
 2012-11-09  Kangil Han  <kangil....@samsung.com>
 
         [EFL] Refactor TestExpectations file

Modified: trunk/LayoutTests/inspector/console/command-line-api-expected.txt (134052 => 134053)


--- trunk/LayoutTests/inspector/console/command-line-api-expected.txt	2012-11-09 12:54:35 UTC (rev 134052)
+++ trunk/LayoutTests/inspector/console/command-line-api-expected.txt	2012-11-09 13:05:13 UTC (rev 134053)
@@ -1,4 +1,4 @@
-CONSOLE MESSAGE: line 1031: The console function $() has changed from $=getElementById(id) to $=querySelector(selector). You might try $("#%s")
+CONSOLE MESSAGE: line 1040: The console function $() has changed from $=getElementById(id) to $=querySelector(selector). You might try $("#%s")
 Tests that command line api works.
 
 

Modified: trunk/LayoutTests/inspector/console/command-line-api-inspect-expected.txt (134052 => 134053)


--- trunk/LayoutTests/inspector/console/command-line-api-inspect-expected.txt	2012-11-09 12:54:35 UTC (rev 134052)
+++ trunk/LayoutTests/inspector/console/command-line-api-inspect-expected.txt	2012-11-09 13:05:13 UTC (rev 134053)
@@ -14,26 +14,26 @@
 
 WebInspector.inspect called with: Database
 WebInspector.inspect's hints are: ["databaseId"]
-inspect(db) = Database {version: "1.0"}
+inspect(db) = Database {version: "1.0", transaction: function, readTransaction: function, changeVersion: function}
 
 Running: testRevealDatabase2
 
 
 WebInspector.inspect called with: Database
 WebInspector.inspect's hints are: ["databaseId"]
-inspect(db2) = Database {version: "1.0"}
+inspect(db2) = Database {version: "1.0", transaction: function, readTransaction: function, changeVersion: function}
 
 Running: testRevealLocalStorage
 
 
 WebInspector.inspect called with: Storage
 WebInspector.inspect's hints are: ["domStorageId"]
-inspect(localStorage) = Storage
+inspect(localStorage) = Storage {}
 
 Running: testRevealSessionStorage
 
 
 WebInspector.inspect called with: Storage
 WebInspector.inspect's hints are: ["domStorageId"]
-inspect(sessionStorage) = Storage
+inspect(sessionStorage) = Storage {}
 

Modified: trunk/LayoutTests/inspector/console/console-format-collections-expected.txt (134052 => 134053)


--- trunk/LayoutTests/inspector/console/console-format-collections-expected.txt	2012-11-09 12:54:35 UTC (rev 134052)
+++ trunk/LayoutTests/inspector/console/console-format-collections-expected.txt	2012-11-09 13:05:13 UTC (rev 134053)
@@ -27,12 +27,12 @@
 Array[2] console-format-collections.html:41
 NonArrayWithLength console-format-collections.html:44
 Arguments[2] console-format-collections.html:51
-[<select>] console-format-collections.html:15
- console-format-collections.html:19
-[<option>, <option>, selectedIndex: 0] console-format-collections.html:23
- console-format-collections.html:27
- console-format-collections.html:31
-[<input>, <input>] console-format-collections.html:35
+[<select>, item: function] console-format-collections.html:15
+[<script>, <script>, <script>, item: function, namedItem: function] console-format-collections.html:19
+[<option>, <option>, selectedIndex: 0, remove: function, add: function, item: function, namedItem: function] console-format-collections.html:23
+[<html>, <head>, <script>, <script>, <script>, <body>, <p>, <div>, <form>, <select>, <option>, <option>, <input>, <input>, namedItem: function, tags: function, item: function] console-format-collections.html:27
+[<select>, <input>, <input>, item: function, namedItem: function] console-format-collections.html:31
+[<input>, <input>, item: function] console-format-collections.html:35
 [1, Array[2]] console-format-collections.html:41
 NonArrayWithLength {keys: Array[0]} console-format-collections.html:44
 [1, "2"] console-format-collections.html:51

Modified: trunk/LayoutTests/inspector/console/console-format-expected.txt (134052 => 134053)


--- trunk/LayoutTests/inspector/console/console-format-expected.txt	2012-11-09 12:54:35 UTC (rev 134052)
+++ trunk/LayoutTests/inspector/console/console-format-expected.txt	2012-11-09 13:05:13 UTC (rev 134053)
@@ -45,6 +45,12 @@
 CONSOLE MESSAGE: line 55: -Infinity
 CONSOLE MESSAGE: line 54: test,test2,,,test4,,,,,
 CONSOLE MESSAGE: line 55: test,test2,,,test4,,,,,
+CONSOLE MESSAGE: line 54: [object Object]
+CONSOLE MESSAGE: line 55: [object Object]
+CONSOLE MESSAGE: line 54: function () {}
+CONSOLE MESSAGE: line 55: function () {}
+CONSOLE MESSAGE: line 54: [object Object]
+CONSOLE MESSAGE: line 55: [object Object]
 Tests that console logging dumps proper messages.
 
 Array[10] console-format.html:20
@@ -66,24 +72,22 @@
 ["test named "test""] console-format.html:55
 globals[3]
 "test named "test""
-Error console-format.html:54
+Error {} console-format.html:54
 [Error] console-format.html:55
 globals[4]
-Error
+Error {}
 <p id="p">Tests that console logging dumps proper messages.</p> console-format.html:54
 [<p>] console-format.html:55
 globals[5]
 <p id="p">Tests that console logging dumps proper messages.</p>
 function () { return 1; } console-format.html:54
-[function () { return 1; }] console-format.html:55
+[function] console-format.html:55
 globals[6]
 function () { return 1; }
 function () {
         return 2;
     } console-format.html:54
-[function () {
-        return 2;
-    }] console-format.html:55
+[function] console-format.html:55
 globals[7]
 function () {
         return 2;
@@ -116,10 +120,10 @@
 [id] console-format.html:55
 globals[14]
 id="x""x"
-Object console-format.html:54
+Object {} console-format.html:54
 [Object] console-format.html:55
 globals[15]
-Object
+Object {}
 NaN console-format.html:54
 [NaN] console-format.html:55
 globals[16]
@@ -136,4 +140,16 @@
 [Array[10]] console-format.html:55
 globals[19]
 ["test", "test2", undefined × 2, "test4", undefined × 5]
+Object {} console-format.html:54
+[Object] console-format.html:55
+globals[20]
+Object {}
+[function] console-format.html:54
+[Array[1]] console-format.html:55
+globals[21]
+[function () {}]
+Object {bar: "bar", foo: "foo"} console-format.html:54
+[Object] console-format.html:55
+globals[22]
+Object {bar: "bar", foo: "foo"}
 

Modified: trunk/LayoutTests/inspector/console/console-format.html (134052 => 134053)


--- trunk/LayoutTests/inspector/console/console-format.html	2012-11-09 12:54:35 UTC (rev 134052)
+++ trunk/LayoutTests/inspector/console/console-format.html	2012-11-09 13:05:13 UTC (rev 134053)
@@ -9,10 +9,10 @@
 
 function onload()
 {
+    var foo = { foo: "foo"};
+    var bar = { bar: "bar" };
+    bar.__proto__ = foo;
 
-
-
-
     var array = ["test", "test2"]; array.length = 10;
     array.foo = {}; 
     array[4] = "test4";
@@ -43,7 +43,7 @@
     globals = [
         regex1, regex2, str, str2, error, node, func, multilinefunc, num, linkify,
         null, undefined, valuelessAttribute, valuedAttribute, existingAttribute, throwingLengthGetter,
-        NaN, Number.POSITIVE_INFINITY, Number.NEGATIVE_INFINITY, array
+        NaN, Number.POSITIVE_INFINITY, Number.NEGATIVE_INFINITY, array, {}, [function() {}], bar 
     ];
 
     runTest();

Copied: trunk/LayoutTests/platform/chromium/inspector/console/command-line-api-inspect-expected.txt (from rev 134052, trunk/LayoutTests/inspector/console/command-line-api-inspect-expected.txt) (0 => 134053)


--- trunk/LayoutTests/platform/chromium/inspector/console/command-line-api-inspect-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/platform/chromium/inspector/console/command-line-api-inspect-expected.txt	2012-11-09 13:05:13 UTC (rev 134053)
@@ -0,0 +1,39 @@
+Tests that inspect() command line api works.
+
+
+Running: testRevealElement
+
+
+WebInspector.inspect called with: <p>
+WebInspector.inspect's hints are: []
+inspect($('#p1')) = 
+Selected node id: 'p1'.
+
+Running: testRevealDatabase
+
+
+WebInspector.inspect called with: Database
+WebInspector.inspect's hints are: ["databaseId"]
+inspect(db) = Database {version: "1.0", changeVersion: function, transaction: function, readTransaction: function}
+
+Running: testRevealDatabase2
+
+
+WebInspector.inspect called with: Database
+WebInspector.inspect's hints are: ["databaseId"]
+inspect(db2) = Database {version: "1.0", changeVersion: function, transaction: function, readTransaction: function}
+
+Running: testRevealLocalStorage
+
+
+WebInspector.inspect called with: Storage
+WebInspector.inspect's hints are: ["domStorageId"]
+inspect(localStorage) = Storage {}
+
+Running: testRevealSessionStorage
+
+
+WebInspector.inspect called with: Storage
+WebInspector.inspect's hints are: ["domStorageId"]
+inspect(sessionStorage) = Storage {}
+

Modified: trunk/LayoutTests/platform/chromium/inspector/console/console-format-collections-expected.txt (134052 => 134053)


--- trunk/LayoutTests/platform/chromium/inspector/console/console-format-collections-expected.txt	2012-11-09 12:54:35 UTC (rev 134052)
+++ trunk/LayoutTests/platform/chromium/inspector/console/console-format-collections-expected.txt	2012-11-09 13:05:13 UTC (rev 134053)
@@ -27,12 +27,12 @@
 Array[2] console-format-collections.html:41
 NonArrayWithLength console-format-collections.html:44
 Arguments[2] console-format-collections.html:51
-[<select>] console-format-collections.html:15
-[<script>, <script>, <script>] console-format-collections.html:19
-[<option>, <option>, selectedIndex: 0] console-format-collections.html:23
-[<html>, <head>, <script>, <script>, <script>, <body>, <p>, <div>, <form>, <select>, <option>, <option>, <input>, <input>] console-format-collections.html:27
-[<select>, <input>, <input>] console-format-collections.html:31
-[<input>, <input>] console-format-collections.html:35
+[<select>, item: function] console-format-collections.html:15
+[<script>, <script>, <script>, item: function, namedItem: function] console-format-collections.html:19
+[<option>, <option>, selectedIndex: 0, add: function, remove: function, item: function, namedItem: function] console-format-collections.html:23
+[<html>, <head>, <script>, <script>, <script>, <body>, <p>, <div>, <form>, <select>, <option>, <option>, <input>, <input>, item: function, namedItem: function, tags: function] console-format-collections.html:27
+[<select>, <input>, <input>, item: function, namedItem: function] console-format-collections.html:31
+[<input>, <input>, item: function] console-format-collections.html:35
 [1, Array[2]] console-format-collections.html:41
 NonArrayWithLength {keys: Array[0]} console-format-collections.html:44
 [1, "2"] console-format-collections.html:51

Modified: trunk/Source/WebCore/ChangeLog (134052 => 134053)


--- trunk/Source/WebCore/ChangeLog	2012-11-09 12:54:35 UTC (rev 134052)
+++ trunk/Source/WebCore/ChangeLog	2012-11-09 13:05:13 UTC (rev 134053)
@@ -1,3 +1,17 @@
+2012-11-07  Pavel Feldman  <pfeld...@chromium.org>
+
+        Web Inspector: wrong output for empty object {}
+        https://bugs.webkit.org/show_bug.cgi?id=101356
+
+        Reviewed by Vsevolod Vlasov.
+
+        Changed preview formatting to iterate over enumerable properties only + visit the prototypes.
+
+        * inspector/InjectedScriptSource.js:
+        (.):
+        * inspector/front-end/ConsoleMessage.js:
+        (WebInspector.ConsoleMessageImpl.prototype._appendObjectPreview):
+
 2012-11-09  Keishi Hattori  <kei...@webkit.org>
 
         Fix annotations in page popup files

Modified: trunk/Source/WebCore/inspector/InjectedScriptSource.js (134052 => 134053)


--- trunk/Source/WebCore/inspector/InjectedScriptSource.js	2012-11-09 12:54:35 UTC (rev 134052)
+++ trunk/Source/WebCore/inspector/InjectedScriptSource.js	2012-11-09 13:05:13 UTC (rev 134053)
@@ -814,35 +814,45 @@
      */
     _generatePreview: function(object)
     {
-        var preview = {};
+        this.preview = {};
+        this.preview.lossless = true;
+        this.preview.overflow = false;
+        this.preview.properties = [];
+
         var isArray = this.subtype === "array";
         var elementsToDump = isArray ? 100 : 5;
-  
-        var propertyNames = Object.getOwnPropertyNames(/** @type {!Object} */(object));
-        preview.lossless = true;
-        preview.overflow = false;
-        var properties = preview.properties = [];
 
+        for (var o = object; injectedScript._isDefined(o); o = o.__proto__)
+            this._generateProtoPreview(o, elementsToDump);
+    },
+
+    /**
+     * @param {Object} object
+     * @param {number} elementsToDump
+     */
+    _generateProtoPreview: function(object, elementsToDump)
+    {
+        var propertyNames = Object.keys(/** @type {!Object} */(object));
         try {
             for (var i = 0; i < propertyNames.length; ++i) {
-                if (properties.length >= elementsToDump) {
-                    preview.overflow = true;
-                    preview.lossless = false;
+                if (this.preview.properties.length >= elementsToDump) {
+                    this.preview.overflow = true;
+                    this.preview.lossless = false;
                     break;
                 }
                 var name = propertyNames[i];
-                if (isArray && name === "length")
+                if (this.subtype === "array" && name === "length")
                     continue;
 
                 var descriptor = Object.getOwnPropertyDescriptor(/** @type {!Object} */(object), name);
                 if (!("value" in descriptor) || !descriptor.enumerable) {
-                    preview.lossless = false;
+                    this.preview.lossless = false;
                     continue;
                 }
 
                 var value = descriptor.value;
                 if (value === null) {
-                    properties.push({ name: name, type: "object", value: "null" });
+                    this.preview.properties.push({ name: name, type: "object", value: "null" });
                     continue;
                 }
     
@@ -853,27 +863,26 @@
                     if (type === "string") {
                         if (value.length > maxLength) {
                             value = this._abbreviateString(value, maxLength, true);
-                            preview.lossless = false;
+                            this.preview.lossless = false;
                         }
                         value = "\"" + value.replace(/\n/g, "\u21B5") + "\"";
                     }
-                    properties.push({ name: name, type: type, value: value + "" });
+                    this.preview.properties.push({ name: name, type: type, value: value + "" });
                     continue;
                 }
     
-                preview.lossless = false;
+                this.preview.lossless = false;
 
-                if (type === "function")
-                    continue;
+                var subtype = injectedScript._subtype(value);
+                var description = "";
+                if (type !== "function")
+                    description = this._abbreviateString(/** @type {string} */ (injectedScript._describe(value)), maxLength, subtype === "regexp");
 
-                var subtype = injectedScript._subtype(value);
-                var property = { name: name, type: type, value: this._abbreviateString(/** @type {string} */ (injectedScript._describe(value)), maxLength, subtype === "regexp") };
+                var property = { name: name, type: type, value: description };
                 if (subtype)
                     property.subtype = subtype;
-                properties.push(property);
+                this.preview.properties.push(property);
             }
-            if (properties.length)
-                this.preview = preview;
         } catch (e) {
         }
     },

Modified: trunk/Source/WebCore/inspector/front-end/ConsoleMessage.js (134052 => 134053)


--- trunk/Source/WebCore/inspector/front-end/ConsoleMessage.js	2012-11-09 12:54:35 UTC (rev 134052)
+++ trunk/Source/WebCore/inspector/front-end/ConsoleMessage.js	2012-11-09 13:05:13 UTC (rev 134053)
@@ -328,8 +328,11 @@
                     span.addStyleClass("console-formatted-preview-node");
                 else if (property.subtype === "regexp")
                     span.addStyleClass("console-formatted-string");
-            }
-            span.textContent = property.value;
+                span.textContent = property.value;
+            } else if (property.type === "function")
+                span.textContent = "function";
+            else
+                span.textContent = property.value;
         }
         if (preview.overflow)
             titleElement.createChild("span").textContent = "\u2026";
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to