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.
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@103697 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/Source/JavaScriptCore/runtime/NumberConstructor.cpp b/Source/JavaScriptCore/runtime/NumberConstructor.cpp
index e863e86..e1ff62f 100644
--- a/Source/JavaScriptCore/runtime/NumberConstructor.cpp
+++ b/Source/JavaScriptCore/runtime/NumberConstructor.cpp
@@ -83,6 +83,11 @@
return getStaticValueDescriptor<NumberConstructor, InternalFunction>(exec, ExecState::numberConstructorTable(exec), jsCast<NumberConstructor*>(object), propertyName, descriptor);
}
+void NumberConstructor::put(JSCell* cell, ExecState* exec, const Identifier& propertyName, JSValue value, PutPropertySlot& slot)
+{
+ lookupPut<NumberConstructor, InternalFunction>(exec, propertyName, value, ExecState::numberConstructorTable(exec), jsCast<NumberConstructor*>(cell), slot);
+}
+
static JSValue numberConstructorNaNValue(ExecState*, JSValue, const Identifier&)
{
return jsNaN();