summaryrefslogtreecommitdiffstats
path: root/dom/workers/test/serviceworkers/claim_worker_1.js
diff options
context:
space:
mode:
Diffstat (limited to 'dom/workers/test/serviceworkers/claim_worker_1.js')
-rw-r--r--dom/workers/test/serviceworkers/claim_worker_1.js28
1 files changed, 28 insertions, 0 deletions
diff --git a/dom/workers/test/serviceworkers/claim_worker_1.js b/dom/workers/test/serviceworkers/claim_worker_1.js
new file mode 100644
index 000000000..e5f6392d3
--- /dev/null
+++ b/dom/workers/test/serviceworkers/claim_worker_1.js
@@ -0,0 +1,28 @@
+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() {
+ var claimPromise = self.clients.claim().then(function(ret) {
+ result.resolve_value = ret;
+ });
+
+ return claimPromise.then(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");
+ }
+ }));
+ });
+}