Author: [email protected]
Date: Tue Jul  7 07:06:08 2009
New Revision: 2379

Modified:
    branches/bleeding_edge/src/objects.cc
    branches/bleeding_edge/test/cctest/test-api.cc

Log:
Fix issue number 398: replacing a constant function on a clone.
Review URL: http://codereview.chromium.org/149249

Modified: branches/bleeding_edge/src/objects.cc
==============================================================================
--- branches/bleeding_edge/src/objects.cc       (original)
+++ branches/bleeding_edge/src/objects.cc       Tue Jul  7 07:06:08 2009
@@ -1865,7 +1865,7 @@
        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 @@
        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

Modified: branches/bleeding_edge/test/cctest/test-api.cc
==============================================================================
--- branches/bleeding_edge/test/cctest/test-api.cc      (original)
+++ branches/bleeding_edge/test/cctest/test-api.cc      Tue Jul  7 07:06:08 2009
@@ -7041,3 +7041,21 @@
    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());
+}

--~--~---------~--~----~------------~-------~--~----~
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
-~----------~----~----~----~------~----~------~--~---

Reply via email to