Diff
Modified: trunk/LayoutTests/ChangeLog (108281 => 108282)
--- trunk/LayoutTests/ChangeLog 2012-02-21 02:19:35 UTC (rev 108281)
+++ trunk/LayoutTests/ChangeLog 2012-02-21 02:35:19 UTC (rev 108282)
@@ -1,3 +1,17 @@
+2012-02-20 Gavin Barraclough <[email protected]>
+
+ DefineOwnProperty fails with numeric properties & Object.prototype
+ https://bugs.webkit.org/show_bug.cgi?id=79059
+
+ Reviewed by Oliver Hunt.
+
+ ObjectPrototype caches whether it contains any numeric properties (m_hasNoPropertiesWithUInt32Names),
+ calls to defineOwnProperty need to update this cache.
+
+ * fast/js/Object-defineProperty-expected.txt:
+ * fast/js/script-tests/Object-defineProperty.js:
+ (shouldBe.shouldBe.shouldBe.shouldBe.shouldBe.shouldBe.shouldBe.shouldThrow.Object.defineProperty):
+
2012-02-20 Martin Robinson <[email protected]>
[UNIX] Plugin information fields are not interpreted as UTF-8
Modified: trunk/LayoutTests/fast/js/Object-defineProperty-expected.txt (108281 => 108282)
--- trunk/LayoutTests/fast/js/Object-defineProperty-expected.txt 2012-02-21 02:19:35 UTC (rev 108281)
+++ trunk/LayoutTests/fast/js/Object-defineProperty-expected.txt 2012-02-21 02:35:19 UTC (rev 108282)
@@ -112,6 +112,8 @@
PASS 'use strict'; var o = Object.defineProperty(Object.defineProperty({foo:1}, 'foo', {get:function(){return 42;}, set:function(x){this.result = x;}}), 'foo', {set:function(){this.result = 13;}}); o.foo = 42; o.result; is 13
PASS 'use strict'; var o = Object.defineProperty(Object.defineProperty({foo:1}, 'foo', {get:function(){return 42;}, set:function(x){this.result = x;}}), 'foo', {set:undefined}); o.foo is 42
PASS 'use strict'; var o = Object.defineProperty(Object.defineProperty({foo:1}, 'foo', {get:function(){return 42;}, set:function(x){this.result = x;}}), 'foo', {set:undefined}); o.foo = 42; o.result; threw exception TypeError: setting a property that has only a getter.
+PASS 0 in Object.prototype is true
+PASS '0' in Object.prototype is true
PASS successfullyParsed is true
TEST COMPLETE
Modified: trunk/LayoutTests/fast/js/script-tests/Object-defineProperty.js (108281 => 108282)
--- trunk/LayoutTests/fast/js/script-tests/Object-defineProperty.js 2012-02-21 02:19:35 UTC (rev 108281)
+++ trunk/LayoutTests/fast/js/script-tests/Object-defineProperty.js 2012-02-21 02:35:19 UTC (rev 108282)
@@ -156,3 +156,8 @@
shouldBe("'use strict'; var o = Object.defineProperty(Object.defineProperty({foo:1}, 'foo', {get:function(){return 42;}, set:function(x){this.result = x;}}), 'foo', {set:function(){this.result = 13;}}); o.foo = 42; o.result;", '13')
shouldBe("'use strict'; var o = Object.defineProperty(Object.defineProperty({foo:1}, 'foo', {get:function(){return 42;}, set:function(x){this.result = x;}}), 'foo', {set:undefined}); o.foo", '42')
shouldThrow("'use strict'; var o = Object.defineProperty(Object.defineProperty({foo:1}, 'foo', {get:function(){return 42;}, set:function(x){this.result = x;}}), 'foo', {set:undefined}); o.foo = 42; o.result;")
+
+Object.defineProperty(Object.prototype, 0, {get:function(){ return false; }, configurable:true})
+shouldBeTrue("0 in Object.prototype");
+shouldBeTrue("'0' in Object.prototype");
+delete Object.prototype[0];
Modified: trunk/Source/_javascript_Core/ChangeLog (108281 => 108282)
--- trunk/Source/_javascript_Core/ChangeLog 2012-02-21 02:19:35 UTC (rev 108281)
+++ trunk/Source/_javascript_Core/ChangeLog 2012-02-21 02:35:19 UTC (rev 108282)
@@ -1,3 +1,21 @@
+2012-02-20 Gavin Barraclough <[email protected]>
+
+ DefineOwnProperty fails with numeric properties & Object.prototype
+ https://bugs.webkit.org/show_bug.cgi?id=79059
+
+ Reviewed by Oliver Hunt.
+
+ ObjectPrototype caches whether it contains any numeric properties (m_hasNoPropertiesWithUInt32Names),
+ calls to defineOwnProperty need to update this cache.
+
+ * runtime/ObjectPrototype.cpp:
+ (JSC::ObjectPrototype::put):
+ (JSC::ObjectPrototype::defineOwnProperty):
+ (JSC):
+ (JSC::ObjectPrototype::getOwnPropertySlotByIndex):
+ * runtime/ObjectPrototype.h:
+ (ObjectPrototype):
+
2012-02-20 Pino Toscano <[email protected]>
Does not build on GNU Hurd
Modified: trunk/Source/_javascript_Core/runtime/ObjectPrototype.cpp (108281 => 108282)
--- trunk/Source/_javascript_Core/runtime/ObjectPrototype.cpp 2012-02-21 02:19:35 UTC (rev 108281)
+++ trunk/Source/_javascript_Core/runtime/ObjectPrototype.cpp 2012-02-21 02:35:19 UTC (rev 108282)
@@ -80,7 +80,7 @@
void ObjectPrototype::put(JSCell* cell, ExecState* exec, const Identifier& propertyName, JSValue value, PutPropertySlot& slot)
{
ObjectPrototype* thisObject = jsCast<ObjectPrototype*>(cell);
- JSNonFinalObject::put(cell, exec, propertyName, value, slot);
+ Base::put(cell, exec, propertyName, value, slot);
if (thisObject->m_hasNoPropertiesWithUInt32Names) {
bool isUInt32;
@@ -89,12 +89,26 @@
}
}
+bool ObjectPrototype::defineOwnProperty(JSObject* object, ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor, bool shouldThrow)
+{
+ ObjectPrototype* thisObject = jsCast<ObjectPrototype*>(object);
+ bool result = Base::defineOwnProperty(object, exec, propertyName, descriptor, shouldThrow);
+
+ if (thisObject->m_hasNoPropertiesWithUInt32Names) {
+ bool isUInt32;
+ propertyName.toUInt32(isUInt32);
+ thisObject->m_hasNoPropertiesWithUInt32Names = !isUInt32;
+ }
+
+ return result;
+}
+
bool ObjectPrototype::getOwnPropertySlotByIndex(JSCell* cell, ExecState* exec, unsigned propertyName, PropertySlot& slot)
{
ObjectPrototype* thisObject = jsCast<ObjectPrototype*>(cell);
if (thisObject->m_hasNoPropertiesWithUInt32Names)
return false;
- return JSNonFinalObject::getOwnPropertySlotByIndex(thisObject, exec, propertyName, slot);
+ return Base::getOwnPropertySlotByIndex(thisObject, exec, propertyName, slot);
}
bool ObjectPrototype::getOwnPropertySlot(JSCell* cell, ExecState* exec, const Identifier& propertyName, PropertySlot &slot)
Modified: trunk/Source/_javascript_Core/runtime/ObjectPrototype.h (108281 => 108282)
--- trunk/Source/_javascript_Core/runtime/ObjectPrototype.h 2012-02-21 02:19:35 UTC (rev 108281)
+++ trunk/Source/_javascript_Core/runtime/ObjectPrototype.h 2012-02-21 02:35:19 UTC (rev 108282)
@@ -51,6 +51,7 @@
private:
ObjectPrototype(ExecState*, Structure*);
static void put(JSCell*, ExecState*, const Identifier&, JSValue, PutPropertySlot&);
+ static bool defineOwnProperty(JSObject*, ExecState*, const Identifier& propertyName, PropertyDescriptor&, bool shouldThrow);
static bool getOwnPropertySlot(JSCell*, ExecState*, const Identifier&, PropertySlot&);
static bool getOwnPropertySlotByIndex(JSCell*, ExecState*, unsigned propertyName, PropertySlot&);