summaryrefslogtreecommitdiffstats
path: root/dom/base/crashtests/eventSource_invalid_scheme_worker_shutdown.html
blob: 731392d83d99e6de7419c5afac83f3f84c258ae8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
<html class="reftest-wait">
    <head>
        <script type="text/javascript">
            const workerURL = "1614339-worker.js";

            const Cc = SpecialPowers.Cc;
            const Ci = SpecialPowers.Ci;
            const wdm = Cc["@mozilla.org/dom/workers/workerdebuggermanager;1"]
                          .getService(Ci.nsIWorkerDebuggerManager);

            function waitForUnregister() {
              return new Promise(function(resolve) {
                wdm.addListener({
                  onUnregister(dbg) {
                    if (dbg.url !== workerURL) {
                      return;
                    }
                    wdm.removeListener(this);
                     resolve();
                  },
                });
              });
            }

            function boom() {
              const worker = new Worker(workerURL);
              waitForUnregister().then(function() {
                document.documentElement.classList.remove("reftest-wait");
              });
              worker.postMessage("Start");
            }
         </script>
     </head>
     <body onload="boom();"></body>
</html>