tor-browser

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

breakpoint-oom-01.js (1042B)


      1 // |jit-test| skip-if: !hasFunction.oomTest
      2 
      3 // Test for OOM hitting a breakpoint in a generator.
      4 //
      5 // (The purpose is to test OOM-handling in the code that creates the
      6 // Debugger.Frame object and associates it with the generator object.)
      7 
      8 let g = newGlobal({newCompartment: true});
      9 g.eval(`\
     10    function* gen(x) {  // line 1
     11        x++;            // 2
     12        yield x;        // 3
     13    }                   // 4
     14 `);
     15 
     16 let dbg = new Debugger;
     17 
     18 // On OOM in the debugger, propagate it to the debuggee.
     19 dbg.uncaughtExceptionHook = exc => exc === "out of memory" ? {throw: exc} : null;
     20 
     21 let gw = dbg.addDebuggee(g);
     22 let script = gw.makeDebuggeeValue(g.gen).script;
     23 let hits = 0;
     24 let handler = {
     25    hit(frame) {
     26        hits++;
     27        print("x=", frame.environment.getVariable("x"));
     28    }
     29 };
     30 for (let offset of script.getLineOffsets(2))
     31    script.setBreakpoint(offset, handler);
     32 
     33 let result;
     34 oomTest(() => {
     35    hits = 0;
     36    result = g.gen(1).next();
     37 }, false);
     38 assertEq(hits, 1);
     39 assertEq(result.done, false);
     40 assertEq(result.value, 2);