tor-browser

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

import-scripts-worker.js (1229B)


      1 try {
      2  importScripts('empty-worker.js');
      3  if ('DedicatedWorkerGlobalScope' in self &&
      4      self instanceof DedicatedWorkerGlobalScope) {
      5    postMessage('LOADED');
      6  } else if (
      7      'SharedWorkerGlobalScope' in self &&
      8      self instanceof SharedWorkerGlobalScope) {
      9    onconnect = e => {
     10      e.ports[0].postMessage('LOADED');
     11    };
     12  }
     13 } catch (e) {
     14  // Post a message instead of propagating an ErrorEvent to the page because
     15  // propagated event loses an error name.
     16  //
     17  // Step 1. "Let notHandled be the result of firing an event named error at the
     18  // Worker object associated with the worker, using ErrorEvent, with the
     19  // cancelable attribute initialized to true, the message, filename, lineno,
     20  // and colno attributes initialized appropriately, and the error attribute
     21  // initialized to null."
     22  // https://html.spec.whatwg.org/multipage/workers.html#runtime-script-errors-2
     23  if ('DedicatedWorkerGlobalScope' in self &&
     24      self instanceof DedicatedWorkerGlobalScope) {
     25    postMessage(e.name);
     26  } else if (
     27      'SharedWorkerGlobalScope' in self &&
     28      self instanceof SharedWorkerGlobalScope) {
     29    onconnect = connectEvent => {
     30      connectEvent.ports[0].postMessage(e.name);
     31    };
     32  }
     33 }