tor-browser

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

websocket_sharedWorker.js (738B)


      1 /* global onconnect:true */
      2 onconnect = function (evt) {
      3  var ws = new WebSocket(
      4    "ws://mochi.test:8888/tests/dom/websocket/tests/file_websocket_hello"
      5  );
      6 
      7  ws.onopen = function () {
      8    evt.ports[0].postMessage({
      9      type: "status",
     10      status: true,
     11      msg: "OnOpen called",
     12    });
     13    ws.send("data");
     14  };
     15 
     16  ws.onclose = function () {};
     17 
     18  ws.onerror = function () {
     19    evt.ports[0].postMessage({
     20      type: "status",
     21      status: false,
     22      msg: "onerror called!",
     23    });
     24  };
     25 
     26  ws.onmessage = function (e) {
     27    evt.ports[0].postMessage({
     28      type: "status",
     29      status: e.data == "Hello world!",
     30      msg: "Wrong data",
     31    });
     32    ws.close();
     33    evt.ports[0].postMessage({ type: "finish" });
     34  };
     35 };