tor-browser

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

Frame-newTargetOverflow-01.js (1112B)


      1 // Test that Ion frames are invalidated by turning on Debugger. Invalidation
      2 // is unobservable, but we know that Ion scripts cannot handle Debugger
      3 // handlers, so we test for the handlers being called.
      4 
      5 load(libdir + "jitopts.js");
      6 
      7 if (!jitTogglesMatch(Opts_Ion2NoOffthreadCompilation))
      8  quit();
      9 
     10 // GCs can invalidate JIT code and cause this test to fail.
     11 if ('gczeal' in this)
     12    gczeal(0);
     13 
     14 withJitOptions(Opts_Ion2NoOffthreadCompilation, function () {
     15  var g = newGlobal({newCompartment: true});
     16  var dbg = new Debugger;
     17 
     18  g.toggle = function toggle(d) {
     19    if (d) {
     20      dbg.addDebuggee(g);
     21 
     22      var frame = dbg.getNewestFrame();
     23      assertEq(frame.implementation, "ion");
     24      assertEq(frame.constructing, true);
     25 
     26      // overflow args are read from the parent's frame
     27      // ensure we have the right offset to read from those.
     28      assertEq(frame.arguments[1], 15);
     29    }
     30  };
     31 
     32  g.eval("" + function f(d) { new g(d, 15); });
     33 
     34  g.eval("" + function g(d) { toggle(d); });
     35 
     36  g.eval("(" + function test() {
     37    for (var i = 0; i < 5; i++)
     38      f(false);
     39    f(true);
     40  } + ")();");
     41 });