summaryrefslogtreecommitdiffstats
path: root/dom/serviceworkers/test/close_test.js
blob: 0609782e5efdf65e63d85f0d995c2ae5d0246362 (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
/* eslint-disable mozilla/no-comparison-or-assignment-inside-ok */

function ok(v, msg) {
  client.postMessage({ status: "ok", result: !!v, message: msg });
}

var client;
onmessage = function (e) {
  if (e.data.message == "start") {
    self.clients.matchAll().then(function (clients) {
      client = clients[0];
      try {
        close();
        ok(false, "close() should throw");
      } catch (ex) {
        ok(
          ex.name === "InvalidAccessError",
          "close() should throw InvalidAccessError"
        );
      }
      client.postMessage({ status: "done" });
    });
  }
};