⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 202666 in webkit


Ignore:
Timestamp:
Jun 29, 2016, 9:19:42 PM (10 years ago)
Author:
Joseph Pecoraro
Message:

Web Inspector: API View of Native DOM APIs looks poor (TypeErrors for native getters)
https://bugs.webkit.org/show_bug.cgi?id=158334
<rdar://problem/26615366>

Reviewed by Timothy Hatcher.

Source/JavaScriptCore:

  • inspector/InjectedScriptSource.js:

(InjectedScript.prototype._getProperties):
(InjectedScript.prototype._propertyDescriptors):
Do not create fake value property descriptors for native accessors
unless requested. This means, getProperties for a native prototype
should return accessors for native accessors just like it does
for normal non-native accessors (getters/setters).

(InjectedScript.prototype.getProperties):
Do not produce fake value accessors for native accessors.

(InjectedScript.prototype.getDisplayableProperties):
(InjectedScript.RemoteObject.prototype._generatePreview):
Do produce fake value accessors for native accessors.

LayoutTests:

  • inspector/runtime/getProperties-expected.txt:
  • inspector/runtime/getProperties.html:

Improve output for accessors now that getProperties
returns real accessor descriptors for native accessors
instead of fake value descriptors.

Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r202659 r202666  
     12016-06-29  Joseph Pecoraro  <pecoraro@apple.com>
     2
     3        Web Inspector: API View of Native DOM APIs looks poor (TypeErrors for native getters)
     4        https://bugs.webkit.org/show_bug.cgi?id=158334
     5        <rdar://problem/26615366>
     6
     7        Reviewed by Timothy Hatcher.
     8
     9        * inspector/runtime/getProperties-expected.txt:
     10        * inspector/runtime/getProperties.html:
     11        Improve output for accessors now that getProperties
     12        returns real accessor descriptors for native accessors
     13        instead of fake value descriptors.
     14
    1152016-06-29  Joseph Pecoraro  <pecoraro@apple.com>
    216
  • trunk/LayoutTests/inspector/runtime/getProperties-expected.txt

    r202568 r202666  
    2121    [native code]
    2222}
    23   arguments object TypeError: 'arguments', 'callee', and 'caller' cannot be accessed in strict mode.
    24   caller object TypeError: 'arguments', 'callee', and 'caller' cannot be accessed in strict mode.
     23  arguments getter setter
     24  caller getter setter
    2525  length number 0
    2626  name string bound Number
     
    3838    [native code]
    3939}
    40   arguments object TypeError: 'arguments', 'callee', and 'caller' cannot be accessed in strict mode.
    41   caller object TypeError: 'arguments', 'callee', and 'caller' cannot be accessed in strict mode.
     40  arguments getter setter
     41  caller getter setter
    4242  length number 0
    4343  name string bound
  • trunk/LayoutTests/inspector/runtime/getProperties.html

    r200746 r202666  
    8181
    8282        function dumpSingleProperty(property) {
    83             var {name, value} = property;
     83            var {name, value, get, set} = property;
    8484            if (value)
    85                 ProtocolTest.log("  " + name + " " + value.type + " " + (value.value || value.description));
     85                ProtocolTest.log(`  ${name} ${value.type} ${value.value || value.description}`);
     86            else if (get || set)
     87                ProtocolTest.log(`  ${name} ${get ? "getter" : "-"} ${set ? "setter" : ""}`);
    8688            else
    87                 ProtocolTest.log("  " + name);
     89                ProtocolTest.log(`  ${name}`);
    8890        }
    8991
  • trunk/Source/JavaScriptCore/ChangeLog

    r202664 r202666  
     12016-06-29  Joseph Pecoraro  <pecoraro@apple.com>
     2
     3        Web Inspector: API View of Native DOM APIs looks poor (TypeErrors for native getters)
     4        https://bugs.webkit.org/show_bug.cgi?id=158334
     5        <rdar://problem/26615366>
     6
     7        Reviewed by Timothy Hatcher.
     8
     9        * inspector/InjectedScriptSource.js:
     10        (InjectedScript.prototype._getProperties):
     11        (InjectedScript.prototype._propertyDescriptors):
     12        Do not create fake value property descriptors for native accessors
     13        unless requested. This means, getProperties for a native prototype
     14        should return  accessors for native accessors just like it does
     15        for normal non-native accessors (getters/setters).
     16
     17        (InjectedScript.prototype.getProperties):
     18        Do not produce fake value accessors for native accessors.
     19
     20        (InjectedScript.prototype.getDisplayableProperties):
     21        (InjectedScript.RemoteObject.prototype._generatePreview):
     22        Do produce fake value accessors for native accessors.
     23
    1242016-06-29  Saam barati  <sbarati@apple.com>
    225
  • trunk/Source/JavaScriptCore/inspector/InjectedScriptSource.js

    r202659 r202666  
    252252    },
    253253
    254     _getProperties: function(objectId, collectionMode, generatePreview)
     254    _getProperties: function(objectId, collectionMode, generatePreview, nativeGettersAsValues)
    255255    {
    256256        var parsedObjectId = this._parseObjectId(objectId);
     
    264264            return false;
    265265
    266         var descriptors = this._propertyDescriptors(object, collectionMode);
     266        var descriptors = this._propertyDescriptors(object, collectionMode, nativeGettersAsValues);
    267267
    268268        // Go over properties, wrap object values.
     
    288288    getProperties: function(objectId, ownProperties, generatePreview)
    289289    {
     290        var nativeGettersAsValues = false;
    290291        var collectionMode = ownProperties ? InjectedScript.CollectionMode.OwnProperties : InjectedScript.CollectionMode.AllProperties;
    291         return this._getProperties(objectId, collectionMode, generatePreview);
     292        return this._getProperties(objectId, collectionMode, generatePreview, nativeGettersAsValues);
    292293    },
    293294
    294295    getDisplayableProperties: function(objectId, generatePreview)
    295296    {
     297        var nativeGettersAsValues = true;
    296298        var collectionMode = InjectedScript.CollectionMode.OwnProperties | InjectedScript.CollectionMode.NativeGetterProperties;
    297         return this._getProperties(objectId, collectionMode, generatePreview);
     299        return this._getProperties(objectId, collectionMode, generatePreview, nativeGettersAsValues);
    298300    },
    299301
     
    571573    },
    572574
    573     _propertyDescriptors: function(object, collectionMode)
     575    _propertyDescriptors: function(object, collectionMode, nativeGettersAsValues)
    574576    {
    575577        var descriptors = [];
     
    613615            // Native Getter properties.
    614616            if (collectionMode & InjectedScript.CollectionMode.NativeGetterProperties) {
    615                 // FIXME: <https://webkit.org/b/140575> Web Inspector: Native Bindings Descriptors are Incomplete
    616                 // if (descriptor.hasOwnProperty("get") && descriptor.get && isNativeFunction(descriptor.get)) { ... }
    617 
    618617                if (possibleNativeBindingGetter) {
    619                     // Possible getter property in the prototype chain.
    620618                    descriptors.push(descriptor);
    621619                    return;
     
    645643                }
    646644
    647                 if (endsWith(String(descriptor.get), "[native code]\n}") ||
    648                      (!descriptor.get && descriptor.hasOwnProperty("get") && !descriptor.set && descriptor.hasOwnProperty("set"))) {
    649                     // FIXME: Some Native Bindings Descriptors are Incomplete
    650                     // <https://webkit.org/b/141585> Some IDL attributes appear on the instances instead of on prototypes
    651                     // Developers may create such a descriptors, so we should be resilient:
    652                     // var x = {}; Object.defineProperty(x, "p", {get:undefined}); Object.getOwnPropertyDescriptor(x, "p")
    653                     var fakeDescriptor = createFakeValueDescriptor(name, symbol, descriptor, isOwnProperty, true);
    654                     processDescriptor(fakeDescriptor, isOwnProperty, true);
    655                     continue;
     645                if (nativeGettersAsValues) {
     646                    if (endsWith(String(descriptor.get), "[native code]\n}") || (!descriptor.get && descriptor.hasOwnProperty("get") && !descriptor.set && descriptor.hasOwnProperty("set"))) {
     647                        // Developers may create such a descriptor, so we should be resilient:
     648                        // var x = {}; Object.defineProperty(x, "p", {get:undefined}); Object.getOwnPropertyDescriptor(x, "p")
     649                        var fakeDescriptor = createFakeValueDescriptor(name, symbol, descriptor, isOwnProperty, true);
     650                        processDescriptor(fakeDescriptor, isOwnProperty, true);
     651                        continue;
     652                    }
    656653                }
    657654
     
    10441041
    10451042            // Properties.
    1046             var descriptors = injectedScript._propertyDescriptors(object, InjectedScript.CollectionMode.AllProperties);
     1043            var nativeGettersAsValues = true;
     1044            var descriptors = injectedScript._propertyDescriptors(object, InjectedScript.CollectionMode.AllProperties, nativeGettersAsValues);
    10471045            this._appendPropertyPreviews(object, preview, descriptors, false, propertiesThreshold, firstLevelKeys, secondLevelKeys);
    10481046            if (propertiesThreshold.indexes < 0 || propertiesThreshold.properties < 0)
Note: See TracChangeset for help on using the changeset viewer.