Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
1 // Environments of different instances of the same generator have the same
2 // callee. I love this job.
4 var g = newGlobal();
5 var dbg = new Debugger;
6 var gw = dbg.addDebuggee(g);
8 function check(gen, label) {
9 print("check(" + label + ")");
10 var hits;
11 dbg.onDebuggerStatement = function (frame) {
12 hits++;
13 var env = frame.environment;
14 assertEq(env.callee, gw.makeDebuggeeValue(g.f));
15 };
16 hits = 0;
17 gen.next();
18 assertEq(hits, 1);
19 }
21 g.eval('function f(x) { debugger; yield x; }');
22 g.eval('var g = f(2);');
23 g.eval('var h = f(3);');
24 check(g.g, 'g.g');
25 check(g.h, 'g.h');
27 g.eval('function* f(x) { debugger; yield x; }');
28 g.eval('var g = f(2);');
29 g.eval('var h = f(3);');
30 check(g.g, 'g.g');
31 check(g.h, 'g.h');