summaryrefslogtreecommitdiffstats
path: root/dom/xhr/tests/worker_bug1697539.js
blob: faef1f1614e771df0455d46fb4f39cedd803c75f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
onmessage = function (e) {
  let xhr = new XMLHttpRequest();
  let already_sent = false;
  xhr.addEventListener("readystatechange", event => {
    try {
      event.originalTarget.send("test");
    } catch (error) {
      if (error.name == "InvalidStateError") {
        if (!already_sent) {
          postMessage(error.name);
          already_sent = true;
        }
      }
    }
  });

  xhr.open("POST", e.data, false);
  xhr.send();
};