summaryrefslogtreecommitdiffstats
path: root/dom/serviceworkers/test/match_all_properties_worker.js
blob: 84156c93e036f85dc82b0bb9af4f69daaafa88e4 (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
onfetch = function(e) {
  if (/\/clientId$/.test(e.request.url)) {
    e.respondWith(new Response(e.clientId));
    return;
  }
};

onmessage = function(e) {
  dump("MatchAllPropertiesWorker:" + e.data + "\n");
  self.clients.matchAll().then(function(res) {
    if (!res.length) {
      dump("ERROR: no clients are currently controlled.\n");
    }

    for (i = 0; i < res.length; i++) {
      client = res[i];
      response = {
        type: client.type,
        id: client.id,
        url: client.url,
        visibilityState: client.visibilityState,
        focused: client.focused,
        frameType: client.frameType,
      };
      client.postMessage(response);
    }
  });
};