|
1 // Adding a debuggee allowed with scripts on stack from stranger places. |
|
2 |
|
3 // Test CCW. |
|
4 (function testCCW() { |
|
5 var g = newGlobal(); |
|
6 var dbg = new Debugger; |
|
7 g.dbg = dbg; |
|
8 g.GLOBAL = g; |
|
9 |
|
10 g.turnOnDebugger = function () { |
|
11 dbg.addDebuggee(g); |
|
12 }; |
|
13 |
|
14 g.eval("" + function f(d) { |
|
15 turnOnDebugger(); |
|
16 assertEq(dbg.hasDebuggee(GLOBAL), true); |
|
17 }); |
|
18 |
|
19 g.eval("(" + function test() { |
|
20 f(false); |
|
21 f(false); |
|
22 f(true); |
|
23 f(true); |
|
24 } + ")();"); |
|
25 })(); |
|
26 |
|
27 // Test getter. |
|
28 (function testGetter() { |
|
29 var g = newGlobal(); |
|
30 g.dbg = new Debugger; |
|
31 g.GLOBAL = g; |
|
32 |
|
33 g.eval("" + function f(obj) { |
|
34 obj.foo; |
|
35 assertEq(dbg.hasDebuggee(GLOBAL), true); |
|
36 }); |
|
37 |
|
38 g.eval("(" + function test() { |
|
39 f({ get foo() { dbg.addDebuggee(GLOBAL); } }); |
|
40 } + ")();"); |
|
41 })(); |
|
42 |
|
43 // Test setter. |
|
44 (function testSetter() { |
|
45 var g = newGlobal(); |
|
46 g.dbg = new Debugger; |
|
47 g.GLOBAL = g; |
|
48 |
|
49 g.eval("" + function f(obj) { |
|
50 obj.foo = 42; |
|
51 assertEq(dbg.hasDebuggee(GLOBAL), true); |
|
52 }); |
|
53 |
|
54 g.eval("(" + function test() { |
|
55 f({ set foo(v) { dbg.addDebuggee(GLOBAL); } }); |
|
56 } + ")();"); |
|
57 })(); |
|
58 |
|
59 // Test toString. |
|
60 (function testToString() { |
|
61 var g = newGlobal(); |
|
62 g.dbg = new Debugger; |
|
63 g.GLOBAL = g; |
|
64 |
|
65 g.eval("" + function f(obj) { |
|
66 obj + ""; |
|
67 assertEq(dbg.hasDebuggee(GLOBAL), true); |
|
68 }); |
|
69 |
|
70 g.eval("(" + function test() { |
|
71 f({ toString: function () { dbg.addDebuggee(GLOBAL); }}); |
|
72 } + ")();"); |
|
73 })(); |
|
74 |
|
75 // Test valueOf. |
|
76 (function testValueOf() { |
|
77 var g = newGlobal(); |
|
78 g.dbg = new Debugger; |
|
79 g.GLOBAL = g; |
|
80 |
|
81 g.eval("" + function f(obj) { |
|
82 obj + ""; |
|
83 assertEq(dbg.hasDebuggee(GLOBAL), true); |
|
84 }); |
|
85 |
|
86 g.eval("(" + function test() { |
|
87 f({ valueOf: function () { dbg.addDebuggee(GLOBAL); }}); |
|
88 } + ")();"); |
|
89 })(); |
|
90 |
|
91 // Test proxy trap. |
|
92 (function testProxyTrap() { |
|
93 var g = newGlobal(); |
|
94 g.dbg = new Debugger; |
|
95 g.GLOBAL = g; |
|
96 |
|
97 g.eval("" + function f(proxy) { |
|
98 proxy["foo"]; |
|
99 assertEq(dbg.hasDebuggee(GLOBAL), true); |
|
100 }); |
|
101 |
|
102 g.eval("(" + function test() { |
|
103 var handler = { get: function () { dbg.addDebuggee(GLOBAL); } }; |
|
104 var proxy = new Proxy({}, handler); |
|
105 f(proxy); |
|
106 } + ")();"); |
|
107 })(); |