Changeset 92670 in webkit


Ignore:
Timestamp:
Aug 9, 2011 2:05:16 AM (13 years ago)
Author:
pfeldman@chromium.org
Message:

Web Inspector: there should be a way to tell what properties are non-enumerable when expanding objects.
https://bugs.webkit.org/show_bug.cgi?id=65518

Reviewed by Yury Semikhatsky.

Source/WebCore:

  • inspector/InjectedScript.cpp:

(WebCore::InjectedScript::getProperties):

  • inspector/InjectedScript.h:
  • inspector/InjectedScriptSource.js:

(.):

  • inspector/Inspector.json:
  • inspector/InspectorRuntimeAgent.cpp:

(WebCore::InspectorRuntimeAgent::getProperties):

  • inspector/InspectorRuntimeAgent.h:
  • inspector/front-end/ObjectPropertiesSection.js:

(WebInspector.ObjectPropertyTreeElement.prototype.ondblclick):
(WebInspector.ObjectPropertyTreeElement.prototype.update):

  • inspector/front-end/RemoteObject.js:

(WebInspector.RemoteObject.prototype.getOwnProperties):
(WebInspector.RemoteObject.prototype.getAllProperties):
(WebInspector.RemoteObjectProperty):

  • inspector/front-end/inspector.css:

(.section .properties .dimmed):

LayoutTests:

  • inspector/protocol/runtime-agent-expected.txt:
  • inspector/runtime/runtime-getProperties-expected.txt:
  • inspector/runtime/runtime-getProperties.html:
Location:
trunk
Files:
1 deleted
14 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r92668 r92670  
     12011-08-09  Pavel Feldman  <pfeldman@google.com>
     2
     3        Web Inspector: there should be a way to tell what properties are non-enumerable when expanding objects.
     4        https://bugs.webkit.org/show_bug.cgi?id=65518
     5
     6        Reviewed by Yury Semikhatsky.
     7
     8        * inspector/protocol/runtime-agent-expected.txt:
     9        * inspector/runtime/runtime-getProperties-expected.txt:
     10        * inspector/runtime/runtime-getProperties.html:
     11
    1122011-08-09  Nikolas Zimmermann  <nzimmermann@rim.com>
    213
  • trunk/LayoutTests/inspector/protocol/runtime-agent-expected.txt

    r92471 r92670  
    168168    params : {
    169169        objectId : <string>
    170         ignoreHasOwnProperty : false
     170        ownProperties : false
    171171    }
    172172    id : <number>
     
    178178        result : [
    179179            {
    180                 name : "assignedByCallFunctionOn"
    181180                value : {
    182181                    type : "string"
    183182                    value : "callFunctionOn function works fine"
    184183                }
     184                writable : true
     185                enumerable : true
     186                configurable : true
     187                name : "assignedByCallFunctionOn"
    185188            }
    186189            {
    187                 name : "self"
    188190                value : {
    189191                    type : "object"
     
    192194                    description : "TestObject"
    193195                }
    194             }
    195             {
    196                 name : "__proto__"
    197                 value : {
    198                     type : "object"
    199                     objectId : <string>
    200                     className : <string>
    201                     description : "TestObject"
    202                 }
     196                writable : true
     197                enumerable : true
     198                configurable : true
     199                name : "self"
    203200            }
    204201        ]
  • trunk/LayoutTests/inspector/runtime/runtime-getProperties-expected.txt

    r91757 r92670  
    1010        type : "function"
    1111        description : "function () { return 1; }"
     12        objectId : <string>
    1213    }
     14    enumerable : true
     15    writable : false
    1316}
    1417{
     
    1720        type : "function"
    1821        description : "function (value) { }"
     22        objectId : <string>
    1923    }
     24    enumerable : true
     25    writable : false
    2026}
    2127
     
    2632        type : "function"
    2733        description : "function () { return 1; }"
     34        objectId : <string>
    2835    }
     36    enumerable : true
     37    writable : false
    2938}
    3039
  • trunk/LayoutTests/inspector/runtime/runtime-getProperties.html

    r91754 r92670  
    6666            return;
    6767
    68         var propertyObj = {};
    69         propertyObj.name = property.name;
    70         propertyObj.value = {};
    71         propertyObj.value.type = property.value.type;
    72         propertyObj.value.description = property.value.description;
    73 
    74         InspectorTest.dump(propertyObj);
     68        var value = property.value;
     69        if (value)
     70            property.value = { type: value.type, description: value.description.replace("function foo", "function "), objectId: value.objectId };
     71        InspectorTest.dump(property, { objectId: true });
    7572    }
    7673}
  • trunk/Source/WebCore/ChangeLog

    r92665 r92670  
     12011-08-09  Pavel Feldman  <pfeldman@google.com>
     2
     3        Web Inspector: there should be a way to tell what properties are non-enumerable when expanding objects.
     4        https://bugs.webkit.org/show_bug.cgi?id=65518
     5
     6        Reviewed by Yury Semikhatsky.
     7
     8        * inspector/InjectedScript.cpp:
     9        (WebCore::InjectedScript::getProperties):
     10        * inspector/InjectedScript.h:
     11        * inspector/InjectedScriptSource.js:
     12        (.):
     13        * inspector/Inspector.json:
     14        * inspector/InspectorRuntimeAgent.cpp:
     15        (WebCore::InspectorRuntimeAgent::getProperties):
     16        * inspector/InspectorRuntimeAgent.h:
     17        * inspector/front-end/ObjectPropertiesSection.js:
     18        (WebInspector.ObjectPropertyTreeElement.prototype.ondblclick):
     19        (WebInspector.ObjectPropertyTreeElement.prototype.update):
     20        * inspector/front-end/RemoteObject.js:
     21        (WebInspector.RemoteObject.prototype.getOwnProperties):
     22        (WebInspector.RemoteObject.prototype.getAllProperties):
     23        (WebInspector.RemoteObjectProperty):
     24        * inspector/front-end/inspector.css:
     25        (.section .properties .dimmed):
     26
    1272011-08-08  Steve Block  <steveblock@google.com>
    228
  • trunk/Source/WebCore/inspector/InjectedScript.cpp

    r92471 r92670  
    8686}
    8787
    88 void InjectedScript::getProperties(ErrorString* errorString, const String& objectId, bool ignoreHasOwnProperty, RefPtr<InspectorArray>* properties)
     88void InjectedScript::getProperties(ErrorString* errorString, const String& objectId, bool ownProperties, RefPtr<InspectorArray>* properties)
    8989{
    9090    ScriptFunctionCall function(m_injectedScriptObject, "getProperties");
    9191    function.appendArgument(objectId);
    92     function.appendArgument(ignoreHasOwnProperty);
     92    function.appendArgument(ownProperties);
    9393
    9494    RefPtr<InspectorValue> result;
  • trunk/Source/WebCore/inspector/InjectedScript.h

    r92377 r92670  
    7171                        bool* wasThrown);
    7272    void evaluateOnCallFrame(ErrorString*, const ScriptValue& callFrames, const String& callFrameId, const String& expression, const String& objectGroup, bool includeCommandLineAPI, RefPtr<InspectorObject>* result, bool* wasThrown);
    73     void getProperties(ErrorString*, const String& objectId, bool ignoreHasOwnProperty, RefPtr<InspectorArray>* result);
     73    void getProperties(ErrorString*, const String& objectId, bool ownProperties, RefPtr<InspectorArray>* result);
    7474    Node* nodeForObjectId(const String& objectId);
    7575    void releaseObject(const String& objectId);
  • trunk/Source/WebCore/inspector/InjectedScriptSource.js

    r92377 r92670  
    1 /*
     1  /*
    22 * Copyright (C) 2007 Apple Inc.  All rights reserved.
    33 *
     
    166166    },
    167167
    168     getProperties: function(objectId, ignoreHasOwnProperty)
     168    getProperties: function(objectId, ownProperties)
    169169    {
    170170        var parsedObjectId = this._parseObjectId(objectId);
     
    174174        if (!this._isDefined(object))
    175175            return false;
    176         var properties = [];
    177 
    178         var propertyNames = ignoreHasOwnProperty ? this._getPropertyNames(object) : Object.getOwnPropertyNames(object);
    179         if (!ignoreHasOwnProperty && object.__proto__)
    180             propertyNames.push("__proto__");
    181 
    182         // Go over properties, prepare results.
    183         for (var i = 0; i < propertyNames.length; ++i) {
    184             var propertyName = propertyNames[i];
    185 
    186             var getter = (typeof object["__lookupGetter__"] === "function") && object.__lookupGetter__(propertyName);
    187             var setter = (typeof object["__lookupSetter__"] === "function") && object.__lookupSetter__(propertyName);
    188             if (getter || setter) {
    189                 if (getter) {
    190                     var property = {};
    191                     property.name = "get " + propertyName;
    192                     property.value = this._wrapObject(getter, objectGroupName);
    193                     properties.push(property);
    194                 }
    195                 if (setter) {
    196                     var property = {};
    197                     property.name = "set " + propertyName;
    198                     property.value = this._wrapObject(setter, objectGroupName);
    199                     properties.push(property);
    200                 }
    201             } else {
    202                 var property = {};
    203                 property.name = propertyName;
    204                 var value;
    205                 try {
    206                     value = object[propertyName];
    207                 } catch(e) {
    208                     var value = e;
    209                     property.wasThrown = true;
    210                 }
    211                 property.value = this._wrapObject(value, objectGroupName);
    212                 properties.push(property);
    213             }
    214         }
    215         return properties;
     176        var descriptors = [];
     177        this._populatePropertyDescriptors(object, descriptors, ownProperties);
     178
     179        // Go over properties, wrap object values.
     180        for (var i = 0; i < descriptors.length; ++i) {
     181            var descriptor = descriptors[i];
     182            if (descriptor.get)
     183                descriptor.get = this._wrapObject(descriptor.get, objectGroupName);
     184            if (descriptor.set)
     185                descriptor.set = this._wrapObject(descriptor.set, objectGroupName);
     186            if ("value" in descriptor)
     187                descriptor.value = this._wrapObject(descriptor.value, objectGroupName);
     188        }
     189        return descriptors;
    216190    },
    217191
     
    228202    },
    229203
    230     _populatePropertyNames: function(object, resultSet)
    231     {
    232         for (var o = object; o; o = o.__proto__) {
    233             try {
    234                 var names = Object.getOwnPropertyNames(o);
    235                 for (var i = 0; i < names.length; ++i)
    236                     resultSet[names[i]] = true;
    237             } catch (e) {
     204    _populatePropertyDescriptors: function(object, descriptors, ownProperties)
     205    {
     206        var nameProcessed = {};
     207        nameProcessed.__proto__ = null;
     208        for (var o = object; this._isDefined(o); o = o.__proto__) {
     209            var names = Object.getOwnPropertyNames(o);
     210            for (var i = 0; i < names.length; ++i) {
     211                var name = names[i];
     212                if (nameProcessed[name])
     213                    continue;
     214
     215                try {
     216                    nameProcessed[name] = true;
     217                    var descriptor = Object.getOwnPropertyDescriptor(object, name);
     218                    if (!descriptor)
     219                        continue;
     220                } catch (e) {
     221                    var descriptor = {};
     222                    descriptor.value = e;
     223                    descriptor.wasThrown = true;
     224                }
     225
     226                descriptor.name = name;
     227                descriptors.push(descriptor);
    238228            }
    239         }
    240     },
    241 
    242     _getPropertyNames: function(object, resultSet)
    243     {
    244         var propertyNameSet = {};
    245         this._populatePropertyNames(object, propertyNameSet);
    246         return Object.keys(propertyNameSet);
     229            if (ownProperties) {
     230                if (object.__proto__)
     231                    descriptors.push({ name: "__proto__", value: object.__proto__, writable: true, configurable: true, enumerable: false});
     232                break;
     233            }
     234        }
    247235    },
    248236
  • trunk/Source/WebCore/inspector/Inspector.json

    r92377 r92670  
    237237            },
    238238            {
    239                 "id": "RemoteProperty",
    240                 "type": "object",
    241                 "description": "Mirror object property.",
    242                 "properties": [
    243                     { "name": "name", "type": "string", "description": "Property name." },
    244                     { "name": "value", "$ref": "RemoteObject", "description": "Property value." },
    245                     { "name": "wasThrown", "type": "boolean", "optional": true, "description": "True if exception was thrown on attempt to get the property value, in that case the value propery will contain thrown value." }
     239                "id": "PropertyDescriptor",
     240                "type": "object",
     241                "description": "Object property descriptor.",
     242                "properties": [
     243                    { "name": "value", "$ref": "RemoteObject", "description": "The value associated with the property." },
     244                    { "name": "writable", "type": "boolean", "description": "True iff the value associated with the property may be changed (data descriptors only)." },
     245                    { "name": "get", "$ref": "RemoteObject", "description": "A function which serves as a getter for the property, or <code>undefined</code> if there is no getter (accessor descriptors only)." },
     246                    { "name": "set", "$ref": "RemoteObject", "description": "A function which serves as a setter for the property, or <code>undefined</code> if there is no setter (accessor descriptors only)." },
     247                    { "name": "configurable", "type": "boolean", "description": "True iff the type of this property descriptor may be changed and if the property may be deleted from the corresponding object." },
     248                    { "name": "enumerable", "type": "boolean", "description": "True iff this property shows up during enumeration of the properties on the corresponding object." }
    246249                ]
    247250            },
     
    291294                "parameters": [
    292295                    { "name": "objectId", "$ref": "RemoteObjectId", "description": "Identifier of the object to return properties for." },
    293                     { "name": "ignoreHasOwnProperty", "type": "boolean", "description": "If true, returns properties belonging to any element of the prototype chain." }
    294                 ],
    295                 "returns": [
    296                     { "name": "result", "type": "array", "items": { "$ref": "RemoteProperty"}, "description": "Object properties." }
     296                    { "name": "ownProperties", "optional": true, "type": "boolean", "description": "If true, returns properties belonging only to the element itself, not to its prototype chain." }
     297                ],
     298                "returns": [
     299                    { "name": "result", "type": "array", "items": { "$ref": "PropertyDescriptor"}, "description": "Object properties." }
    297300                ],
    298301                "description": "Returns properties of a given object."
  • trunk/Source/WebCore/inspector/InspectorRuntimeAgent.cpp

    r92377 r92670  
    110110}
    111111
    112 void InspectorRuntimeAgent::getProperties(ErrorString* errorString, const String& objectId, bool ignoreHasOwnProperty, RefPtr<InspectorArray>* result)
     112void InspectorRuntimeAgent::getProperties(ErrorString* errorString, const String& objectId, const bool* const ownProperties, RefPtr<InspectorArray>* result)
    113113{
    114114    InjectedScript injectedScript = m_injectedScriptManager->injectedScriptForObjectId(objectId);
     
    117117        return;
    118118    }
    119     injectedScript.getProperties(errorString, objectId, ignoreHasOwnProperty, result);
     119    injectedScript.getProperties(errorString, objectId, ownProperties ? *ownProperties : false, result);
    120120}
    121121
  • trunk/Source/WebCore/inspector/InspectorRuntimeAgent.h

    r92377 r92670  
    7171                        bool* wasThrown);
    7272    void releaseObject(ErrorString*, const String& objectId);
    73     void getProperties(ErrorString*, const String& objectId, bool ignoreHasOwnProperty, RefPtr<InspectorArray>* result);
     73    void getProperties(ErrorString*, const String& objectId, const bool* const ownProperties, RefPtr<InspectorArray>* result);
    7474    void releaseObjectGroup(ErrorString*, const String& objectGroup);
    7575
  • trunk/Source/WebCore/inspector/front-end/ObjectPropertiesSection.js

    r92168 r92670  
    167167    ondblclick: function(event)
    168168    {
    169         this.startEditing();
     169        if (this.property.writable)
     170            this.startEditing();
    170171    },
    171172
     
    180181        this.nameElement.className = "name";
    181182        this.nameElement.textContent = this.property.name;
     183        if (!this.property.enumerable)
     184            this.nameElement.addStyleClass("dimmed");
    182185
    183186        var separatorElement = document.createElement("span");
  • trunk/Source/WebCore/inspector/front-end/RemoteObject.js

    r92122 r92670  
    117117    getOwnProperties: function(callback)
    118118    {
     119        this._getProperties(true, callback);
     120    },
     121
     122    getAllProperties: function(callback)
     123    {
    119124        this._getProperties(false, callback);
    120125    },
    121126
    122     getAllProperties: function(callback)
    123     {
    124         this._getProperties(true, callback);
    125     },
    126 
    127     _getProperties: function(ignoreHasOwnProperty, callback)
     127    _getProperties: function(ownProperties, callback)
    128128    {
    129129        if (!this._objectId) {
     
    137137                return;
    138138            }
    139             for (var i = 0; properties && i < properties.length; ++i)
    140                 properties[i].value = WebInspector.RemoteObject.fromPayload(properties[i].value);
    141             callback(properties);
    142         }
    143         RuntimeAgent.getProperties(this._objectId, !!ignoreHasOwnProperty, remoteObjectBinder);
     139            var result = [];
     140            for (var i = 0; properties && i < properties.length; ++i) {
     141                var property = properties[i];
     142                if (property.get || property.set) {
     143                    if (property.get)
     144                        result.push(new WebInspector.RemoteObjectProperty("get " + property.name, WebInspector.RemoteObject.fromPayload(property.get), property));
     145                    if (property.set)
     146                        result.push(new WebInspector.RemoteObjectProperty("set " + property.name, WebInspector.RemoteObject.fromPayload(property.set), property));
     147                } else
     148                    result.push(new WebInspector.RemoteObjectProperty(property.name, WebInspector.RemoteObject.fromPayload(property.value), property));
     149            }
     150            callback(result);
     151        }
     152        RuntimeAgent.getProperties(this._objectId, ownProperties, remoteObjectBinder);
    144153    },
    145154
     
    214223}
    215224
    216 WebInspector.RemoteObjectProperty = function(name, value)
     225WebInspector.RemoteObjectProperty = function(name, value, descriptor)
    217226{
    218227    this.name = name;
    219228    this.value = value;
     229    this.enumerable = descriptor ? !!descriptor.enumerable : true;
     230    this.writable = descriptor ? !!descriptor.writable : true;
     231    if (descriptor && descriptor.wasThrown)
     232        this.wasThrown = true;
    220233}
    221234
  • trunk/Source/WebCore/inspector/front-end/inspector.css

    r92168 r92670  
    16351635}
    16361636
    1637 .section .properties .value.dimmed {
    1638     color: rgb(100, 100, 100);
     1637.section .properties .dimmed {
     1638    opacity: 0.6;
    16391639}
    16401640
Note: See TracChangeset for help on using the changeset viewer.