summaryrefslogtreecommitdiffstats
path: root/dom/workers/test/serviceworkers/close_test.js
blob: 6138d6421e6d68e73496877e48bce4214ddc20a3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
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 (e) {
        ok(e.name === "InvalidAccessError", "close() should throw InvalidAccessError");
      }
      client.postMessage({status: "done"});
    });
  }
}