• barraclough@apple.com's avatar
    RegExp lastIndex should behave as a regular property · 46406a91
    barraclough@apple.com authored
    https://bugs.webkit.org/show_bug.cgi?id=79446
    
    Reviewed by Sam Weinig.
    
    lastIndex should be a regular data descriptor, with the attributes configurable:false,
    enumerable:false, writable:true. As such, it should be possible to reconfigure writable
    as false. If the lastIndex property is reconfigured to be read-only, we should respect
    this correctly.
    
    Source/JavaScriptCore: 
    
    * runtime/CommonIdentifiers.h:
        - Removed some unused identifiers, added lastIndex.
    * runtime/RegExpObject.cpp:
    (JSC::RegExpObject::getOwnPropertySlot):
        - lastIndex is no longer a static value, provided specific handling.
    (JSC::RegExpObject::getOwnPropertyDescriptor):
        - lastIndex is no longer a static value, provided specific handling.
    (JSC::RegExpObject::deleteProperty):
        - lastIndex is no longer a static value, provided specific handling.
    (JSC::RegExpObject::getOwnPropertyNames):
        - lastIndex is no longer a static value, provided specific handling.
    (JSC::RegExpObject::getPropertyNames):
        - lastIndex is no longer a static value, provided specific handling.
    (JSC::reject):
        - helper function for defineOwnProperty.
    (JSC::RegExpObject::defineOwnProperty):
        - lastIndex is no longer a static value, provided specific handling.
    (JSC::RegExpObject::put):
        - lastIndex is no longer a static value, provided specific handling.
    (JSC::RegExpObject::match):
        - Pass setLastIndex an ExecState, so it can throw if read-only.
    * runtime/RegExpObject.h:
    (JSC::RegExpObject::setLastIndex):
        - Pass setLastIndex an ExecState, so it can throw if read-only.
    (RegExpObjectData):
        - Added lastIndexIsWritable.
    * runtime/RegExpPrototype.cpp:
    (JSC::regExpProtoFuncCompile):
        - Pass setLastIndex an ExecState, so it can throw if read-only.
    
    LayoutTests: 
    
    * fast/regex/lastIndex-expected.txt: Added.
    * fast/regex/lastIndex.html: Added.
    * fast/regex/script-tests/lastIndex.js: Added.
        - Added test cases for correct handling of lastIndex.
    
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@109008 268f45cc-cd09-0410-ab3c-d52691b4dbfc
    46406a91
RegExpPrototype.cpp 6.06 KB