tor-browser

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

Environment-module-01.js (665B)


      1 // Debug environments for module environments should include variables that are
      2 // are not closed over or exported.
      3 
      4 var g = newGlobal({newCompartment: true});
      5 var dbg = Debugger(g);
      6 dbg.onEnterFrame = function (frame) {
      7  if (!frame.older) {
      8    return;
      9  }
     10  const env = frame.older.environment;
     11  assertEq(env.names().join(','), "foo,y,x,z");
     12  assertEq(env.getVariable('x'), 0);
     13  assertEq(env.getVariable('y'), 1);
     14  assertEq(env.getVariable('z'), 2);
     15  env.setVariable('x', 3);
     16  assertEq(env.getVariable('x'), 3);
     17 };
     18 const m = g.parseModule(`
     19  var x = 0;
     20  export var y = 1;
     21  const z = 2;
     22  foo();
     23  function foo() {}
     24 `);
     25 moduleLink(m);
     26 moduleEvaluate(m);