Changeset 31225 in webkit


Ignore:
Timestamp:
Mar 21, 2008 7:36:34 PM (16 years ago)
Author:
oliver@apple.com
Message:

Global properties that use LocalStorage are not correctly listed as enumerable.

Reviewed by Geoff Garen

The problem was caused by JSObject::getPropertyAttributes not being aware
of the JSVariableObject SymbolTable. The fix is to make getPropertyAttributes
virtual and override in JSVariableObject. This does not produce any performance
regression.

Location:
trunk
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/ChangeLog

    r31216 r31225  
     12008-03-21  Oliver Hunt  <oliver@apple.com>
     2
     3        Reviewed by Geoff Garen.
     4
     5        Global properties that use LocalStorage are not correctly listed as enumerable.
     6
     7        The problem was caused by JSObject::getPropertyAttributes not being aware
     8        of the JSVariableObject SymbolTable.  The fix is to make getPropertyAttributes
     9        virtual and override in JSVariableObject.  This does not produce any performance
     10        regression.
     11
     12        * JavaScriptCore.exp:
     13        * kjs/JSVariableObject.cpp:
     14        (KJS::JSVariableObject::getPropertyNames):
     15        (KJS::JSVariableObject::getPropertyAttributes):
     16        * kjs/JSVariableObject.h:
     17        * kjs/object.h:
     18
    1192008-03-21  Arkadiusz Miskiewicz  <arekm@maven.pl>
    220
  • trunk/JavaScriptCore/JavaScriptCore.exp

    r31208 r31225  
    230230__ZNK3KJS16JSVariableObject16isVariableObjectEv
    231231__ZNK3KJS16JSVariableObject16saveLocalStorageERNS_15SavedPropertiesE
     232__ZNK3KJS16JSVariableObject21getPropertyAttributesERKNS_10IdentifierERj
    232233__ZNK3KJS19InternalFunctionImp14implementsCallEv
    233234__ZNK3KJS19InternalFunctionImp21implementsHasInstanceEv
     
    256257__ZNK3KJS8JSObject14implementsCallEv
    257258__ZNK3KJS8JSObject19implementsConstructEv
     259__ZNK3KJS8JSObject21getPropertyAttributesERKNS_10IdentifierERj
    258260__ZNK3KJS8JSObject21implementsHasInstanceEv
    259261__ZNK3KJS8JSObject3getEPNS_9ExecStateERKNS_10IdentifierE
  • trunk/JavaScriptCore/kjs/JSVariableObject.cpp

    r31114 r31225  
    8585void JSVariableObject::getPropertyNames(ExecState* exec, PropertyNameArray& propertyNames)
    8686{
    87     SymbolTable::const_iterator::Keys end = symbolTable().end().keys();
    88     for (SymbolTable::const_iterator::Keys it = symbolTable().begin().keys(); it != end; ++it)
    89         propertyNames.add(Identifier(it->get()));
     87    SymbolTable::const_iterator end = symbolTable().end();
     88    for (SymbolTable::const_iterator it = symbolTable().begin(); it != end; ++it)
     89        if ((localStorage()[it->second].attributes & DontEnum) == 0)
     90            propertyNames.add(Identifier(it->first.get()));
     91   
     92    JSObject::getPropertyNames(exec, propertyNames);
     93}
    9094
    91     JSObject::getPropertyNames(exec, propertyNames);
     95bool JSVariableObject::getPropertyAttributes(const Identifier& propertyName, unsigned& attributes) const
     96{
     97    size_t index = symbolTable().get(propertyName.ustring().rep());
     98    if (index != missingSymbolMarker()) {
     99        attributes = localStorage()[index].attributes;
     100        return true;
     101    }
     102    return JSObject::getPropertyAttributes(propertyName, attributes);
    92103}
    93104
  • trunk/JavaScriptCore/kjs/JSVariableObject.h

    r31114 r31225  
    3838    class JSVariableObject : public JSObject {
    3939    public:
    40         SymbolTable& symbolTable() { return *d->symbolTable; }
    41         LocalStorage& localStorage() { return d->localStorage; }
     40        SymbolTable& symbolTable() const { return *d->symbolTable; }
     41        LocalStorage& localStorage() const { return d->localStorage; }
    4242       
    4343        void saveLocalStorage(SavedProperties&) const;
     
    5353        virtual bool isVariableObject() const;
    5454        virtual bool isDynamicScope() const = 0;
     55
     56        virtual bool getPropertyAttributes(const Identifier& propertyName, unsigned& attributes) const;
    5557
    5658    protected:
  • trunk/JavaScriptCore/kjs/object.h

    r31114 r31225  
    404404    virtual JSObject *toObject(ExecState *exec) const;
    405405   
    406     bool getPropertyAttributes(const Identifier& propertyName, unsigned& attributes) const;
     406    virtual bool getPropertyAttributes(const Identifier& propertyName, unsigned& attributes) const;
    407407   
    408408    // WebCore uses this to make document.all and style.filter undetectable
  • trunk/LayoutTests/ChangeLog

    r31224 r31225  
     12008-03-21  Oliver Hunt  <oliver@apple.com>
     2
     3        Reviewed by Geoff Garen.
     4
     5        Ensure we correctly report optimised variables as being
     6        enumerable.
     7
     8        * fast/js/propertyIsEnumerable-expected.txt:
     9        * fast/js/resources/propertyIsEnumerable.js:
     10
    1112008-03-21  Sam Weinig  <sam@webkit.org>
    212
  • trunk/LayoutTests/fast/js/propertyIsEnumerable-expected.txt

    r12001 r31225  
    77PASS a.propertyIsEnumerable ('foo') is true
    88PASS a.propertyIsEnumerable ('non-existant') is false
     9PASS global.propertyIsEnumerable ('aVarDecl') is true
     10PASS global.propertyIsEnumerable ('aFunctionDecl') is true
     11PASS global.propertyIsEnumerable ('Math') is false
     12PASS global.propertyIsEnumerable ('NaN') is false
     13PASS global.propertyIsEnumerable ('undefined') is false
    914PASS successfullyParsed is true
    1015
  • trunk/LayoutTests/fast/js/resources/propertyIsEnumerable.js

    r11995 r31225  
    66a.foo='bar'
    77
     8var aVarDecl;
     9function aFunctionDecl(){}
     10var global = this;
    811shouldBeFalse("a.propertyIsEnumerable('length')");
    912shouldBeTrue("a.propertyIsEnumerable ('foo')");
    1013shouldBeFalse("a.propertyIsEnumerable ('non-existant')");
    1114
     15shouldBeTrue("global.propertyIsEnumerable ('aVarDecl')");
     16shouldBeTrue("global.propertyIsEnumerable ('aFunctionDecl')");
     17shouldBeFalse("global.propertyIsEnumerable ('Math')");
     18shouldBeFalse("global.propertyIsEnumerable ('NaN')");
     19shouldBeFalse("global.propertyIsEnumerable ('undefined')");
     20
    1221var successfullyParsed = true;
Note: See TracChangeset for help on using the changeset viewer.