Index: src/v8natives.js |
=================================================================== |
--- src/v8natives.js (revision 4684) |
+++ src/v8natives.js (working copy) |
@@ -434,6 +434,11 @@ |
} |
+PropertyDescriptor.prototype.hasWritable = function() { |
+ return this.hasWritable_; |
+} |
+ |
+ |
PropertyDescriptor.prototype.setConfigurable = function(configurable) { |
this.configurable_ = configurable; |
this.hasConfigurable_ = true; |
@@ -537,6 +542,22 @@ |
throw MakeTypeError("define_disallowed", ["defineProperty"]); |
if (!IS_UNDEFINED(current) && !current.isConfigurable()) { |
+ // Step 5 and 6 |
+ if ((!desc.hasEnumerable() || |
+ SameValue(desc.isEnumerable() && current.isEnumerable())) && |
+ (!desc.hasConfigurable() || |
+ SameValue(desc.isConfigurable(), current.isConfigurable())) && |
+ (!desc.hasWritable() || |
+ SameValue(desc.isWritable(), current.isWritable())) && |
+ (!desc.hasValue() || |
+ SameValue(desc.getValue(), current.getValue())) && |
+ (!desc.hasGetter() || |
+ SameValue(desc.getGet(), current.getGet())) && |
+ (!desc.hasSetter() || |
+ SameValue(desc.getSet(), current.getSet()))) { |
+ return true; |
+ } |
+ |
// Step 7 |
if (desc.isConfigurable() || desc.isEnumerable() != current.isEnumerable()) |
throw MakeTypeError("redefine_disallowed", ["defineProperty"]); |
@@ -673,8 +694,9 @@ |
// ES5 section 15.2.3.6. |
function ObjectDefineProperty(obj, p, attributes) { |
if ((!IS_SPEC_OBJECT_OR_NULL(obj) || IS_NULL_OR_UNDEFINED(obj)) && |
- !IS_UNDETECTABLE(obj)) |
+ !IS_UNDETECTABLE(obj)) { |
throw MakeTypeError("obj_ctor_property_non_object", ["defineProperty"]); |
+ } |
var name = ToString(p); |
var desc = ToPropertyDescriptor(attributes); |
DefineOwnProperty(obj, name, desc, true); |