Ignore:
Timestamp:
Jan 21, 2010, 12:46:03 PM (15 years ago)
Author:
[email protected]
Message:

2010-01-21 Kent Hansen <[email protected]>

Reviewed by Geoffrey Garen.

Object.getOwnPropertyDescriptor always returns undefined for JS API objects
https://bugs.webkit.org/show_bug.cgi?id=33946

Ideally the getOwnPropertyDescriptor() reimplementation should return an
access descriptor that wraps the property getter and setter callbacks, but
that approach is much more involved than returning a value descriptor.
Keep it simple for now.

  • API/JSCallbackObject.h:
  • API/JSCallbackObjectFunctions.h: (JSC::::getOwnPropertyDescriptor):
  • API/tests/testapi.js:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/API/JSCallbackObjectFunctions.h

    r53170 r53638  
    169169
    170170template <class Base>
     171bool JSCallbackObject<Base>::getOwnPropertyDescriptor(ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor)
     172{
     173    PropertySlot slot;
     174    if (getOwnPropertySlot(exec, propertyName, slot)) {
     175        // Ideally we should return an access descriptor, but returning a value descriptor is better than nothing.
     176        JSValue value = slot.getValue(exec, propertyName);
     177        if (!exec->hadException())
     178            descriptor.setValue(value);
     179        // We don't know whether the property is configurable, but assume it is.
     180        descriptor.setConfigurable(true);
     181        // We don't know whether the property is enumerable (we could call getOwnPropertyNames() to find out), but assume it isn't.
     182        descriptor.setEnumerable(false);
     183        return true;
     184    }
     185
     186    return Base::getOwnPropertyDescriptor(exec, propertyName, descriptor);
     187}
     188
     189template <class Base>
    171190void JSCallbackObject<Base>::put(ExecState* exec, const Identifier& propertyName, JSValue value, PutPropertySlot& slot)
    172191{
Note: See TracChangeset for help on using the changeset viewer.