tor-browser

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

Frame-evalWithBindings-09.js (1065B)


      1 // evalWithBindings code is debuggee code, so it can trip the debugger. It nests!
      2 var g = newGlobal({newCompartment: true});
      3 var dbg = new Debugger(g);
      4 var f1;
      5 var hits = 0;
      6 dbg.onDebuggerStatement = function (frame) {
      7    f1 = frame;
      8 
      9    // This trips the onExceptionUnwind hook.
     10    var x = frame.evalWithBindings("wrongSpeling", {rightSpelling: 2}).throw;
     11 
     12    assertEq(frame.evalWithBindings("exc.name", {exc: x}).return, "ReferenceError");
     13    hits++;
     14 };
     15 dbg.onExceptionUnwind = function (frame, exc) {
     16    assertEq(frame !== f1, true);
     17 
     18    // f1's environment does not contain the binding for the first evalWithBindings call.
     19    assertEq(f1.eval("rightSpelling").return, "dependent");
     20    assertEq(f1.evalWithBindings("n + rightSpelling", {n: "in"}).return, "independent");
     21 
     22    // frame's environment does contain the binding.
     23    assertEq(frame.eval("rightSpelling").return, 2);
     24    assertEq(frame.evalWithBindings("rightSpelling + three", {three: 3}).return, 5);
     25    hits++;
     26 };
     27 g.eval("(function () { var rightSpelling = 'dependent'; debugger; })();");