Changeset 53170 in webkit


Ignore:
Timestamp:
Jan 12, 2010 4:58:21 PM (14 years ago)
Author:
eric@webkit.org
Message:

2010-01-12 Kent Hansen <kent.hansen@nokia.com>

Reviewed by Geoffrey Garen.

[ES5] Implement Object.getOwnPropertyNames
https://bugs.webkit.org/show_bug.cgi?id=32242

Add an extra argument to getPropertyNames() and getOwnPropertyNames()
(and all reimplementations thereof) that indicates whether non-enumerable
properties should be added.

  • API/JSCallbackObject.h:
  • API/JSCallbackObjectFunctions.h: (JSC::::getOwnPropertyNames):
  • JavaScriptCore.exp:
  • JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def:
  • debugger/DebuggerActivation.cpp: (JSC::DebuggerActivation::getOwnPropertyNames):
  • debugger/DebuggerActivation.h:
  • runtime/Arguments.cpp: (JSC::Arguments::getOwnPropertyNames):
  • runtime/Arguments.h:
  • runtime/CommonIdentifiers.h:
  • runtime/JSArray.cpp: (JSC::JSArray::getOwnPropertyNames):
  • runtime/JSArray.h:
  • runtime/JSByteArray.cpp: (JSC::JSByteArray::getOwnPropertyNames):
  • runtime/JSByteArray.h:
  • runtime/JSFunction.cpp: (JSC::JSFunction::getOwnPropertyNames):
  • runtime/JSFunction.h:
  • runtime/JSNotAnObject.cpp: (JSC::JSNotAnObject::getOwnPropertyNames):
  • runtime/JSNotAnObject.h:
  • runtime/JSObject.cpp: (JSC::getClassPropertyNames): (JSC::JSObject::getPropertyNames): (JSC::JSObject::getOwnPropertyNames):
  • runtime/JSObject.h:
  • runtime/JSVariableObject.cpp: (JSC::JSVariableObject::getOwnPropertyNames):
  • runtime/JSVariableObject.h:
  • runtime/ObjectConstructor.cpp: (JSC::ObjectConstructor::ObjectConstructor): (JSC::objectConstructorGetOwnPropertyNames):
  • runtime/RegExpMatchesArray.h: (JSC::RegExpMatchesArray::getOwnPropertyNames):
  • runtime/StringObject.cpp: (JSC::StringObject::getOwnPropertyNames):
  • runtime/StringObject.h:
  • runtime/Structure.cpp: Rename getEnumerablePropertyNames() to getPropertyNames(), which takes an extra argument. (JSC::Structure::getPropertyNames):
  • runtime/Structure.h: (JSC::):

2010-01-12 Kent Hansen <kent.hansen@nokia.com>

Reviewed by Geoffrey Garen.

[ES5] Implement Object.getOwnPropertyNames
https://bugs.webkit.org/show_bug.cgi?id=32242

Add new argument to the reimplementation of getOwnPropertyNames().

  • UserObjectImp.cpp: (UserObjectImp::getOwnPropertyNames):
  • UserObjectImp.h:

2010-01-12 Kent Hansen <kent.hansen@nokia.com>

Reviewed by Geoffrey Garen.

[ES5] Implement Object.getOwnPropertyNames
https://bugs.webkit.org/show_bug.cgi?id=32242

Add tests for Object.getOwnPropertyNames(o), both standard usage and cross origin.

  • fast/js/Object-getOwnPropertyNames-expected.txt: Added.
  • fast/js/Object-getOwnPropertyNames.html: Added.
  • fast/js/script-tests/Object-getOwnPropertyNames.js: Added.
  • http/tests/security/cross-frame-access-enumeration-expected.txt:
  • http/tests/security/cross-frame-access-enumeration.html:

2010-01-12 Kent Hansen <kent.hansen@nokia.com>

Reviewed by Geoffrey Garen.

[ES5] Implement Object.getOwnPropertyNames
https://bugs.webkit.org/show_bug.cgi?id=32242

Add new argument to reimplementations of getPropertyNames()
and getOwnPropertyNames(), and update the JS bindings generator.

Test: fast/js/Object-getOwnPropertyNames.html

  • bindings/js/JSDOMWindowCustom.cpp: (WebCore::JSDOMWindow::getPropertyNames): (WebCore::JSDOMWindow::getOwnPropertyNames):
  • bindings/js/JSDOMWindowShell.cpp: (WebCore::JSDOMWindowShell::getPropertyNames): (WebCore::JSDOMWindowShell::getOwnPropertyNames):
  • bindings/js/JSDOMWindowShell.h:
  • bindings/js/JSHistoryCustom.cpp: (WebCore::JSHistory::getOwnPropertyNames):
  • bindings/js/JSLocationCustom.cpp: (WebCore::JSLocation::getOwnPropertyNames):
  • bindings/js/JSQuarantinedObjectWrapper.cpp: (WebCore::JSQuarantinedObjectWrapper::getPropertyNames): (WebCore::JSQuarantinedObjectWrapper::getOwnPropertyNames):
  • bindings/js/JSQuarantinedObjectWrapper.h:
  • bindings/js/JSStorageCustom.cpp: (WebCore::JSStorage::getOwnPropertyNames):
  • bindings/scripts/CodeGeneratorJS.pm:
  • bridge/runtime_array.cpp: (JSC::RuntimeArray::getOwnPropertyNames):
  • bridge/runtime_array.h:
  • bridge/runtime_object.cpp: (JSC::RuntimeObjectImp::getPropertyNames): (JSC::RuntimeObjectImp::getOwnPropertyNames):
  • bridge/runtime_object.h:
Location:
trunk
Files:
3 added
48 edited

Legend:

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

    r49721 r53170  
    7070    virtual bool hasInstance(ExecState* exec, JSValue value, JSValue proto);
    7171
    72     virtual void getOwnPropertyNames(ExecState*, PropertyNameArray&);
     72    virtual void getOwnPropertyNames(ExecState*, PropertyNameArray&, EnumerationMode mode = ExcludeDontEnumProperties);
    7373
    7474    virtual double toNumber(ExecState*) const;
  • trunk/JavaScriptCore/API/JSCallbackObjectFunctions.h

    r52751 r53170  
    381381
    382382template <class Base>
    383 void JSCallbackObject<Base>::getOwnPropertyNames(ExecState* exec, PropertyNameArray& propertyNames)
     383void JSCallbackObject<Base>::getOwnPropertyNames(ExecState* exec, PropertyNameArray& propertyNames, EnumerationMode mode)
    384384{
    385385    JSContextRef execRef = toRef(exec);
     
    398398                UString::Rep* name = it->first.get();
    399399                StaticValueEntry* entry = it->second;
    400                 if (entry->getProperty && !(entry->attributes & kJSPropertyAttributeDontEnum))
     400                if (entry->getProperty && (!(entry->attributes & kJSPropertyAttributeDontEnum) || (mode == IncludeDontEnumProperties)))
    401401                    propertyNames.add(Identifier(exec, name));
    402402            }
     
    409409                UString::Rep* name = it->first.get();
    410410                StaticFunctionEntry* entry = it->second;
    411                 if (!(entry->attributes & kJSPropertyAttributeDontEnum))
     411                if (!(entry->attributes & kJSPropertyAttributeDontEnum) || (mode == IncludeDontEnumProperties))
    412412                    propertyNames.add(Identifier(exec, name));
    413413            }
     
    415415    }
    416416   
    417     Base::getOwnPropertyNames(exec, propertyNames);
     417    Base::getOwnPropertyNames(exec, propertyNames, mode);
    418418}
    419419
  • trunk/JavaScriptCore/ChangeLog

    r53151 r53170  
     12010-01-12  Kent Hansen  <kent.hansen@nokia.com>
     2
     3        Reviewed by Geoffrey Garen.
     4
     5        [ES5] Implement Object.getOwnPropertyNames
     6        https://bugs.webkit.org/show_bug.cgi?id=32242
     7
     8        Add an extra argument to getPropertyNames() and getOwnPropertyNames()
     9        (and all reimplementations thereof) that indicates whether non-enumerable
     10        properties should be added.
     11
     12        * API/JSCallbackObject.h:
     13        * API/JSCallbackObjectFunctions.h:
     14        (JSC::::getOwnPropertyNames):
     15        * JavaScriptCore.exp:
     16        * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def:
     17        * debugger/DebuggerActivation.cpp:
     18        (JSC::DebuggerActivation::getOwnPropertyNames):
     19        * debugger/DebuggerActivation.h:
     20        * runtime/Arguments.cpp:
     21        (JSC::Arguments::getOwnPropertyNames):
     22        * runtime/Arguments.h:
     23        * runtime/CommonIdentifiers.h:
     24        * runtime/JSArray.cpp:
     25        (JSC::JSArray::getOwnPropertyNames):
     26        * runtime/JSArray.h:
     27        * runtime/JSByteArray.cpp:
     28        (JSC::JSByteArray::getOwnPropertyNames):
     29        * runtime/JSByteArray.h:
     30        * runtime/JSFunction.cpp:
     31        (JSC::JSFunction::getOwnPropertyNames):
     32        * runtime/JSFunction.h:
     33        * runtime/JSNotAnObject.cpp:
     34        (JSC::JSNotAnObject::getOwnPropertyNames):
     35        * runtime/JSNotAnObject.h:
     36        * runtime/JSObject.cpp:
     37        (JSC::getClassPropertyNames):
     38        (JSC::JSObject::getPropertyNames):
     39        (JSC::JSObject::getOwnPropertyNames):
     40        * runtime/JSObject.h:
     41        * runtime/JSVariableObject.cpp:
     42        (JSC::JSVariableObject::getOwnPropertyNames):
     43        * runtime/JSVariableObject.h:
     44        * runtime/ObjectConstructor.cpp:
     45        (JSC::ObjectConstructor::ObjectConstructor):
     46        (JSC::objectConstructorGetOwnPropertyNames):
     47        * runtime/RegExpMatchesArray.h:
     48        (JSC::RegExpMatchesArray::getOwnPropertyNames):
     49        * runtime/StringObject.cpp:
     50        (JSC::StringObject::getOwnPropertyNames):
     51        * runtime/StringObject.h:
     52        * runtime/Structure.cpp: Rename getEnumerablePropertyNames() to getPropertyNames(), which takes an extra argument.
     53        (JSC::Structure::getPropertyNames):
     54        * runtime/Structure.h:
     55        (JSC::):
     56
    1572010-01-12  Alexey Proskuryakov  <ap@apple.com>
    258
  • trunk/JavaScriptCore/JavaScriptCore.exp

    r52961 r53170  
    127127__ZN3JSC12StringObject18getOwnPropertySlotEPNS_9ExecStateERKNS_10IdentifierERNS_12PropertySlotE
    128128__ZN3JSC12StringObject18getOwnPropertySlotEPNS_9ExecStateEjRNS_12PropertySlotE
    129 __ZN3JSC12StringObject19getOwnPropertyNamesEPNS_9ExecStateERNS_17PropertyNameArrayE
     129__ZN3JSC12StringObject19getOwnPropertyNamesEPNS_9ExecStateERNS_17PropertyNameArrayENS_15EnumerationModeE
    130130__ZN3JSC12StringObject24getOwnPropertyDescriptorEPNS_9ExecStateERKNS_10IdentifierERNS_18PropertyDescriptorE
    131131__ZN3JSC12StringObject3putEPNS_9ExecStateERKNS_10IdentifierENS_7JSValueERNS_15PutPropertySlotE
     
    160160__ZN3JSC16JSVariableObject14deletePropertyEPNS_9ExecStateERKNS_10IdentifierE
    161161__ZN3JSC16JSVariableObject14symbolTableGetERKNS_10IdentifierERNS_18PropertyDescriptorE
    162 __ZN3JSC16JSVariableObject19getOwnPropertyNamesEPNS_9ExecStateERNS_17PropertyNameArrayE
     162__ZN3JSC16JSVariableObject19getOwnPropertyNamesEPNS_9ExecStateERNS_17PropertyNameArrayENS_15EnumerationModeE
    163163__ZN3JSC16toUInt32SlowCaseEdRb
    164164__ZN3JSC17BytecodeGenerator21setDumpsGeneratedCodeEb
     
    254254__ZN3JSC8JSObject14deletePropertyEPNS_9ExecStateEj
    255255__ZN3JSC8JSObject15unwrappedObjectEv
    256 __ZN3JSC8JSObject16getPropertyNamesEPNS_9ExecStateERNS_17PropertyNameArrayE
     256__ZN3JSC8JSObject16getPropertyNamesEPNS_9ExecStateERNS_17PropertyNameArrayENS_15EnumerationModeE
    257257__ZN3JSC8JSObject17createInheritorIDEv
    258258__ZN3JSC8JSObject17defineOwnPropertyEPNS_9ExecStateERKNS_10IdentifierERNS_18PropertyDescriptorEb
     
    263263__ZN3JSC8JSObject18getOwnPropertySlotEPNS_9ExecStateEjRNS_12PropertySlotE
    264264__ZN3JSC8JSObject18getPrimitiveNumberEPNS_9ExecStateERdRNS_7JSValueE
    265 __ZN3JSC8JSObject19getOwnPropertyNamesEPNS_9ExecStateERNS_17PropertyNameArrayE
     265__ZN3JSC8JSObject19getOwnPropertyNamesEPNS_9ExecStateERNS_17PropertyNameArrayENS_15EnumerationModeE
    266266__ZN3JSC8JSObject21getPropertyDescriptorEPNS_9ExecStateERKNS_10IdentifierERNS_18PropertyDescriptorE
    267267__ZN3JSC8JSObject22fillGetterPropertySlotERNS_12PropertySlotEPNS_7JSValueE 
  • trunk/JavaScriptCore/JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def

    r53087 r53170  
    139139    ?getOwnPropertyDescriptor@JSString@JSC@@EAE_NPAVExecState@2@ABVIdentifier@2@AAVPropertyDescriptor@2@@Z
    140140    ?getOwnPropertyDescriptor@StringObject@JSC@@UAE_NPAVExecState@2@ABVIdentifier@2@AAVPropertyDescriptor@2@@Z
    141     ?getOwnPropertyNames@JSObject@JSC@@UAEXPAVExecState@2@AAVPropertyNameArray@2@@Z
    142     ?getOwnPropertyNames@JSVariableObject@JSC@@UAEXPAVExecState@2@AAVPropertyNameArray@2@@Z
    143     ?getOwnPropertyNames@StringObject@JSC@@UAEXPAVExecState@2@AAVPropertyNameArray@2@@Z
     141    ?getOwnPropertyNames@JSObject@JSC@@UAEXPAVExecState@2@AAVPropertyNameArray@2@W4EnumerationMode@2@@Z
     142    ?getOwnPropertyNames@JSVariableObject@JSC@@UAEXPAVExecState@2@AAVPropertyNameArray@2@W4EnumerationMode@2@@Z
     143    ?getOwnPropertyNames@StringObject@JSC@@UAEXPAVExecState@2@AAVPropertyNameArray@2@W4EnumerationMode@2@@Z
    144144    ?getOwnPropertySlot@JSCell@JSC@@EAE_NPAVExecState@2@ABVIdentifier@2@AAVPropertySlot@2@@Z
    145145    ?getOwnPropertySlot@JSCell@JSC@@EAE_NPAVExecState@2@IAAVPropertySlot@2@@Z
     
    153153    ?getPrimitiveNumber@JSString@JSC@@EAE_NPAVExecState@2@AANAAVJSValue@2@@Z
    154154    ?getPropertyDescriptor@JSObject@JSC@@QAE_NPAVExecState@2@ABVIdentifier@2@AAVPropertyDescriptor@2@@Z
    155     ?getPropertyNames@JSObject@JSC@@UAEXPAVExecState@2@AAVPropertyNameArray@2@@Z
     155    ?getPropertyNames@JSObject@JSC@@UAEXPAVExecState@2@AAVPropertyNameArray@2@W4EnumerationMode@2@@Z
    156156    ?getSlice@ArgList@JSC@@QBEXHAAV12@@Z
    157157    ?getString@JSCell@JSC@@QBE?AVUString@2@PAVExecState@2@@Z
  • trunk/JavaScriptCore/debugger/DebuggerActivation.cpp

    r51971 r53170  
    7272}
    7373
    74 void DebuggerActivation::getOwnPropertyNames(ExecState* exec, PropertyNameArray& propertyNames)
     74void DebuggerActivation::getOwnPropertyNames(ExecState* exec, PropertyNameArray& propertyNames, EnumerationMode mode)
    7575{
    76     m_activation->getPropertyNames(exec, propertyNames);
     76    m_activation->getPropertyNames(exec, propertyNames, mode);
    7777}
    7878
  • trunk/JavaScriptCore/debugger/DebuggerActivation.h

    r51971 r53170  
    4343        virtual void putWithAttributes(ExecState*, const Identifier& propertyName, JSValue, unsigned attributes);
    4444        virtual bool deleteProperty(ExecState*, const Identifier& propertyName);
    45         virtual void getOwnPropertyNames(ExecState*, PropertyNameArray&);
     45        virtual void getOwnPropertyNames(ExecState*, PropertyNameArray&, EnumerationMode mode = ExcludeDontEnumProperties);
    4646        virtual bool getOwnPropertyDescriptor(ExecState*, const Identifier&, PropertyDescriptor&);
    4747        virtual void defineGetter(ExecState*, const Identifier& propertyName, JSObject* getterFunction, unsigned attributes);
  • trunk/JavaScriptCore/runtime/Arguments.cpp

    r47780 r53170  
    205205}
    206206
     207void Arguments::getOwnPropertyNames(ExecState* exec, PropertyNameArray& propertyNames, EnumerationMode mode)
     208{
     209    if (mode == IncludeDontEnumProperties) {
     210        for (unsigned i = 0; i < d->numArguments; ++i) {
     211            if (!d->deletedArguments || !d->deletedArguments[i])
     212                propertyNames.add(Identifier(exec, UString::from(i)));
     213        }
     214        propertyNames.add(exec->propertyNames().callee);
     215        propertyNames.add(exec->propertyNames().length);
     216    }
     217    JSObject::getOwnPropertyNames(exec, propertyNames, mode);
     218}
     219
    207220void Arguments::put(ExecState* exec, unsigned i, JSValue value, PutPropertySlot& slot)
    208221{
  • trunk/JavaScriptCore/runtime/Arguments.h

    r49721 r53170  
    9797        virtual bool getOwnPropertySlot(ExecState*, unsigned propertyName, PropertySlot&);
    9898        virtual bool getOwnPropertyDescriptor(ExecState*, const Identifier&, PropertyDescriptor&);
     99        virtual void getOwnPropertyNames(ExecState*, PropertyNameArray&, EnumerationMode mode = ExcludeDontEnumProperties);
    99100        virtual void put(ExecState*, const Identifier& propertyName, JSValue, PutPropertySlot&);
    100101        virtual void put(ExecState*, unsigned propertyName, JSValue, PutPropertySlot&);
  • trunk/JavaScriptCore/runtime/CommonIdentifiers.h

    r48568 r53170  
    5151    macro(getPrototypeOf) \
    5252    macro(getOwnPropertyDescriptor) \
     53    macro(getOwnPropertyNames) \
    5354    macro(hasOwnProperty) \
    5455    macro(ignoreCase) \
  • trunk/JavaScriptCore/runtime/JSArray.cpp

    r53091 r53170  
    470470}
    471471
    472 void JSArray::getOwnPropertyNames(ExecState* exec, PropertyNameArray& propertyNames)
     472void JSArray::getOwnPropertyNames(ExecState* exec, PropertyNameArray& propertyNames, EnumerationMode mode)
    473473{
    474474    // FIXME: Filling PropertyNameArray with an identifier for every integer
     
    490490    }
    491491
    492     JSObject::getOwnPropertyNames(exec, propertyNames);
     492    if (mode == IncludeDontEnumProperties)
     493        propertyNames.add(exec->propertyNames().length);
     494
     495    JSObject::getOwnPropertyNames(exec, propertyNames, mode);
    493496}
    494497
  • trunk/JavaScriptCore/runtime/JSArray.h

    r53025 r53170  
    9999        virtual bool deleteProperty(ExecState*, const Identifier& propertyName);
    100100        virtual bool deleteProperty(ExecState*, unsigned propertyName);
    101         virtual void getOwnPropertyNames(ExecState*, PropertyNameArray&);
     101        virtual void getOwnPropertyNames(ExecState*, PropertyNameArray&, EnumerationMode mode = ExcludeDontEnumProperties);
    102102        virtual void markChildren(MarkStack&);
    103103
  • trunk/JavaScriptCore/runtime/JSByteArray.cpp

    r52956 r53170  
    105105}
    106106
    107 void JSByteArray::getOwnPropertyNames(ExecState* exec, PropertyNameArray& propertyNames)
     107void JSByteArray::getOwnPropertyNames(ExecState* exec, PropertyNameArray& propertyNames, EnumerationMode mode)
    108108{
    109109    unsigned length = m_storage->length();
    110110    for (unsigned i = 0; i < length; ++i)
    111111        propertyNames.add(Identifier::from(exec, i));
    112     JSObject::getOwnPropertyNames(exec, propertyNames);
     112    JSObject::getOwnPropertyNames(exec, propertyNames, mode);
    113113}
    114114
  • trunk/JavaScriptCore/runtime/JSByteArray.h

    r52956 r53170  
    8383        virtual void put(JSC::ExecState*, unsigned propertyName, JSC::JSValue);
    8484
    85         virtual void getOwnPropertyNames(JSC::ExecState*, JSC::PropertyNameArray&);
     85        virtual void getOwnPropertyNames(JSC::ExecState*, JSC::PropertyNameArray&, EnumerationMode mode = ExcludeDontEnumProperties);
    8686
    8787        virtual const ClassInfo* classInfo() const { return m_classInfo; }
  • trunk/JavaScriptCore/runtime/JSFunction.cpp

    r52956 r53170  
    209209    }
    210210   
     211void JSFunction::getOwnPropertyNames(ExecState* exec, PropertyNameArray& propertyNames, EnumerationMode mode)
     212{
     213    if (!isHostFunction() && (mode == IncludeDontEnumProperties)) {
     214        propertyNames.add(exec->propertyNames().arguments);
     215        propertyNames.add(exec->propertyNames().callee);
     216        propertyNames.add(exec->propertyNames().caller);
     217        propertyNames.add(exec->propertyNames().length);
     218    }
     219    Base::getOwnPropertyNames(exec, propertyNames, mode);
     220}
     221
    211222void JSFunction::put(ExecState* exec, const Identifier& propertyName, JSValue value, PutPropertySlot& slot)
    212223{
  • trunk/JavaScriptCore/runtime/JSFunction.h

    r52956 r53170  
    8383        virtual bool getOwnPropertySlot(ExecState*, const Identifier&, PropertySlot&);
    8484        virtual bool getOwnPropertyDescriptor(ExecState*, const Identifier&, PropertyDescriptor&);
     85        virtual void getOwnPropertyNames(ExecState*, PropertyNameArray&, EnumerationMode mode = ExcludeDontEnumProperties);
    8586        virtual void put(ExecState*, const Identifier& propertyName, JSValue, PutPropertySlot&);
    8687        virtual bool deleteProperty(ExecState*, const Identifier& propertyName);
  • trunk/JavaScriptCore/runtime/JSNotAnObject.cpp

    r48336 r53170  
    122122}
    123123
    124 void JSNotAnObject::getOwnPropertyNames(ExecState* exec, PropertyNameArray&)
     124void JSNotAnObject::getOwnPropertyNames(ExecState* exec, PropertyNameArray&, EnumerationMode)
    125125{
    126126    ASSERT_UNUSED(exec, exec->hadException() && exec->exception() == m_exception);
  • trunk/JavaScriptCore/runtime/JSNotAnObject.h

    r49721 r53170  
    9292        virtual bool deleteProperty(ExecState*, unsigned propertyName);
    9393
    94         virtual void getOwnPropertyNames(ExecState*, PropertyNameArray&);
     94        virtual void getOwnPropertyNames(ExecState*, PropertyNameArray&, EnumerationMode mode = ExcludeDontEnumProperties);
    9595
    9696        JSNotAnObjectErrorStub* m_exception;
  • trunk/JavaScriptCore/runtime/JSObject.cpp

    r51971 r53170  
    4343ASSERT_CLASS_FITS_IN_CELL(JSObject);
    4444
    45 static inline void getEnumerablePropertyNames(ExecState* exec, const ClassInfo* classInfo, PropertyNameArray& propertyNames)
     45static inline void getClassPropertyNames(ExecState* exec, const ClassInfo* classInfo, PropertyNameArray& propertyNames, EnumerationMode mode)
    4646{
    4747    // Add properties from the static hashtables of properties
     
    5656        const HashEntry* entry = table->table;
    5757        for (int i = 0; i <= hashSizeMask; ++i, ++entry) {
    58             if (entry->key() && !(entry->attributes() & DontEnum))
     58            if (entry->key() && (!(entry->attributes() & DontEnum) || (mode == IncludeDontEnumProperties)))
    5959                propertyNames.add(entry->key());
    6060        }
     
    426426}
    427427
    428 void JSObject::getPropertyNames(ExecState* exec, PropertyNameArray& propertyNames)
    429 {
    430     getOwnPropertyNames(exec, propertyNames);
     428void JSObject::getPropertyNames(ExecState* exec, PropertyNameArray& propertyNames, EnumerationMode mode)
     429{
     430    getOwnPropertyNames(exec, propertyNames, mode);
    431431
    432432    if (prototype().isNull())
     
    436436    while(1) {
    437437        if (prototype->structure()->typeInfo().overridesGetPropertyNames()) {
    438             prototype->getPropertyNames(exec, propertyNames);
     438            prototype->getPropertyNames(exec, propertyNames, mode);
    439439            break;
    440440        }
    441         prototype->getOwnPropertyNames(exec, propertyNames);
     441        prototype->getOwnPropertyNames(exec, propertyNames, mode);
    442442        JSValue nextProto = prototype->prototype();
    443443        if (nextProto.isNull())
     
    447447}
    448448
    449 void JSObject::getOwnPropertyNames(ExecState* exec, PropertyNameArray& propertyNames)
    450 {
    451     m_structure->getEnumerablePropertyNames(propertyNames);
    452     getEnumerablePropertyNames(exec, classInfo(), propertyNames);
     449void JSObject::getOwnPropertyNames(ExecState* exec, PropertyNameArray& propertyNames, EnumerationMode mode)
     450{
     451    m_structure->getPropertyNames(propertyNames, mode);
     452    getClassPropertyNames(exec, classInfo(), propertyNames, mode);
    453453}
    454454
  • trunk/JavaScriptCore/runtime/JSObject.h

    r51971 r53170  
    123123        virtual bool hasInstance(ExecState*, JSValue, JSValue prototypeProperty);
    124124
    125         virtual void getPropertyNames(ExecState*, PropertyNameArray&);
    126         virtual void getOwnPropertyNames(ExecState*, PropertyNameArray&);
     125        virtual void getPropertyNames(ExecState*, PropertyNameArray&, EnumerationMode mode = ExcludeDontEnumProperties);
     126        virtual void getOwnPropertyNames(ExecState*, PropertyNameArray&, EnumerationMode mode = ExcludeDontEnumProperties);
    127127
    128128        virtual JSValue toPrimitive(ExecState*, PreferredPrimitiveType = NoPreference) const;
  • trunk/JavaScriptCore/runtime/JSVariableObject.cpp

    r51971 r53170  
    4343}
    4444
    45 void JSVariableObject::getOwnPropertyNames(ExecState* exec, PropertyNameArray& propertyNames)
     45void JSVariableObject::getOwnPropertyNames(ExecState* exec, PropertyNameArray& propertyNames, EnumerationMode mode)
    4646{
    4747    SymbolTable::const_iterator end = symbolTable().end();
    4848    for (SymbolTable::const_iterator it = symbolTable().begin(); it != end; ++it) {
    49         if (!(it->second.getAttributes() & DontEnum))
     49        if (!(it->second.getAttributes() & DontEnum) || (mode == IncludeDontEnumProperties))
    5050            propertyNames.add(Identifier(exec, it->first.get()));
    5151    }
    5252   
    53     JSObject::getOwnPropertyNames(exec, propertyNames);
     53    JSObject::getOwnPropertyNames(exec, propertyNames, mode);
    5454}
    5555
  • trunk/JavaScriptCore/runtime/JSVariableObject.h

    r51971 r53170  
    5050
    5151        virtual bool deleteProperty(ExecState*, const Identifier&);
    52         virtual void getOwnPropertyNames(ExecState*, PropertyNameArray&);
     52        virtual void getOwnPropertyNames(ExecState*, PropertyNameArray&, EnumerationMode mode = ExcludeDontEnumProperties);
    5353       
    5454        virtual bool isVariableObject() const;
  • trunk/JavaScriptCore/runtime/ObjectConstructor.cpp

    r51760 r53170  
    3737static JSValue JSC_HOST_CALL objectConstructorGetPrototypeOf(ExecState*, JSObject*, JSValue, const ArgList&);
    3838static JSValue JSC_HOST_CALL objectConstructorGetOwnPropertyDescriptor(ExecState*, JSObject*, JSValue, const ArgList&);
     39static JSValue JSC_HOST_CALL objectConstructorGetOwnPropertyNames(ExecState*, JSObject*, JSValue, const ArgList&);
    3940static JSValue JSC_HOST_CALL objectConstructorKeys(ExecState*, JSObject*, JSValue, const ArgList&);
    4041static JSValue JSC_HOST_CALL objectConstructorDefineProperty(ExecState*, JSObject*, JSValue, const ArgList&);
     
    5354    putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, prototypeFunctionStructure, 1, exec->propertyNames().getPrototypeOf, objectConstructorGetPrototypeOf), DontEnum);
    5455    putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, prototypeFunctionStructure, 2, exec->propertyNames().getOwnPropertyDescriptor, objectConstructorGetOwnPropertyDescriptor), DontEnum);
     56    putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, prototypeFunctionStructure, 1, exec->propertyNames().getOwnPropertyNames, objectConstructorGetOwnPropertyNames), DontEnum);
    5557    putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, prototypeFunctionStructure, 1, exec->propertyNames().keys, objectConstructorKeys), DontEnum);
    5658    putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, prototypeFunctionStructure, 3, exec->propertyNames().defineProperty, objectConstructorDefineProperty), DontEnum);
     
    124126
    125127    return description;
     128}
     129
     130// FIXME: Use the enumeration cache.
     131JSValue JSC_HOST_CALL objectConstructorGetOwnPropertyNames(ExecState* exec, JSObject*, JSValue, const ArgList& args)
     132{
     133    if (!args.at(0).isObject())
     134        return throwError(exec, TypeError, "Requested property names of a value that is not an object.");
     135    PropertyNameArray properties(exec);
     136    asObject(args.at(0))->getOwnPropertyNames(exec, properties, IncludeDontEnumProperties);
     137    JSArray* names = constructEmptyArray(exec);
     138    size_t numProperties = properties.size();
     139    for (size_t i = 0; i < numProperties; i++)
     140        names->push(exec, jsOwnedString(exec, properties[i].ustring()));
     141    return names;
    126142}
    127143
  • trunk/JavaScriptCore/runtime/RegExpMatchesArray.h

    r48336 r53170  
    8080        }
    8181
    82         virtual void getOwnPropertyNames(ExecState* exec, PropertyNameArray& arr)
     82        virtual void getOwnPropertyNames(ExecState* exec, PropertyNameArray& arr, EnumerationMode mode = ExcludeDontEnumProperties)
    8383        {
    8484            if (lazyCreationData())
    8585                fillArrayInstance(exec);
    86             JSArray::getOwnPropertyNames(exec, arr);
     86            JSArray::getOwnPropertyNames(exec, arr, mode);
    8787        }
    8888
  • trunk/JavaScriptCore/runtime/StringObject.cpp

    r51724 r53170  
    8787}
    8888
    89 void StringObject::getOwnPropertyNames(ExecState* exec, PropertyNameArray& propertyNames)
     89void StringObject::getOwnPropertyNames(ExecState* exec, PropertyNameArray& propertyNames, EnumerationMode mode)
    9090{
    9191    int size = internalValue()->length();
    9292    for (int i = 0; i < size; ++i)
    9393        propertyNames.add(Identifier(exec, UString::from(i)));
    94     return JSObject::getOwnPropertyNames(exec, propertyNames);
     94    if (mode == IncludeDontEnumProperties)
     95        propertyNames.add(exec->propertyNames().length);
     96    return JSObject::getOwnPropertyNames(exec, propertyNames, mode);
    9597}
    9698
  • trunk/JavaScriptCore/runtime/StringObject.h

    r49721 r53170  
    4040        virtual void put(ExecState* exec, const Identifier& propertyName, JSValue, PutPropertySlot&);
    4141        virtual bool deleteProperty(ExecState*, const Identifier& propertyName);
    42         virtual void getOwnPropertyNames(ExecState*, PropertyNameArray&);
     42        virtual void getOwnPropertyNames(ExecState*, PropertyNameArray&, EnumerationMode mode = ExcludeDontEnumProperties);
    4343
    4444        virtual const ClassInfo* classInfo() const { return &info; }
  • trunk/JavaScriptCore/runtime/Structure.cpp

    r52948 r53170  
    10751075}
    10761076
    1077 void Structure::getEnumerablePropertyNames(PropertyNameArray& propertyNames)
     1077void Structure::getPropertyNames(PropertyNameArray& propertyNames, EnumerationMode mode)
    10781078{
    10791079    materializePropertyMapIfNecessary();
     
    10871087        for (unsigned k = 1; k <= entryCount; k++) {
    10881088            ASSERT(m_hasNonEnumerableProperties || !(m_propertyTable->entries()[k].attributes & DontEnum));
    1089             if (m_propertyTable->entries()[k].key && !(m_propertyTable->entries()[k].attributes & DontEnum)) {
     1089            if (m_propertyTable->entries()[k].key && (!(m_propertyTable->entries()[k].attributes & DontEnum) || (mode == IncludeDontEnumProperties))) {
    10901090                PropertyMapEntry* value = &m_propertyTable->entries()[k];
    10911091                int j;
     
    11141114    unsigned entryCount = m_propertyTable->keyCount + m_propertyTable->deletedSentinelCount;
    11151115    for (unsigned i = 1; i <= entryCount; i++) {
    1116         if (m_propertyTable->entries()[i].key && !(m_propertyTable->entries()[i].attributes & DontEnum))
     1116        if (m_propertyTable->entries()[i].key && (!(m_propertyTable->entries()[i].attributes & DontEnum) || (mode == IncludeDontEnumProperties)))
    11171117            *p++ = &m_propertyTable->entries()[i];
    11181118    }
  • trunk/JavaScriptCore/runtime/Structure.h

    r52948 r53170  
    5252    class PropertyNameArrayData;
    5353
     54    enum EnumerationMode {
     55        ExcludeDontEnumProperties,
     56        IncludeDontEnumProperties
     57    };
     58
    5459    class Structure : public RefCounted<Structure> {
    5560    public:
     
    132137        void setEnumerationCache(JSPropertyNameIterator* enumerationCache); // Defined in JSPropertyNameIterator.h.
    133138        JSPropertyNameIterator* enumerationCache() { return m_enumerationCache.get(); }
    134         void getEnumerablePropertyNames(PropertyNameArray&);
     139        void getPropertyNames(PropertyNameArray&, EnumerationMode mode);
    135140       
    136141    private:
  • trunk/JavaScriptGlue/ChangeLog

    r52959 r53170  
     12010-01-12  Kent Hansen  <kent.hansen@nokia.com>
     2
     3        Reviewed by Geoffrey Garen.
     4
     5        [ES5] Implement Object.getOwnPropertyNames
     6        https://bugs.webkit.org/show_bug.cgi?id=32242
     7
     8        Add new argument to the reimplementation of getOwnPropertyNames().
     9
     10        * UserObjectImp.cpp:
     11        (UserObjectImp::getOwnPropertyNames):
     12        * UserObjectImp.h:
     13
    1142010-01-07  Alexey Proskuryakov  <ap@apple.com>
    215
  • trunk/JavaScriptGlue/UserObjectImp.cpp

    r52856 r53170  
    9595
    9696
    97 void UserObjectImp::getOwnPropertyNames(ExecState *exec, PropertyNameArray& propertyNames)
     97void UserObjectImp::getOwnPropertyNames(ExecState *exec, PropertyNameArray& propertyNames, EnumerationMode mode)
    9898{
    9999    JSUserObject* ptr = GetJSUserObject();
     
    110110        }
    111111    }
    112     JSObject::getOwnPropertyNames(exec, propertyNames);
     112    JSObject::getOwnPropertyNames(exec, propertyNames, mode);
    113113}
    114114
  • trunk/JavaScriptGlue/UserObjectImp.h

    r49694 r53170  
    4545    virtual CallType getCallData(CallData&);
    4646
    47     virtual void getOwnPropertyNames(ExecState*, PropertyNameArray&);
     47    virtual void getOwnPropertyNames(ExecState*, PropertyNameArray&, EnumerationMode mode = ExcludeDontEnumProperties);
    4848
    4949    virtual JSValue callAsFunction(ExecState *exec, JSObject *thisObj, const ArgList &args);
  • trunk/LayoutTests/ChangeLog

    r53169 r53170  
     12010-01-12  Kent Hansen  <kent.hansen@nokia.com>
     2
     3        Reviewed by Geoffrey Garen.
     4
     5        [ES5] Implement Object.getOwnPropertyNames
     6        https://bugs.webkit.org/show_bug.cgi?id=32242
     7
     8        Add tests for Object.getOwnPropertyNames(o), both standard usage and cross origin.
     9
     10        * fast/js/Object-getOwnPropertyNames-expected.txt: Added.
     11        * fast/js/Object-getOwnPropertyNames.html: Added.
     12        * fast/js/script-tests/Object-getOwnPropertyNames.js: Added.
     13        * http/tests/security/cross-frame-access-enumeration-expected.txt:
     14        * http/tests/security/cross-frame-access-enumeration.html:
     15
    1162010-01-12  Brian Weinstein  <bweinstein@apple.com>
    217
  • trunk/LayoutTests/http/tests/security/cross-frame-access-enumeration-expected.txt

    r51644 r53170  
     1CONSOLE MESSAGE: line 1: Unsafe JavaScript attempt to access frame with URL http://localhost:8000/security/resources/cross-frame-iframe-for-enumeration-test.html from frame with URL http://127.0.0.1:8000/security/cross-frame-access-enumeration.html. Domains, protocols and ports must match.
     2
     3CONSOLE MESSAGE: line 1: Unsafe JavaScript attempt to access frame with URL http://localhost:8000/security/resources/cross-frame-iframe-for-enumeration-test.html from frame with URL http://127.0.0.1:8000/security/cross-frame-access-enumeration.html. Domains, protocols and ports must match.
     4
     5CONSOLE MESSAGE: line 1: Unsafe JavaScript attempt to access frame with URL http://localhost:8000/security/resources/cross-frame-iframe-for-enumeration-test.html from frame with URL http://127.0.0.1:8000/security/cross-frame-access-enumeration.html. Domains, protocols and ports must match.
     6
    17CONSOLE MESSAGE: line 1: Unsafe JavaScript attempt to access frame with URL http://localhost:8000/security/resources/cross-frame-iframe-for-enumeration-test.html from frame with URL http://127.0.0.1:8000/security/cross-frame-access-enumeration.html. Domains, protocols and ports must match.
    28
     
    2026PASS: Cross frame access by enumerating the window object was denied.
    2127PASS: Cross frame access by getting the keys of the window object was denied.
     28PASS: Cross frame access by getting the property names of the window object was denied.
    2229PASS: Cross frame access by enumerating the History object was denied.
    2330PASS: Cross frame access by getting the keys of the History object was denied.
     31PASS: Cross frame access by getting the property names of the History object was denied.
    2432PASS: Cross frame access by enumerating the Location object was denied.
    2533PASS: Cross frame access by getting the keys of the Location object was denied.
     34PASS: Cross frame access by getting the property names of the Location object was denied.
    2635
  • trunk/LayoutTests/http/tests/security/cross-frame-access-enumeration.html

    r48336 r53170  
    5353            log("PASS: Cross frame access by getting the keys of the window object was denied.");
    5454
     55            var b_winPropertyNames = Object.getOwnPropertyNames(b_win);
     56            if (b_winPropertyNames.indexOf("customWindowProperty") != -1) {
     57                log("FAIL: Cross frame access by getting the property names of the window object was allowed.");
     58                return;
     59            }
     60            log("PASS: Cross frame access by getting the property names of the window object was denied.");
     61
    5562            // Test enumerating the History object
    5663            var b_win_history = b_win.history;
     
    7380            log("PASS: Cross frame access by getting the keys of the History object was denied.");
    7481
     82            var b_winHistoryPropertyNames = Object.getOwnPropertyNames(b_win_history);
     83            if (b_winHistoryPropertyNames.indexOf("customHistoryProperty") != -1) {
     84                log("FAIL: Cross frame access by getting the property names of the History object was allowed.");
     85                return;
     86            }
     87            log("PASS: Cross frame access by getting the property names of the History object was denied.");
     88
    7589            // Test enumerating the Location object
    7690            var b_win_location = b_win.location;
     
    92106            }
    93107            log("PASS: Cross frame access by getting the keys of the Location object was denied.");
     108
     109            var b_winLocationPropertyNames = Object.getOwnPropertyNames(b_win_location);
     110            if (b_winLocationPropertyNames.indexOf("customLocationProperty") != -1) {
     111                log("FAIL: Cross frame access by getting the property names of the Location object was allowed.");
     112                return;
     113            }
     114            log("PASS: Cross frame access by getting the property names of the Location object was denied.");
    94115        }
    95116    </script>
  • trunk/WebCore/ChangeLog

    r53168 r53170  
     12010-01-12  Kent Hansen  <kent.hansen@nokia.com>
     2
     3        Reviewed by Geoffrey Garen.
     4
     5        [ES5] Implement Object.getOwnPropertyNames
     6        https://bugs.webkit.org/show_bug.cgi?id=32242
     7
     8        Add new argument to reimplementations of getPropertyNames()
     9        and getOwnPropertyNames(), and update the JS bindings generator.
     10
     11        Test: fast/js/Object-getOwnPropertyNames.html
     12
     13        * bindings/js/JSDOMWindowCustom.cpp:
     14        (WebCore::JSDOMWindow::getPropertyNames):
     15        (WebCore::JSDOMWindow::getOwnPropertyNames):
     16        * bindings/js/JSDOMWindowShell.cpp:
     17        (WebCore::JSDOMWindowShell::getPropertyNames):
     18        (WebCore::JSDOMWindowShell::getOwnPropertyNames):
     19        * bindings/js/JSDOMWindowShell.h:
     20        * bindings/js/JSHistoryCustom.cpp:
     21        (WebCore::JSHistory::getOwnPropertyNames):
     22        * bindings/js/JSLocationCustom.cpp:
     23        (WebCore::JSLocation::getOwnPropertyNames):
     24        * bindings/js/JSQuarantinedObjectWrapper.cpp:
     25        (WebCore::JSQuarantinedObjectWrapper::getPropertyNames):
     26        (WebCore::JSQuarantinedObjectWrapper::getOwnPropertyNames):
     27        * bindings/js/JSQuarantinedObjectWrapper.h:
     28        * bindings/js/JSStorageCustom.cpp:
     29        (WebCore::JSStorage::getOwnPropertyNames):
     30        * bindings/scripts/CodeGeneratorJS.pm:
     31        * bridge/runtime_array.cpp:
     32        (JSC::RuntimeArray::getOwnPropertyNames):
     33        * bridge/runtime_array.h:
     34        * bridge/runtime_object.cpp:
     35        (JSC::RuntimeObjectImp::getPropertyNames):
     36        (JSC::RuntimeObjectImp::getOwnPropertyNames):
     37        * bridge/runtime_object.h:
     38
    1392010-01-12  Brian Weinstein  <bweinstein@apple.com>
    240
  • trunk/WebCore/bindings/js/JSDOMWindowCustom.cpp

    r52314 r53170  
    420420}
    421421
    422 void JSDOMWindow::getPropertyNames(ExecState* exec, PropertyNameArray& propertyNames)
     422void JSDOMWindow::getPropertyNames(ExecState* exec, PropertyNameArray& propertyNames, EnumerationMode mode)
    423423{
    424424    // Only allow the window to enumerated by frames in the same origin.
    425425    if (!allowsAccessFrom(exec))
    426426        return;
    427     Base::getPropertyNames(exec, propertyNames);
    428 }
    429 
    430 void JSDOMWindow::getOwnPropertyNames(ExecState* exec, PropertyNameArray& propertyNames)
     427    Base::getPropertyNames(exec, propertyNames, mode);
     428}
     429
     430void JSDOMWindow::getOwnPropertyNames(ExecState* exec, PropertyNameArray& propertyNames, EnumerationMode mode)
    431431{
    432432    // Only allow the window to enumerated by frames in the same origin.
    433433    if (!allowsAccessFrom(exec))
    434434        return;
    435     Base::getOwnPropertyNames(exec, propertyNames);
     435    Base::getOwnPropertyNames(exec, propertyNames, mode);
    436436}
    437437
  • trunk/WebCore/bindings/js/JSDOMWindowShell.cpp

    r51971 r53170  
    115115}
    116116
    117 void JSDOMWindowShell::getPropertyNames(ExecState* exec, PropertyNameArray& propertyNames)
     117void JSDOMWindowShell::getPropertyNames(ExecState* exec, PropertyNameArray& propertyNames, EnumerationMode mode)
    118118{
    119     m_window->getPropertyNames(exec, propertyNames);
     119    m_window->getPropertyNames(exec, propertyNames, mode);
    120120}
    121121
    122 void JSDOMWindowShell::getOwnPropertyNames(ExecState* exec, PropertyNameArray& propertyNames)
     122void JSDOMWindowShell::getOwnPropertyNames(ExecState* exec, PropertyNameArray& propertyNames, EnumerationMode mode)
    123123{
    124     m_window->getOwnPropertyNames(exec, propertyNames);
     124    m_window->getOwnPropertyNames(exec, propertyNames, mode);
    125125}
    126126
  • trunk/WebCore/bindings/js/JSDOMWindowShell.h

    r51971 r53170  
    7676        virtual void putWithAttributes(JSC::ExecState*, const JSC::Identifier& propertyName, JSC::JSValue, unsigned attributes);
    7777        virtual bool deleteProperty(JSC::ExecState*, const JSC::Identifier& propertyName);
    78         virtual void getPropertyNames(JSC::ExecState*, JSC::PropertyNameArray&);
    79         virtual void getOwnPropertyNames(JSC::ExecState*, JSC::PropertyNameArray&);
     78        virtual void getPropertyNames(JSC::ExecState*, JSC::PropertyNameArray&, JSC::EnumerationMode mode = JSC::ExcludeDontEnumProperties);
     79        virtual void getOwnPropertyNames(JSC::ExecState*, JSC::PropertyNameArray&, JSC::EnumerationMode mode = JSC::ExcludeDontEnumProperties);
    8080        virtual void defineGetter(JSC::ExecState*, const JSC::Identifier& propertyName, JSC::JSObject* getterFunction, unsigned attributes);
    8181        virtual void defineSetter(JSC::ExecState*, const JSC::Identifier& propertyName, JSC::JSObject* setterFunction, unsigned attributes);
  • trunk/WebCore/bindings/js/JSHistoryCustom.cpp

    r51757 r53170  
    155155}
    156156
    157 void JSHistory::getOwnPropertyNames(ExecState* exec, PropertyNameArray& propertyNames)
     157void JSHistory::getOwnPropertyNames(ExecState* exec, PropertyNameArray& propertyNames, EnumerationMode mode)
    158158{
    159159    // Only allow the history object to enumerated by frames in the same origin.
    160160    if (!allowsAccessFromFrame(exec, impl()->frame()))
    161161        return;
    162     Base::getOwnPropertyNames(exec, propertyNames);
     162    Base::getOwnPropertyNames(exec, propertyNames, mode);
    163163}
    164164
  • trunk/WebCore/bindings/js/JSLocationCustom.cpp

    r51757 r53170  
    169169}
    170170
    171 void JSLocation::getOwnPropertyNames(ExecState* exec, PropertyNameArray& propertyNames)
     171void JSLocation::getOwnPropertyNames(ExecState* exec, PropertyNameArray& propertyNames, EnumerationMode mode)
    172172{
    173173    // Only allow the location object to enumerated by frames in the same origin.
    174174    if (!allowsAccessFromFrame(exec, impl()->frame()))
    175175        return;
    176     Base::getOwnPropertyNames(exec, propertyNames);
     176    Base::getOwnPropertyNames(exec, propertyNames, mode);
    177177}
    178178
  • trunk/WebCore/bindings/js/JSQuarantinedObjectWrapper.cpp

    r51512 r53170  
    314314}
    315315
    316 void JSQuarantinedObjectWrapper::getPropertyNames(ExecState*, PropertyNameArray& array)
     316void JSQuarantinedObjectWrapper::getPropertyNames(ExecState*, PropertyNameArray& array, EnumerationMode mode)
    317317{
    318318    if (!allowsGetPropertyNames())
    319319        return;
    320320   
    321     m_unwrappedObject->getPropertyNames(unwrappedExecState(), array);
    322 }
    323 
    324 void JSQuarantinedObjectWrapper::getOwnPropertyNames(ExecState*, PropertyNameArray& array)
     321    m_unwrappedObject->getPropertyNames(unwrappedExecState(), array, mode);
     322}
     323
     324void JSQuarantinedObjectWrapper::getOwnPropertyNames(ExecState*, PropertyNameArray& array, EnumerationMode mode)
    325325{
    326326    if (!allowsGetPropertyNames())
    327327        return;
    328328
    329     m_unwrappedObject->getOwnPropertyNames(unwrappedExecState(), array);
     329    m_unwrappedObject->getOwnPropertyNames(unwrappedExecState(), array, mode);
    330330}
    331331
  • trunk/WebCore/bindings/js/JSQuarantinedObjectWrapper.h

    r49835 r53170  
    7575        virtual bool hasInstance(JSC::ExecState*, JSC::JSValue, JSC::JSValue proto);
    7676       
    77         virtual void getPropertyNames(JSC::ExecState*, JSC::PropertyNameArray&);
    78         virtual void getOwnPropertyNames(JSC::ExecState*, JSC::PropertyNameArray&);
     77        virtual void getPropertyNames(JSC::ExecState*, JSC::PropertyNameArray&, JSC::EnumerationMode mode = JSC::ExcludeDontEnumProperties);
     78        virtual void getOwnPropertyNames(JSC::ExecState*, JSC::PropertyNameArray&, JSC::EnumerationMode mode = JSC::ExcludeDontEnumProperties);
    7979
    8080        virtual JSC::UString className() const { return m_unwrappedObject->className(); }
  • trunk/WebCore/bindings/js/JSStorageCustom.cpp

    r48336 r53170  
    6565}
    6666
    67 void JSStorage::getOwnPropertyNames(ExecState* exec, PropertyNameArray& propertyNames)
     67void JSStorage::getOwnPropertyNames(ExecState* exec, PropertyNameArray& propertyNames, EnumerationMode mode)
    6868{
    6969    unsigned length = m_impl->length();
     
    7171        propertyNames.add(Identifier(exec, m_impl->key(i)));
    7272       
    73     Base::getOwnPropertyNames(exec, propertyNames);
     73    Base::getOwnPropertyNames(exec, propertyNames, mode);
    7474}
    7575
  • trunk/WebCore/bindings/scripts/CodeGeneratorJS.pm

    r53086 r53170  
    648648    # Custom getPropertyNames function exists on DOMWindow
    649649    if ($interfaceName eq "DOMWindow") {
    650         push(@headerContent, "    virtual void getPropertyNames(JSC::ExecState*, JSC::PropertyNameArray&);\n");
     650        push(@headerContent, "    virtual void getPropertyNames(JSC::ExecState*, JSC::PropertyNameArray&, JSC::EnumerationMode mode = JSC::ExcludeDontEnumProperties);\n");
    651651        $structureFlags{"JSC::OverridesGetPropertyNames"} = 1;
    652652    }
     
    657657    # Custom getOwnPropertyNames function
    658658    if ($dataNode->extendedAttributes->{"CustomGetPropertyNames"} || $dataNode->extendedAttributes->{"HasIndexGetter"} || $dataNode->extendedAttributes->{"HasCustomIndexGetter"} || $dataNode->extendedAttributes->{"HasNumericIndexGetter"}) {
    659         push(@headerContent, "    virtual void getOwnPropertyNames(JSC::ExecState*, JSC::PropertyNameArray&);\n");
     659        push(@headerContent, "    virtual void getOwnPropertyNames(JSC::ExecState*, JSC::PropertyNameArray&, JSC::EnumerationMode mode = JSC::ExcludeDontEnumProperties);\n");
    660660        $structureFlags{"JSC::OverridesGetPropertyNames"} = 1;       
    661661    }
     
    15391539
    15401540    if (($dataNode->extendedAttributes->{"HasIndexGetter"} || $dataNode->extendedAttributes->{"HasCustomIndexGetter"} || $dataNode->extendedAttributes->{"HasNumericIndexGetter"}) && !$dataNode->extendedAttributes->{"CustomGetPropertyNames"}) {
    1541         push(@implContent, "void ${className}::getOwnPropertyNames(ExecState* exec, PropertyNameArray& propertyNames)\n");
     1541        push(@implContent, "void ${className}::getOwnPropertyNames(ExecState* exec, PropertyNameArray& propertyNames, EnumerationMode mode)\n");
    15421542        push(@implContent, "{\n");
    15431543        if ($dataNode->extendedAttributes->{"HasIndexGetter"} || $dataNode->extendedAttributes->{"HasCustomIndexGetter"} || $dataNode->extendedAttributes->{"HasNumericIndexGetter"}) {
     
    15451545            push(@implContent, "        propertyNames.add(Identifier::from(exec, i));\n");
    15461546        }
    1547         push(@implContent, "     Base::getOwnPropertyNames(exec, propertyNames);\n");
     1547        push(@implContent, "     Base::getOwnPropertyNames(exec, propertyNames, mode);\n");
    15481548        push(@implContent, "}\n\n");
    15491549    }
  • trunk/WebCore/bridge/runtime_array.cpp

    r51985 r53170  
    5858}
    5959
    60 void RuntimeArray::getOwnPropertyNames(ExecState* exec, PropertyNameArray& propertyNames)
     60void RuntimeArray::getOwnPropertyNames(ExecState* exec, PropertyNameArray& propertyNames, EnumerationMode mode)
    6161{
    6262    unsigned length = getLength();
     
    6464        propertyNames.add(Identifier::from(exec, i));
    6565
    66     JSObject::getOwnPropertyNames(exec, propertyNames);
     66    if (mode == IncludeDontEnumProperties)
     67        propertyNames.add(exec->propertyNames().length);
     68
     69    JSObject::getOwnPropertyNames(exec, propertyNames, mode);
    6770}
    6871
  • trunk/WebCore/bridge/runtime_array.h

    r51985 r53170  
    3636    RuntimeArray(ExecState*, Bindings::Array*);
    3737
    38     virtual void getOwnPropertyNames(ExecState*, PropertyNameArray&);
     38    virtual void getOwnPropertyNames(ExecState*, PropertyNameArray&, EnumerationMode mode = ExcludeDontEnumProperties);
    3939    virtual bool getOwnPropertySlot(ExecState *, const Identifier&, PropertySlot&);
    4040    virtual bool getOwnPropertySlot(ExecState *, unsigned, PropertySlot&);
  • trunk/WebCore/bridge/runtime_object.cpp

    r48836 r53170  
    303303}
    304304
    305 void RuntimeObjectImp::getPropertyNames(ExecState* exec, PropertyNameArray& propertyNames)
     305void RuntimeObjectImp::getPropertyNames(ExecState* exec, PropertyNameArray& propertyNames, EnumerationMode)
    306306{
    307307    if (!m_instance) {
     
    317317}
    318318
    319 void RuntimeObjectImp::getOwnPropertyNames(ExecState* exec, PropertyNameArray& propertyNames)
    320 {
    321     getOwnPropertyNames(exec, propertyNames);
     319void RuntimeObjectImp::getOwnPropertyNames(ExecState* exec, PropertyNameArray& propertyNames, EnumerationMode mode)
     320{
     321    getOwnPropertyNames(exec, propertyNames, mode);
    322322}
    323323
  • trunk/WebCore/bridge/runtime_object.h

    r49835 r53170  
    4545    virtual ConstructType getConstructData(ConstructData&);
    4646
    47     virtual void getPropertyNames(ExecState*, PropertyNameArray&);
    48     virtual void getOwnPropertyNames(ExecState*, PropertyNameArray&);
     47    virtual void getPropertyNames(ExecState*, PropertyNameArray&, EnumerationMode mode = ExcludeDontEnumProperties);
     48    virtual void getOwnPropertyNames(ExecState*, PropertyNameArray&, EnumerationMode mode = ExcludeDontEnumProperties);
    4949
    5050    void invalidate();
Note: See TracChangeset for help on using the changeset viewer.