|
1 |
|
2 // Properties cleared in the middle of a single function constructor. |
|
3 |
|
4 function foo(x, y) { |
|
5 this.f = 0; |
|
6 this.g = x + y; |
|
7 this.h = 2; |
|
8 } |
|
9 |
|
10 var called = false; |
|
11 var a = 0; |
|
12 var b = {valueOf: function() { Object.defineProperty(Object.prototype, 'g', {set: function() { called = true }}) }}; |
|
13 var c = new foo(a, b); |
|
14 |
|
15 assertEq(called, true); |
|
16 assertEq(c.g, undefined); |
|
17 |
|
18 // Properties cleared in the middle of a constructor callee. |
|
19 |
|
20 function foo2(x, y) { |
|
21 this.a = 0; |
|
22 this.b = 1; |
|
23 bar2.call(this, x, y); |
|
24 this.c = 2; |
|
25 } |
|
26 function bar2(x, y) { |
|
27 this.d = x + y; |
|
28 this.e = 3; |
|
29 } |
|
30 |
|
31 var called2 = false; |
|
32 var xa = 0; |
|
33 var xb = {valueOf: function() { Object.defineProperty(Object.prototype, 'e', {set: function() { called2 = true }}) }}; |
|
34 var xc = new foo2(xa, xb); |
|
35 |
|
36 assertEq(called2, true); |
|
37 assertEq(xc.e, undefined); |
|
38 assertEq(xc.c, 2); |
|
39 |
|
40 // Properties cleared after a constructor callee. |
|
41 |
|
42 function foo3() { |
|
43 this.aa = 0; |
|
44 this.bb = 1; |
|
45 bar3.call(this); |
|
46 this.cc = 2; |
|
47 baz(); |
|
48 xbar3.call(this); |
|
49 this.dd = 3; |
|
50 } |
|
51 function bar3() { |
|
52 this.ee = 4; |
|
53 } |
|
54 function xbar3() { |
|
55 this.ff = 5; |
|
56 } |
|
57 function baz() { |
|
58 eval("xbar3.call = function() { called3 = true }"); |
|
59 } |
|
60 |
|
61 var called3 = false; |
|
62 var c3 = new foo3(); |
|
63 assertEq(c3.cc, 2); |
|
64 assertEq(c3.ee, 4); |
|
65 assertEq(c3.ff, undefined); |
|
66 assertEq(c3.dd, 3); |
|
67 assertEq(called3, true); |