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

Unified Diff: src/objects.cc

Issue 6712059: Follow jsc on not throwing when trying to add a property to a non-extensible object. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 9 years, 9 months 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
Index: src/objects.cc
===================================================================
--- src/objects.cc (revision 7276)
+++ src/objects.cc (working copy)
@@ -1438,13 +1438,19 @@
MaybeObject* JSObject::AddProperty(String* name,
Object* value,
- PropertyAttributes attributes) {
+ PropertyAttributes attributes,
+ StrictModeFlag strict_mode) {
ASSERT(!IsJSGlobalProxy());
Heap* heap = GetHeap();
if (!map()->is_extensible()) {
- Handle<Object> args[1] = {Handle<String>(name)};
- return heap->isolate()->Throw(
- *FACTORY->NewTypeError("object_not_extensible", HandleVector(args, 1)));
+ if (strict_mode == kNonStrictMode) {
+ return heap->undefined_value();
+ } else {
+ Handle<Object> args[1] = {Handle<String>(name)};
+ return heap->isolate()->Throw(
+ *FACTORY->NewTypeError("object_not_extensible",
+ HandleVector(args, 1)));
+ }
}
if (HasFastProperties()) {
// Ensure the descriptor array does not get too big.
@@ -1485,7 +1491,7 @@
return SetProperty(&result, name, value, attributes, strict_mode);
}
// Add a new real property.
- return AddProperty(name, value, attributes);
+ return AddProperty(name, value, attributes, strict_mode);
}
@@ -1989,7 +1995,7 @@
}
if (!result->IsFound()) {
// Neither properties nor transitions found.
- return AddProperty(name, value, attributes);
+ return AddProperty(name, value, attributes, strict_mode);
}
if (result->IsReadOnly() && result->IsProperty()) {
if (strict_mode == kStrictMode) {
@@ -2096,7 +2102,7 @@
// Check for accessor in prototype chain removed here in clone.
if (!result.IsFound()) {
// Neither properties nor transitions found.
- return AddProperty(name, value, attributes);
+ return AddProperty(name, value, attributes, kNonStrictMode);
}
PropertyDetails details = PropertyDetails(attributes, NORMAL);
@@ -7347,13 +7353,17 @@
// When we set the is_extensible flag to false we always force
// the element into dictionary mode (and force them to stay there).
if (!map()->is_extensible()) {
- Handle<Object> number(isolate->factory()->NewNumberFromUint(index));
- Handle<String> index_string(
- isolate->factory()->NumberToString(number));
- Handle<Object> args[1] = { index_string };
- return isolate->Throw(
- *isolate->factory()->NewTypeError("object_not_extensible",
- HandleVector(args, 1)));
+ if (strict_mode == kNonStrictMode) {
+ return isolate->heap()->undefined_value();
+ } else {
+ Handle<Object> number(isolate->factory()->NewNumberFromUint(index));
+ Handle<String> index_string(
+ isolate->factory()->NumberToString(number));
+ Handle<Object> args[1] = { index_string };
+ return isolate->Throw(
+ *isolate->factory()->NewTypeError("object_not_extensible",
+ HandleVector(args, 1)));
+ }
}
Object* result;
{ MaybeObject* maybe_result = dictionary->AtNumberPut(index, value);
« no previous file with comments | « src/objects.h ('k') | test/cctest/test-api.cc » ('j') | test/mjsunit/strict-mode.js » ('J')

Powered by Google App Engine
This is Rietveld 408576698