tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

Environment-calleeScript-03.js (614B)


      1 // Environments of different instances of the same generator have the same
      2 // calleeScript.
      3 
      4 var g = newGlobal({newCompartment: true});
      5 var dbg = new Debugger;
      6 var gw = dbg.addDebuggee(g);
      7 
      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.calleeScript, gw.makeDebuggeeValue(g.f).script);
     15  };
     16  hits = 0;
     17  gen.next();
     18  assertEq(hits, 1);
     19 }
     20 
     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');