[Webkit-unassigned] [Bug 48911] New: Object.defineProperty doesn't create property on Global Object in the presence of a setter in the prototype chain
bugzilla-daemon at webkit.org
bugzilla-daemon at webkit.org
Wed Nov 3 06:26:12 PDT 2010
https://bugs.webkit.org/show_bug.cgi?id=48911
Summary: Object.defineProperty doesn't create property on
Global Object in the presence of a setter in the
prototype chain
Product: WebKit
Version: 528+ (Nightly build)
Platform: PC
OS/Version: All
Status: NEW
Severity: Normal
Priority: P2
Component: JavaScriptCore
AssignedTo: webkit-unassigned at lists.webkit.org
ReportedBy: kent.hansen at nokia.com
For normal objects, this works as expected:
o = {};
o.__proto__ = {};
o.__proto__.__defineGetter__("foo", function() { return this._x; });
o.__proto__.__defineSetter__("foo", function(v) { this._x = v; });
o.foo = 123;
o.hasOwnProperty("foo"); // false
Object.defineProperty(o, "foo", { value : 456 });
o.hasOwnProperty("foo"); // true
i.e. even if there's a getter for a property named "foo" in the prototype chain, Object.defineProperty creates a new property on the object itself. This is in accordance with the ES5 spec, so all is good.
However, if instead you do this on the Global Object (this=global):
this.__proto__ = {};
this.__proto__.__defineGetter__("foo", function() { return this._x; });
this.__proto__.__defineSetter__("foo", function(v) { this._x = v; });
this.foo = 123;
this.hasOwnProperty("foo"); // false
Object.defineProperty(this, "foo", { value : 456 });
this.hasOwnProperty("foo"); // still false
the property will _not_ be created on the Global Object, but will instead call the setter in the prototype.
This is because JSGlobalObject::putWithAttributes() calls JSObject::put(), as discussed in https://bugs.webkit.org/show_bug.cgi?id=38636.
--
Configure bugmail: https://bugs.webkit.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
More information about the webkit-unassigned
mailing list