tor-browser

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

abrupt_completion_worker.js (660B)


      1 function setMessageHandler(response) {
      2  onmessage = e => {
      3    e.source.postMessage(response);
      4  };
      5 }
      6 
      7 setMessageHandler("handler-before-throw");
      8 
      9 // importScripts will throw when the ServiceWorker is past the "intalling" state.
     10 importScripts(`empty.js?${Date.now()}`);
     11 
     12 // When importScripts throws an uncaught exception, these calls should never be
     13 // made and the message handler should remain responding "handler-before-throw".
     14 setMessageHandler("handler-after-throw");
     15 
     16 // There needs to be a fetch handler to avoid the no-fetch optimizaiton,
     17 // which will skip starting up this worker.
     18 onfetch = e => e.respondWith(new Response("handler-after-throw"));