tor-browser

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

serviceworker-failure.js (1281B)


      1 "use strict";
      2 self.importScripts("/resources/testharness.js");
      3 
      4 let state = "start in worker";
      5 
      6 self.onmessage = e => {
      7  if (e.data === "start in window") {
      8    assert_equals(state, "start in worker");
      9    e.source.postMessage(state);
     10    state = "we are expecting a messageerror due to the window sending us a SAB";
     11  } else if (e.data === "we are expecting a messageerror due to the worker sending us a SAB") {
     12    assert_equals(state, "onmessageerror was received in worker");
     13    e.source.postMessage(new SharedArrayBuffer());
     14    state = "done in worker";
     15  } else {
     16    e.source.postMessage(`worker onmessage was reached when in state "${state}" and data ${e.data}`);
     17  }
     18 };
     19 
     20 self.onmessageerror = e => {
     21  if (state === "we are expecting a messageerror due to the window sending us a SAB") {
     22    assert_equals(e.constructor.name, "ExtendableMessageEvent", "type");
     23    assert_equals(e.data, null, "data");
     24    assert_equals(e.origin, self.origin, "origin");
     25    assert_not_equals(e.source, null, "source");
     26    assert_equals(e.ports.length, 0, "ports length");
     27 
     28    state = "onmessageerror was received in worker";
     29    e.source.postMessage(state);
     30  } else {
     31    e.source.postMessage(`worker onmessageerror was reached when in state "${state}" and data ${e.data}`);
     32  }
     33 };