tor-browser

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

onEnterFrame-async-tryskipawait-01.js (966B)


      1 // CanSkipAwait with resolved Promises when attaching onEnterFrame
      2 // after the initial call into the async function.
      3 
      4 load(libdir + "array-compare.js");
      5 
      6 let g = newGlobal({ newCompartment: true });
      7 let dbg = new Debugger(g);
      8 
      9 let log = [];
     10 g.log = log;
     11 
     12 g.eval(`
     13    async function f() {
     14        log.push("START");
     15        await Promise.resolve(0);
     16        log.push("MIDDLE");
     17        await Promise.resolve(0);
     18        log.push("END");
     19    }
     20 `);
     21 
     22 function neverCalled(e) {
     23    // Quit with non-zero exit code to ensure a test suite error is shown,
     24    // even when this function is called within promise handlers which normally
     25    // swallow any exceptions.
     26    print("Error: " + e + "\nstack:\n" + e.stack);
     27    quit(1);
     28 }
     29 
     30 g.f().then(() => {
     31    assertEq(arraysEqual(log, [
     32        "START",
     33        "enter: f",
     34        "MIDDLE",
     35        "END",
     36    ]), true);
     37 }).catch(neverCalled);
     38 
     39 dbg.onEnterFrame = frame => {
     40    log.push(`enter: ${frame.callee.name}`);
     41 };