Commit 19e82212 authored by whesse@chromium.org's avatar whesse@chromium.org

Fix issue number 398: replacing a constant function on a clone.

Review URL: http://codereview.chromium.org/149249

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@2379 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 35a1de0f
......@@ -1865,7 +1865,7 @@ Object* JSObject::SetProperty(LookupResult* result,
if (value == result->GetConstantFunction()) return value;
// Preserve the attributes of this existing property.
attributes = result->GetAttributes();
return ConvertDescriptorToFieldAndMapTransition(name, value, attributes);
return ConvertDescriptorToField(name, value, attributes);
case CALLBACKS:
return SetPropertyWithCallback(result->GetCallbackObject(),
name,
......@@ -1947,7 +1947,7 @@ Object* JSObject::IgnoreAttributesAndSetLocalProperty(
if (value == result->GetConstantFunction()) return value;
// Preserve the attributes of this existing property.
attributes = result->GetAttributes();
return ConvertDescriptorToFieldAndMapTransition(name, value, attributes);
return ConvertDescriptorToField(name, value, attributes);
case CALLBACKS:
case INTERCEPTOR:
// Override callback in clone
......
......@@ -7041,3 +7041,21 @@ THREADED_TEST(InitGlobalVarInProtoChain) {
CHECK(!result->IsUndefined());
CHECK_EQ(42, result->Int32Value());
}
// Regression test for issue 398.
// If a function is added to an object, creating a constant function
// field, and the result is cloned, replacing the constant function on the
// original should not affect the clone.
// See http://code.google.com/p/v8/issues/detail?id=398
THREADED_TEST(ReplaceConstantFunction) {
v8::HandleScope scope;
LocalContext context;
v8::Handle<v8::Object> obj = v8::Object::New();
v8::Handle<v8::FunctionTemplate> func_templ = v8::FunctionTemplate::New();
v8::Handle<v8::String> foo_string = v8::String::New("foo");
obj->Set(foo_string, func_templ->GetFunction());
v8::Handle<v8::Object> obj_clone = obj->Clone();
obj_clone->Set(foo_string, v8::String::New("Hello"));
CHECK(!obj->Get(foo_string)->IsUndefined());
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment