| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // Don't wait for clients of old SW to close before activating. |
| 6 self.addEventListener('install', () => skipWaiting()); |
| 7 |
| 5 // Accept messages from the test JavaScript to trigger worker based tests. | 8 // Accept messages from the test JavaScript to trigger worker based tests. |
| 6 self.addEventListener('message', function (event) { | 9 self.addEventListener('message', function (event) { |
| 7 if (event.data.command == 'workerGet') { | 10 if (event.data.command == 'workerGet') { |
| 8 workerGetBudget(); | 11 workerGetBudget(); |
| 9 } else if (event.data.command == 'workerReserve') { | 12 } else if (event.data.command == 'workerReserve') { |
| 10 workerReserve(); | 13 workerReserve(); |
| 11 } else { | 14 } else { |
| 12 sendMessageToClients('message', 'error - unknown message request'); | 15 sendMessageToClients('message', 'error - unknown message request'); |
| 13 return; | 16 return; |
| 14 } | 17 } |
| (...skipping 28 matching lines...) Expand all Loading... |
| 43 'data': data | 46 'data': data |
| 44 }); | 47 }); |
| 45 clients.matchAll().then(function(clients) { | 48 clients.matchAll().then(function(clients) { |
| 46 clients.forEach(function(client) { | 49 clients.forEach(function(client) { |
| 47 client.postMessage(message); | 50 client.postMessage(message); |
| 48 }); | 51 }); |
| 49 }, function(error) { | 52 }, function(error) { |
| 50 console.log(error); | 53 console.log(error); |
| 51 }); | 54 }); |
| 52 } | 55 } |
| OLD | NEW |