tor-browser

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

interrupt-3.js (1074B)


      1 // |jit-test| exitstatus: 6;
      2 
      3 setInterruptCallback(function() {
      4  // Return false from the interrupt handler to stop execution.
      5  return false;
      6 });
      7 
      8 var iterator = {
      9  [Symbol.iterator]() {
     10    return this;
     11  },
     12  next() {
     13    return {value: null, done: false};
     14  },
     15  return() {
     16    // Intentionally use |crash| to cause an abrupt program termination.
     17    crash("iterator return");
     18  },
     19 };
     20 
     21 function emptyFunctionToCheckInterruptState() {
     22  // Ion doesn't the check interrupt state, so don't run this function in it.
     23  with ({}) ;
     24 }
     25 
     26 class P extends Promise {
     27  static resolve(v) {
     28    // Request an interrupt.
     29    interruptIf(true);
     30 
     31    emptyFunctionToCheckInterruptState();
     32 
     33    return {
     34      then() {
     35        // Intentionally use |crash| to cause an abrupt program termination.
     36        crash("then called");
     37      }
     38    };
     39  }
     40 }
     41 
     42 // Promise.any internally uses |js::ForOfIterator|. Ensure ForOfIterator's
     43 // behavior for interrupt handling matches for-of loops (tested in this file's
     44 // siblings "interrupt-1.js" and "interrupt-2.js").
     45 
     46 Promise.any.call(P, iterator);