diff options
Diffstat (limited to 'dom/workers/test/serviceworkers/worker_updatefoundevent.js')
-rw-r--r-- | dom/workers/test/serviceworkers/worker_updatefoundevent.js | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/dom/workers/test/serviceworkers/worker_updatefoundevent.js b/dom/workers/test/serviceworkers/worker_updatefoundevent.js new file mode 100644 index 000000000..a297bf455 --- /dev/null +++ b/dom/workers/test/serviceworkers/worker_updatefoundevent.js @@ -0,0 +1,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); + } + })); +} |