tor-browser

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

interrupt-1.js (877B)


      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("unexpected call to return method");
     18  },
     19 };
     20 
     21 function emptyFunctionToCheckInterruptState() {
     22  // Ion doesn't check the interrupt state, so don't run this function in it.
     23  with ({}) ;
     24 }
     25 
     26 for (var v of iterator) {
     27  // Request an interrupt.
     28  interruptIf(true);
     29 
     30  // Calling a function triggers reading the interrupt state.
     31  emptyFunctionToCheckInterruptState();
     32 
     33  // Break statements normally run the iterator's "return" method. Ensure the
     34  // method isn't called when an interrupt was requested.
     35  break;
     36 }