Commit c0df3f0a authored by lrn@chromium.org's avatar lrn@chromium.org

Fix issue 965.

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@5960 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent ec30a698
......@@ -615,7 +615,13 @@ function DefineOwnProperty(obj, p, desc, should_throw) {
} else {
flag |= READ_ONLY;
}
%DefineOrRedefineDataProperty(obj, p, desc.getValue(), flag);
var value; // Default value is undefined.
if (desc.hasValue()) {
value = desc.getValue();
} else if (!IS_UNDEFINED(current)) {
value = current.getValue();
}
%DefineOrRedefineDataProperty(obj, p, value, flag);
} else {
if (desc.hasGetter() && IS_FUNCTION(desc.getGet())) {
%DefineOrRedefineAccessorProperty(obj, p, GETTER, desc.getGet(), flag);
......
......@@ -866,4 +866,36 @@ assertFalse(desc.writable);
assertFalse(desc.enumerable);
assertFalse(desc.configurable);
// See issue 968: http://code.google.com/p/v8/issues/detail?id=968
var o = { x : 42 };
Object.defineProperty(o, "x", { writable: false });
assertEquals(42, o.x);
o.x = 37;
assertEquals(42, o.x);
o = { x : 42 };
Object.defineProperty(o, "x", {});
assertEquals(42, o.x);
o.x = 37;
// Writability is preserved.
assertEquals(37, o.x);
var o = { };
Object.defineProperty(o, "x", { writable: false });
assertEquals(undefined, o.x);
o.x = 37;
assertEquals(undefined, o.x);
o = { get x() { return 87; } };
Object.defineProperty(o, "x", { writable: false });
assertEquals(undefined, o.x);
o.x = 37;
assertEquals(undefined, o.x);
// Ignore inherited properties.
o = { __proto__ : { x : 87 } };
Object.defineProperty(o, "x", { writable: false });
assertEquals(undefined, o.x);
o.x = 37;
assertEquals(undefined, o.x);
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