tor-browser

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

await-exception-stack-in-finally-1.js (656B)


      1 load(libdir + "asserts.js");
      2 
      3 var g = newGlobal({newCompartment: true})
      4 
      5 // Throw an exception from a different compartment.
      6 var thrower = g.Function(`
      7  throw 0;
      8 `);
      9 
     10 async function throwAndAwait() {
     11  try {
     12    thrower();
     13  } finally {
     14    // The |finally| block is entered with the exception stack on the function
     15    // stack. The function stack is saved in the generator object when executing
     16    // |await|, so the exception stack, which was created in a different
     17    // compartment, has to be wrapped into the current compartment.
     18    await {};
     19  }
     20 }
     21 throwAndAwait().then(() => {
     22  throw new Error("missing error");
     23 }, e => {
     24  assertEq(e, 0);
     25 });