claim_worker_2.js (885B)
1 onactivate = function (e) { 2 var result = { 3 resolve_value: false, 4 match_count_before: -1, 5 match_count_after: -1, 6 message: "claim_worker_2", 7 }; 8 9 self.clients 10 .matchAll() 11 .then(function (matched) { 12 // should be 0 13 result.match_count_before = matched.length; 14 }) 15 .then(function () { 16 return clients.claim(); 17 }) 18 .then(function (ret) { 19 result.resolve_value = ret; 20 return clients.matchAll(); 21 }) 22 .then(function (matched) { 23 // should be 1 24 result.match_count_after = matched.length; 25 if (result.match_count_after === 1) { 26 matched[0].postMessage(result); 27 } else { 28 dump("ERROR: claim_worker_2 failed to capture clients.\n"); 29 for (let i = 0; i < matched.length; ++i) { 30 dump("### ### matched[" + i + "]: " + matched[i].url + "\n"); 31 } 32 } 33 }); 34 };