tor-browser

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

Frame-constructing-03.js (651B)


      1 // Debugger.Frame.prototype.constructing on an async generator.
      2 
      3 load(libdir + "asserts.js");
      4 
      5 const g = newGlobal({ newCompartment: true });
      6 const dbg = Debugger(g);
      7 
      8 g.eval(`
      9 async function* f() {
     10  await Promise.resolve();
     11 }
     12 `);
     13 
     14 let frame;
     15 dbg.onEnterFrame = function(f) {
     16  frame = f;
     17  assertEq(frame.constructing, false);
     18 };
     19 
     20 (async () => {
     21  const it = g.f();
     22 
     23  assertEq(frame.constructing, false);
     24  frame = null;
     25 
     26  const promise = it.next();
     27 
     28  assertEq(!!frame, true);
     29  assertEq(frame.constructing, false);
     30 
     31  await promise;
     32 
     33  // Throws because the frame has terminated.
     34  assertThrowsInstanceOf(() => frame.constructing, Error);
     35 })();