Changeset 136040 in webkit


Ignore:
Timestamp:
Nov 28, 2012, 12:12:38 PM (13 years ago)
Author:
pfeldman@chromium.org
Message:

Merge 134053 - 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:

TBR=pfeldman@chromium.org
BUG=162570
Review URL: https://chromiumcodereview.appspot.com/11415185

Location:
branches/chromium/1312
Files:
8 edited
1 copied

Legend:

Unmodified
Added
Removed
  • branches/chromium/1312/LayoutTests/inspector/console/command-line-api-expected.txt

    r131178 r136040  
    1 CONSOLE MESSAGE: line 1020: The console function $() has changed from $=getElementById(id) to $=querySelector(selector). You might try $("#%s")
     1CONSOLE MESSAGE: line 1029: The console function $() has changed from $=getElementById(id) to $=querySelector(selector). You might try $("#%s")
    22Tests that command line api works.
    33
  • branches/chromium/1312/LayoutTests/inspector/console/command-line-api-inspect-expected.txt

    r127266 r136040  
    1515WebInspector.inspect called with: Database
    1616WebInspector.inspect's hints are: ["databaseId"]
    17 inspect(db) = Database
     17inspect(db) = Database {version: "1.0", transaction: function, readTransaction: function, changeVersion: function}
    1818
    1919Running: testRevealDatabase2
     
    2222WebInspector.inspect called with: Database
    2323WebInspector.inspect's hints are: ["databaseId"]
    24 inspect(db2) = Database
     24inspect(db2) = Database {version: "1.0", transaction: function, readTransaction: function, changeVersion: function}
    2525
    2626Running: testRevealLocalStorage
     
    2929WebInspector.inspect called with: Storage
    3030WebInspector.inspect's hints are: ["domStorageId"]
    31 inspect(localStorage) = Storage
     31inspect(localStorage) = Storage {}
    3232
    3333Running: testRevealSessionStorage
     
    3636WebInspector.inspect called with: Storage
    3737WebInspector.inspect's hints are: ["domStorageId"]
    38 inspect(sessionStorage) = Storage
     38inspect(sessionStorage) = Storage {}
    3939
  • branches/chromium/1312/LayoutTests/inspector/console/console-format-collections-expected.txt

    r125975 r136040  
    2828NonArrayWithLength console-format-collections.html:44
    2929Arguments[2] console-format-collections.html:51
    30 [<select>] console-format-collections.html:15
    31  console-format-collections.html:19
    32 [<option>, <option>, selectedIndex: 0] console-format-collections.html:23
    33  console-format-collections.html:27
    34  console-format-collections.html:31
    35 [<input>, <input>] console-format-collections.html:35
     30[<select>, item: function] console-format-collections.html:15
     31[<script>, <script>, <script>, item: function, namedItem: function] console-format-collections.html:19
     32[<option>, <option>, selectedIndex: 0, remove: function, add: function, item: function, namedItem: function] console-format-collections.html:23
     33[<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
     34[<select>, <input>, <input>, item: function, namedItem: function] console-format-collections.html:31
     35[<input>, <input>, item: function] console-format-collections.html:35
    3636[1, Array[2]] console-format-collections.html:41
    3737NonArrayWithLength {keys: Array[0]} console-format-collections.html:44
  • branches/chromium/1312/LayoutTests/inspector/console/console-format-expected.txt

    r125284 r136040  
    4949CONSOLE MESSAGE: line 54: test,test2,,,test4,,,,,
    5050CONSOLE MESSAGE: line 55: test,test2,,,test4,,,,,
     51CONSOLE MESSAGE: line 54: [object Object]
     52CONSOLE MESSAGE: line 55: [object Object]
     53CONSOLE MESSAGE: line 54: function () {}
     54CONSOLE MESSAGE: line 55: function () {}
     55CONSOLE MESSAGE: line 54: [object Object]
     56CONSOLE MESSAGE: line 55: [object Object]
    5157Tests that console logging dumps proper messages.
    5258
     
    7379globals[3]
    7480"test named "test""
    75 Error console-format.html:54
     81Error {} console-format.html:54
    7682[Error] console-format.html:55
    7783globals[4]
    78 Error
     84Error {}
    7985<p id="p">Tests that console logging dumps proper messages.</p> console-format.html:54
    8086[<p>] console-format.html:55
     
    8288<p id="p">Tests that console logging dumps proper messages.</p>
    8389function () { return 1; } console-format.html:54
    84 [function () { return 1; }] console-format.html:55
     90[function] console-format.html:55
    8591globals[6]
    8692function () { return 1; }
     
    8894        return 2;
    8995    } console-format.html:54
    90 [function () {
    91         return 2;
    92     }] console-format.html:55
     96[function] console-format.html:55
    9397globals[7]
    9498function () {
     
    123127globals[14]
    124128id="x""x"
    125 Object console-format.html:54
     129Object {} console-format.html:54
    126130[Object] console-format.html:55
    127131globals[15]
    128 Object
     132Object {}
    129133NaN console-format.html:54
    130134[NaN] console-format.html:55
     
    143147globals[19]
    144148["test", "test2", undefined × 2, "test4", undefined × 5]
     149Object {} console-format.html:54
     150[Object] console-format.html:55
     151globals[20]
     152Object {}
     153[function] console-format.html:54
     154[Array[1]] console-format.html:55
     155globals[21]
     156[function () {}]
     157Object {bar: "bar", foo: "foo"} console-format.html:54
     158[Object] console-format.html:55
     159globals[22]
     160Object {bar: "bar", foo: "foo"}
    145161
  • branches/chromium/1312/LayoutTests/inspector/console/console-format.html

    r125284 r136040  
    1313    console.log('Message %s for %s', 'format', 'string');
    1414    console.log('Object %o', {'foo' : 'bar' });
     15    var foo = { foo: "foo"};
     16    var bar = { bar: "bar" };
     17    bar.__proto__ = foo;
    1518
    1619    var array = ["test", "test2"]; array.length = 10;
     
    4447        regex1, regex2, str, str2, error, node, func, multilinefunc, num, linkify,
    4548        null, undefined, valuelessAttribute, valuedAttribute, existingAttribute, throwingLengthGetter,
    46         NaN, Number.POSITIVE_INFINITY, Number.NEGATIVE_INFINITY, array
     49        NaN, Number.POSITIVE_INFINITY, Number.NEGATIVE_INFINITY, array, {}, [function() {}], bar
    4750    ];
    4851
  • branches/chromium/1312/LayoutTests/platform/chromium/inspector/console/console-format-collections-expected.txt

    r125284 r136040  
    2828NonArrayWithLength console-format-collections.html:44
    2929Arguments[2] console-format-collections.html:51
    30 [<select>] console-format-collections.html:15
    31 [<script>, <script>, <script>] console-format-collections.html:19
    32 [<option>, <option>, selectedIndex: 0] console-format-collections.html:23
    33 [<html>, <head>, <script>, <script>, <script>, <body>, <p>, <div>, <form>, <select>, <option>, <option>, <input>, <input>] console-format-collections.html:27
    34 [<select>, <input>, <input>] console-format-collections.html:31
    35 [<input>, <input>] console-format-collections.html:35
     30[<select>, item: function] console-format-collections.html:15
     31[<script>, <script>, <script>, item: function, namedItem: function] console-format-collections.html:19
     32[<option>, <option>, selectedIndex: 0, add: function, remove: function, item: function, namedItem: function] console-format-collections.html:23
     33[<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
     34[<select>, <input>, <input>, item: function, namedItem: function] console-format-collections.html:31
     35[<input>, <input>, item: function] console-format-collections.html:35
    3636[1, Array[2]] console-format-collections.html:41
    3737NonArrayWithLength {keys: Array[0]} console-format-collections.html:44
  • branches/chromium/1312/Source/WebCore/inspector/InjectedScriptSource.js

    r131178 r136040  
    804804    _generatePreview: function(object)
    805805    {
    806         var preview = {};
     806        this.preview = {};
     807        this.preview.lossless = true;
     808        this.preview.overflow = false;
     809        this.preview.properties = [];
     810
    807811        var isArray = this.subtype === "array";
    808812        var elementsToDump = isArray ? 100 : 5;
    809  
    810         var propertyNames = Object.getOwnPropertyNames(/** @type {!Object} */(object));
    811         preview.lossless = true;
    812         preview.overflow = false;
    813         var properties = preview.properties = [];
    814 
     813
     814        for (var o = object; injectedScript._isDefined(o); o = o.__proto__)
     815            this._generateProtoPreview(o, elementsToDump);
     816    },
     817
     818    /**
     819     * @param {Object} object
     820     * @param {number} elementsToDump
     821     */
     822    _generateProtoPreview: function(object, elementsToDump)
     823    {
     824        var propertyNames = Object.keys(/** @type {!Object} */(object));
    815825        try {
    816826            for (var i = 0; i < propertyNames.length; ++i) {
    817                 if (properties.length >= elementsToDump) {
    818                     preview.overflow = true;
    819                     preview.lossless = false;
     827                if (this.preview.properties.length >= elementsToDump) {
     828                    this.preview.overflow = true;
     829                    this.preview.lossless = false;
    820830                    break;
    821831                }
    822832                var name = propertyNames[i];
    823                 if (isArray && name === "length")
     833                if (this.subtype === "array" && name === "length")
    824834                    continue;
    825835
    826836                var descriptor = Object.getOwnPropertyDescriptor(/** @type {!Object} */(object), name);
    827837                if (!("value" in descriptor) || !descriptor.enumerable) {
    828                     preview.lossless = false;
     838                    this.preview.lossless = false;
    829839                    continue;
    830840                }
     
    832842                var value = descriptor.value;
    833843                if (value === null) {
    834                     properties.push({ name: name, type: "object", value: "null" });
     844                    this.preview.properties.push({ name: name, type: "object", value: "null" });
    835845                    continue;
    836846                }
     
    843853                        if (value.length > maxLength) {
    844854                            value = this._abbreviateString(value, maxLength, true);
    845                             preview.lossless = false;
     855                            this.preview.lossless = false;
    846856                        }
    847857                        value = "\"" + value.replace(/\n/g, "\u21B5") + "\"";
    848858                    }
    849                     properties.push({ name: name, type: type, value: value + "" });
     859                    this.preview.properties.push({ name: name, type: type, value: value + "" });
    850860                    continue;
    851861                }
    852862   
    853                 preview.lossless = false;
    854 
    855                 if (type === "function")
    856                     continue;
     863                this.preview.lossless = false;
    857864
    858865                var subtype = injectedScript._subtype(value);
    859                 var property = { name: name, type: type, value: this._abbreviateString(/** @type {string} */ (injectedScript._describe(value)), maxLength, subtype === "regexp") };
     866                var description = "";
     867                if (type !== "function")
     868                    description = this._abbreviateString(/** @type {string} */ (injectedScript._describe(value)), maxLength, subtype === "regexp");
     869
     870                var property = { name: name, type: type, value: description };
    860871                if (subtype)
    861872                    property.subtype = subtype;
    862                 properties.push(property);
     873                this.preview.properties.push(property);
    863874            }
    864             if (properties.length)
    865                 this.preview = preview;
    866875        } catch (e) {
    867876        }
  • branches/chromium/1312/Source/WebCore/inspector/front-end/ConsoleMessage.js

    r131448 r136040  
    325325                else if (property.subtype === "regexp")
    326326                    span.addStyleClass("console-formatted-string");
    327             }
    328             span.textContent = property.value;
     327                span.textContent = property.value;
     328            } else if (property.type === "function")
     329                span.textContent = "function";
     330            else
     331                span.textContent = property.value;
    329332        }
    330333        if (preview.overflow)
Note: See TracChangeset for help on using the changeset viewer.