summaryrefslogtreecommitdiffstats
path: root/dom/workers/test/serviceworkers/worker_updatefoundevent.js
blob: a297bf455674c4c34cffc7cbb8b1a7a23016a583 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
/**
 * Any copyright is dedicated to the Public Domain.
 * http://creativecommons.org/publicdomain/zero/1.0/
 */

onactivate = function(e) {
  e.waitUntil(new Promise(function(resolve, reject) {
    registration.onupdatefound = function(e) {
      clients.matchAll().then(function(clients) {
        if (!clients.length) {
          reject("No clients found");
        }

        if (registration.scope.match(/updatefoundevent\.html$/)) {
          clients[0].postMessage("finish");
          resolve();
        } else {
          dump("Scope did not match");
        }
      }, reject);
    }
  }));
}