Bug 1885602 - Part 2: Add a MozillaAccountMenuButton composable for the menu redesign...
[gecko.git] / dom / xhr / tests / test_bug1752863_worker.js
blob929b0059394a571a09cb4b85ab696a95c80a8ac3
1 var xhr;
2 var myself;
4 async function handleLoadstart() {
5   try {
6     xhr.open("POST", "FOOBAR", false);
7     // This will potentially queue another "loadstart" event
8     // before we can catch (err). But the order should be
9     // guaranteed, that is the first postMessage arriving at
10     // our parent is from the first catch (err).
11     xhr.send();
12     myself.postMessage("MissingError");
13   } catch (err) {
14     if (err instanceof DOMException) {
15       // This is what we expect to happen on the first error
16       // and the parent will check for this to arrive.
17       myself.postMessage("DOMException");
18     } else {
19       myself.postMessage("OtherError");
20     }
21     // Let's ensure we still bail out from the processing.
22     xhr.removeEventListener("loadstart", handleLoadstart, true);
23     throw err;
24   }
27 self.onmessage = async function () {
28   xhr = new XMLHttpRequest({ mozAnon: false });
29   myself = self;
30   xhr.addEventListener("loadstart", handleLoadstart, true);
31   xhr.open("POST", "FOOBAR", false);
32   xhr.send();
33   postMessage("TERMINATE");