tor-browser

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

Frame-newTargetEval-01.js (1224B)


      1 // Test that new.target is acceptably usable in RematerializedFrames.
      2 
      3 gczeal(0);
      4 
      5 load(libdir + "jitopts.js");
      6 
      7 if (!jitTogglesMatch(Opts_Ion2NoOffthreadCompilation))
      8  quit();
      9 
     10 withJitOptions(Opts_Ion2NoOffthreadCompilation, function () {
     11  var g = newGlobal({newCompartment: true});
     12  var dbg = new Debugger;
     13 
     14  g.toggle = function toggle(d, expected) {
     15    if (d) {
     16      dbg.addDebuggee(g);
     17 
     18      var frame = dbg.getNewestFrame();
     19      assertEq(frame.implementation, "ion");
     20      assertEq(frame.constructing, true);
     21 
     22      // CONGRATS IF THIS FAILS! You, proud saviour, have made new.target parse
     23      // in debug frame evals (presumably by hooking up static scope walks).
     24      // Uncomment the assert below for efaust's undying gratitude.
     25      // Note that we use .name here because of CCW nonsense.
     26      assertEq(frame.eval('new.target').throw.unsafeDereference().name, "SyntaxError");
     27      // assertEq(frame.eval('new.target').value.unsafeDereference(), expected);
     28    }
     29  };
     30 
     31  g.eval("" + function f(d) { new g(d, g, 15); });
     32 
     33  g.eval("" + function g(d, expected) { toggle(d, expected); });
     34 
     35  g.eval("(" + function test() {
     36    for (var i = 0; i < 5; i++)
     37      f(false);
     38    f(true);
     39  } + ")();");
     40 });