Chromium Code Reviews| Index: src/v8natives.js |
| diff --git a/src/v8natives.js b/src/v8natives.js |
| index 180c05e1ebc81c4385dba9e6a347f0863ee93d47..08555a3d452ca883c3d1437f359f6894b40d586a 100644 |
| --- a/src/v8natives.js |
| +++ b/src/v8natives.js |
| @@ -805,14 +805,24 @@ function DefineObjectProperty(obj, p, desc, should_throw) { |
| } |
| // Step 10a |
| if (IsDataDescriptor(current) && IsDataDescriptor(desc)) { |
| - if (!current.isWritable() && desc.isWritable()) { |
| - if (should_throw) { |
| - throw MakeTypeError(kRedefineDisallowed, p); |
| - } else { |
| - return false; |
| + var currentIsWritable = current.isWritable(); |
| + if (currentIsWritable != desc.isWritable()) { |
| + if (!currentIsWritable) { |
|
rossberg
2015/05/22 13:10:28
Nit: if (!currentIsWritable || IS_STRONG(obj)) h
conradw
2015/05/22 14:07:08
Done. Silly to miss this.
|
| + if (should_throw) { |
| + throw MakeTypeError(kRedefineDisallowed, p); |
|
rossberg
2015/05/22 13:10:28
...and then throw currentIsWritable ? MakeTypeErr
conradw
2015/05/22 14:07:08
Done.
|
| + } else { |
| + return false; |
| + } |
| + } |
| + if (IS_STRONG(obj)) { |
|
rossberg
2015/05/22 13:10:28
...and eliminate this duplication
conradw
2015/05/22 14:07:08
Done.
|
| + if (should_throw) { |
| + throw MakeTypeError(kStrongRedefineDisallowed, p, obj); |
| + } else { |
| + return false; |
| + } |
| } |
| } |
| - if (!current.isWritable() && desc.hasValue() && |
| + if (!currentIsWritable && desc.hasValue() && |
| !$sameValue(desc.getValue(), current.getValue())) { |
| if (should_throw) { |
| throw MakeTypeError(kRedefineDisallowed, p); |