Diff
Modified: trunk/LayoutTests/ChangeLog (109239 => 109240)
--- trunk/LayoutTests/ChangeLog 2012-02-29 19:54:35 UTC (rev 109239)
+++ trunk/LayoutTests/ChangeLog 2012-02-29 19:59:43 UTC (rev 109240)
@@ -1,3 +1,14 @@
+2012-02-29 Gavin Barraclough <barraclo...@apple.com>
+
+ Writable attribute not set correctly when redefining an accessor to a data descriptor
+ https://bugs.webkit.org/show_bug.cgi?id=79931
+
+ Reviewed by Oliver Hunt.
+
+ * fast/js/Object-defineProperty-expected.txt:
+ * fast/js/script-tests/Object-defineProperty.js:
+ - Added tests.
+
2012-02-29 Max Feil <mf...@rim.com>
[BlackBerry] Add support for FLAC audio and OGG/Vorbis audio
Modified: trunk/LayoutTests/fast/js/Object-defineProperty-expected.txt (109239 => 109240)
--- trunk/LayoutTests/fast/js/Object-defineProperty-expected.txt 2012-02-29 19:54:35 UTC (rev 109239)
+++ trunk/LayoutTests/fast/js/Object-defineProperty-expected.txt 2012-02-29 19:59:43 UTC (rev 109240)
@@ -116,6 +116,9 @@
PASS '0' in Object.prototype is true
PASS var o = {}; o.readOnly = false; o.readOnly is true
PASS 'use strict'; var o = {}; o.readOnly = false; o.readOnly threw exception TypeError: Attempted to assign to readonly property..
+PASS Object.getOwnPropertyDescriptor(Object.defineProperty(Object.defineProperty({}, 'foo', {get: function() { return false; }, configurable: true}), 'foo', {value:false}), 'foo').writable is false
+PASS Object.getOwnPropertyDescriptor(Object.defineProperty(Object.defineProperty({}, 'foo', {get: function() { return false; }, configurable: true}), 'foo', {value:false, writable: false}), 'foo').writable is false
+PASS Object.getOwnPropertyDescriptor(Object.defineProperty(Object.defineProperty({}, 'foo', {get: function() { return false; }, configurable: true}), 'foo', {value:false, writable: true}), 'foo').writable is true
PASS successfullyParsed is true
TEST COMPLETE
Modified: trunk/LayoutTests/fast/js/script-tests/Object-defineProperty.js (109239 => 109240)
--- trunk/LayoutTests/fast/js/script-tests/Object-defineProperty.js 2012-02-29 19:54:35 UTC (rev 109239)
+++ trunk/LayoutTests/fast/js/script-tests/Object-defineProperty.js 2012-02-29 19:59:43 UTC (rev 109240)
@@ -167,4 +167,7 @@
shouldThrow("'use strict'; var o = {}; o.readOnly = false; o.readOnly");
delete Object.prototype.readOnly;
-
+// Check the writable attribute is set correctly when redefining an accessor as a data descriptor.
+shouldBeFalse("Object.getOwnPropertyDescriptor(Object.defineProperty(Object.defineProperty({}, 'foo', {get: function() { return false; }, configurable: true}), 'foo', {value:false}), 'foo').writable");
+shouldBeFalse("Object.getOwnPropertyDescriptor(Object.defineProperty(Object.defineProperty({}, 'foo', {get: function() { return false; }, configurable: true}), 'foo', {value:false, writable: false}), 'foo').writable");
+shouldBeTrue("Object.getOwnPropertyDescriptor(Object.defineProperty(Object.defineProperty({}, 'foo', {get: function() { return false; }, configurable: true}), 'foo', {value:false, writable: true}), 'foo').writable");
Modified: trunk/Source/_javascript_Core/ChangeLog (109239 => 109240)
--- trunk/Source/_javascript_Core/ChangeLog 2012-02-29 19:54:35 UTC (rev 109239)
+++ trunk/Source/_javascript_Core/ChangeLog 2012-02-29 19:59:43 UTC (rev 109240)
@@ -1,3 +1,17 @@
+2012-02-29 Gavin Barraclough <barraclo...@apple.com>
+
+ Writable attribute not set correctly when redefining an accessor to a data descriptor
+ https://bugs.webkit.org/show_bug.cgi?id=79931
+
+ Reviewed by Oliver Hunt.
+
+ * runtime/JSObject.cpp:
+ (JSC::JSObject::defineOwnProperty):
+ - use attributesOverridingCurrent instead of attributesWithOverride.
+ * runtime/PropertyDescriptor.cpp:
+ * runtime/PropertyDescriptor.h:
+ - remove attributesWithOverride - attributesOverridingCurrent does the same thing.
+
2012-02-29 Kevin Ollivier <kev...@theolliviers.com>
Add JSCore symbol exports needed by wx port
Modified: trunk/Source/_javascript_Core/runtime/JSObject.cpp (109239 => 109240)
--- trunk/Source/_javascript_Core/runtime/JSObject.cpp 2012-02-29 19:54:35 UTC (rev 109239)
+++ trunk/Source/_javascript_Core/runtime/JSObject.cpp 2012-02-29 19:59:43 UTC (rev 109240)
@@ -702,7 +702,7 @@
if (descriptor.isGenericDescriptor()) {
if (!current.attributesEqual(descriptor)) {
object->methodTable()->deleteProperty(object, exec, propertyName);
- return putDescriptor(exec, object, propertyName, descriptor, current.attributesWithOverride(descriptor), current);
+ return putDescriptor(exec, object, propertyName, descriptor, descriptor.attributesOverridingCurrent(current), current);
}
return true;
}
@@ -715,7 +715,7 @@
return false;
}
object->methodTable()->deleteProperty(object, exec, propertyName);
- return putDescriptor(exec, object, propertyName, descriptor, current.attributesWithOverride(descriptor), current);
+ return putDescriptor(exec, object, propertyName, descriptor, descriptor.attributesOverridingCurrent(current), current);
}
// Changing the value and attributes of an existing property
@@ -737,7 +737,7 @@
if (current.attributesEqual(descriptor) && !descriptor.value())
return true;
object->methodTable()->deleteProperty(object, exec, propertyName);
- return putDescriptor(exec, object, propertyName, descriptor, current.attributesWithOverride(descriptor), current);
+ return putDescriptor(exec, object, propertyName, descriptor, descriptor.attributesOverridingCurrent(current), current);
}
// Changing the accessor functions of an existing accessor property
Modified: trunk/Source/_javascript_Core/runtime/PropertyDescriptor.cpp (109239 => 109240)
--- trunk/Source/_javascript_Core/runtime/PropertyDescriptor.cpp 2012-02-29 19:54:35 UTC (rev 109239)
+++ trunk/Source/_javascript_Core/runtime/PropertyDescriptor.cpp 2012-02-29 19:59:43 UTC (rev 109240)
@@ -206,22 +206,6 @@
return true;
}
-unsigned PropertyDescriptor::attributesWithOverride(const PropertyDescriptor& other) const
-{
- unsigned mismatch = other.m_attributes ^ m_attributes;
- unsigned sharedSeen = other.m_seenAttributes & m_seenAttributes;
- unsigned newAttributes = m_attributes & defaultAttributes;
- if (sharedSeen & WritablePresent && mismatch & ReadOnly)
- newAttributes ^= ReadOnly;
- if (sharedSeen & ConfigurablePresent && mismatch & DontDelete)
- newAttributes ^= DontDelete;
- if (sharedSeen & EnumerablePresent && mismatch & DontEnum)
- newAttributes ^= DontEnum;
- if (isAccessorDescriptor() && other.isDataDescriptor())
- newAttributes |= ReadOnly;
- return newAttributes;
-}
-
unsigned PropertyDescriptor::attributesOverridingCurrent(const PropertyDescriptor& current) const
{
unsigned currentAttributes = current.m_attributes;
Modified: trunk/Source/_javascript_Core/runtime/PropertyDescriptor.h (109239 => 109240)
--- trunk/Source/_javascript_Core/runtime/PropertyDescriptor.h 2012-02-29 19:54:35 UTC (rev 109239)
+++ trunk/Source/_javascript_Core/runtime/PropertyDescriptor.h 2012-02-29 19:59:43 UTC (rev 109240)
@@ -70,7 +70,6 @@
bool getterPresent() const { return m_getter; }
bool equalTo(ExecState* exec, const PropertyDescriptor& other) const;
bool attributesEqual(const PropertyDescriptor& other) const;
- unsigned attributesWithOverride(const PropertyDescriptor& other) const;
unsigned attributesOverridingCurrent(const PropertyDescriptor& current) const;
private: