Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(82)

Unified Diff: src/v8natives.js

Issue 8890015: Fix another corner case for DefineOwnProperty on arrays. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 9 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | test/test262/test262.status » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/v8natives.js
diff --git a/src/v8natives.js b/src/v8natives.js
index 61b130c196db2462289abe12e9aea7a7012bdfe7..1d54e28e97687ca981372b41525ffbed6b150e3a 100644
--- a/src/v8natives.js
+++ b/src/v8natives.js
@@ -873,29 +873,33 @@ function DefineArrayProperty(obj, p, desc, should_throw) {
throw new $RangeError('defineProperty() array length out of range');
}
var length_desc = GetOwnProperty(obj, "length");
+ if (new_length != length && !length_desc.isWritable()) {
+ if (should_throw) {
+ throw MakeTypeError("redefine_disallowed", [p]);
+ } else {
+ return false;
+ }
+ }
+ var threw = false;
+ while (new_length < length--) {
+ if (!Delete(obj, ToString(length), false)) {
+ new_length = length + 1;
+ threw = true;
+ break;
+ }
+ }
// Make sure the below call to DefineObjectProperty() doesn't overwrite
// any magic "length" property by removing the value.
+ obj.length = new_length;
desc.value_ = void 0;
desc.hasValue_ = false;
- if ((new_length != length && !length_desc.isWritable()) ||
- !DefineObjectProperty(obj, "length", desc, should_throw)) {
+ if (!DefineObjectProperty(obj, "length", desc, should_throw) || threw) {
if (should_throw) {
throw MakeTypeError("redefine_disallowed", [p]);
} else {
return false;
}
}
- obj.length = new_length;
- while (new_length < length--) {
- if (!Delete(obj, length, false)) {
- obj.length = length + 1;
- if (should_throw) {
- throw MakeTypeError("redefine_disallowed", [p]);
- } else {
- return false;
- }
- }
- }
return true;
}
« no previous file with comments | « no previous file | test/test262/test262.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698