Index: src/objects.cc |
diff --git a/src/objects.cc b/src/objects.cc |
index 9a5357a338db84f2a643c5980d3dc3dd028ca031..47ba64dce0e49c2003525403a3ecbb8b9434c7d7 100644 |
--- a/src/objects.cc |
+++ b/src/objects.cc |
@@ -6866,6 +6866,22 @@ MaybeObject* JSObject::SetPrototype(Object* value, |
// SpiderMonkey behaves this way. |
if (!value->IsJSObject() && !value->IsNull()) return value; |
+ // From 8.6.2 Object Internal Methods |
+ // ... |
+ // In addition, if [[Extensible]] is false the value of the [[Class]] and |
+ // [[Prototype]] internal properties of the object may not be modified. |
+ // ... |
+ // Implementation specific extensions that modify [[Class]], [[Prototype]] |
+ // or [[Extensible]] must not violate the invariants defined in the preceding |
+ // paragraph. |
+ if (!this->map()->is_extensible()) { |
+ HandleScope scope; |
+ Handle<Object> handle(this, heap->isolate()); |
+ return heap->isolate()->Throw( |
+ *FACTORY->NewTypeError("non_extensible_proto", |
+ HandleVector<Object>(&handle, 1))); |
+ } |
+ |
// Before we can set the prototype we need to be sure |
// prototype cycles are prevented. |
// It is sufficient to validate that the receiver is not in the new prototype |