Ignore:
Timestamp:
Dec 26, 2011, 8:56:37 PM (13 years ago)
Author:
[email protected]
Message:

https://bugs.webkit.org/show_bug.cgi?id=75231
Fail to throw in strict mode on assign to read only static properties

Reviewed by Filip Pizlo.

Source/JavaScriptCore:

There are three bugs here:

  • symbolTablePut should throw for strict mode accesses.
  • lookupPut should throw for strict mode accesses.
  • NumberConstructor should override put to call lookupPut, to trap assignment to readonly properties.
  • runtime/JSActivation.cpp:

(JSC::JSActivation::symbolTablePut):
(JSC::JSActivation::put):

  • runtime/JSActivation.h:
  • runtime/JSGlobalObject.cpp:

(JSC::JSGlobalObject::put):

  • runtime/JSStaticScopeObject.cpp:

(JSC::JSStaticScopeObject::put):

  • runtime/JSVariableObject.h:

(JSC::JSVariableObject::symbolTablePut):

  • runtime/Lookup.h:

(JSC::lookupPut):

  • runtime/NumberConstructor.cpp:

(JSC::NumberConstructor::put):

  • runtime/NumberConstructor.h:

LayoutTests:

Added test cases / updated now-passing results.

  • fast/js/mozilla/strict/15.10.7-expected.txt:
  • fast/js/script-tests/strict-readonly-statics.js: Added.

(testWindowUndefined):
(testNumberMAX_VALUE):

  • fast/js/strict-readonly-statics-expected.txt: Added.
  • fast/js/strict-readonly-statics.html: Added.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/runtime/JSActivation.cpp

    r102545 r103697  
    9898}
    9999
    100 inline bool JSActivation::symbolTablePut(JSGlobalData& globalData, const Identifier& propertyName, JSValue value)
    101 {
     100inline bool JSActivation::symbolTablePut(ExecState* exec, const Identifier& propertyName, JSValue value, bool shouldThrow)
     101{
     102    JSGlobalData& globalData = exec->globalData();
    102103    ASSERT(!Heap::heap(value) || Heap::heap(value) == Heap::heap(this));
    103104   
     
    105106    if (entry.isNull())
    106107        return false;
    107     if (entry.isReadOnly())
    108         return true;
     108    if (entry.isReadOnly()) {
     109        if (shouldThrow)
     110            throwTypeError(exec, StrictModeReadonlyPropertyWriteError);
     111        return true;
     112    }
    109113    if (entry.getIndex() >= m_numCapturedVars)
    110114        return false;
     
    174178    ASSERT(!Heap::heap(value) || Heap::heap(value) == Heap::heap(thisObject));
    175179
    176     if (thisObject->symbolTablePut(exec->globalData(), propertyName, value))
     180    if (thisObject->symbolTablePut(exec, propertyName, value, slot.isStrictMode()))
    177181        return;
    178182
Note: See TracChangeset for help on using the changeset viewer.