michael@0: michael@0: // Properties cleared in the middle of a single function constructor. michael@0: michael@0: function foo(x, y) { michael@0: this.f = 0; michael@0: this.g = x + y; michael@0: this.h = 2; michael@0: } michael@0: michael@0: var called = false; michael@0: var a = 0; michael@0: var b = {valueOf: function() { Object.defineProperty(Object.prototype, 'g', {set: function() { called = true }}) }}; michael@0: var c = new foo(a, b); michael@0: michael@0: assertEq(called, true); michael@0: assertEq(c.g, undefined); michael@0: michael@0: // Properties cleared in the middle of a constructor callee. michael@0: michael@0: function foo2(x, y) { michael@0: this.a = 0; michael@0: this.b = 1; michael@0: bar2.call(this, x, y); michael@0: this.c = 2; michael@0: } michael@0: function bar2(x, y) { michael@0: this.d = x + y; michael@0: this.e = 3; michael@0: } michael@0: michael@0: var called2 = false; michael@0: var xa = 0; michael@0: var xb = {valueOf: function() { Object.defineProperty(Object.prototype, 'e', {set: function() { called2 = true }}) }}; michael@0: var xc = new foo2(xa, xb); michael@0: michael@0: assertEq(called2, true); michael@0: assertEq(xc.e, undefined); michael@0: assertEq(xc.c, 2); michael@0: michael@0: // Properties cleared after a constructor callee. michael@0: michael@0: function foo3() { michael@0: this.aa = 0; michael@0: this.bb = 1; michael@0: bar3.call(this); michael@0: this.cc = 2; michael@0: baz(); michael@0: xbar3.call(this); michael@0: this.dd = 3; michael@0: } michael@0: function bar3() { michael@0: this.ee = 4; michael@0: } michael@0: function xbar3() { michael@0: this.ff = 5; michael@0: } michael@0: function baz() { michael@0: eval("xbar3.call = function() { called3 = true }"); michael@0: } michael@0: michael@0: var called3 = false; michael@0: var c3 = new foo3(); michael@0: assertEq(c3.cc, 2); michael@0: assertEq(c3.ee, 4); michael@0: assertEq(c3.ff, undefined); michael@0: assertEq(c3.dd, 3); michael@0: assertEq(called3, true);