summaryrefslogtreecommitdiffstats
path: root/dom/serviceworkers/test/claim_worker_1.js
diff options
context:
space:
mode:
Diffstat (limited to 'dom/serviceworkers/test/claim_worker_1.js')
-rw-r--r--dom/serviceworkers/test/claim_worker_1.js32
1 files changed, 32 insertions, 0 deletions
diff --git a/dom/serviceworkers/test/claim_worker_1.js b/dom/serviceworkers/test/claim_worker_1.js
new file mode 100644
index 0000000000..60ba5dfc5d
--- /dev/null
+++ b/dom/serviceworkers/test/claim_worker_1.js
@@ -0,0 +1,32 @@
+onactivate = function (e) {
+ var result = {
+ resolve_value: false,
+ match_count_before: -1,
+ match_count_after: -1,
+ message: "claim_worker_1",
+ };
+
+ self.clients
+ .matchAll()
+ .then(function (matched) {
+ // should be 0
+ result.match_count_before = matched.length;
+ })
+ .then(function () {
+ return self.clients.claim();
+ })
+ .then(function (ret) {
+ result.resolve_value = ret;
+ return self.clients.matchAll();
+ })
+ .then(function (matched) {
+ // should be 2
+ result.match_count_after = matched.length;
+ for (i = 0; i < matched.length; i++) {
+ matched[i].postMessage(result);
+ }
+ if (result.match_count_after !== 2) {
+ dump("ERROR: claim_worker_1 failed to capture clients.\n");
+ }
+ });
+};