| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 // Use an absolute path since this could be loaded from a different scope, | 5 // Use an absolute path since this could be loaded from a different scope, |
| 6 // which would affect the scope of the importScripts call here. | 6 // which would affect the scope of the importScripts call here. |
| 7 self.importScripts('/push_messaging/push_constants.js'); | 7 self.importScripts('/push_messaging/push_constants.js'); |
| 8 | 8 |
| 9 // Don't wait for clients of old SW to close before activating. |
| 10 self.addEventListener('install', () => skipWaiting()); |
| 11 |
| 9 // The "onpush" event currently understands two values as message payload | 12 // The "onpush" event currently understands two values as message payload |
| 10 // data coming from the test. Any other input is passed through to the | 13 // data coming from the test. Any other input is passed through to the |
| 11 // document unchanged. | 14 // document unchanged. |
| 12 // | 15 // |
| 13 // "shownotification" - Display a Web Notification with event.waitUntil(). | 16 // "shownotification" - Display a Web Notification with event.waitUntil(). |
| 14 // "shownotification-without-waituntil" | 17 // "shownotification-without-waituntil" |
| 15 // - Display a Web Notification without using event.waitUntil(). | 18 // - Display a Web Notification without using event.waitUntil(). |
| 16 this.onpush = function(event) { | 19 this.onpush = function(event) { |
| 17 if (event.data === null) { | 20 if (event.data === null) { |
| 18 sendMessageToClients('push', '[NULL]'); | 21 sendMessageToClients('push', '[NULL]'); |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 'data': data | 76 'data': data |
| 74 }); | 77 }); |
| 75 clients.matchAll().then(function(clients) { | 78 clients.matchAll().then(function(clients) { |
| 76 clients.forEach(function(client) { | 79 clients.forEach(function(client) { |
| 77 client.postMessage(message); | 80 client.postMessage(message); |
| 78 }); | 81 }); |
| 79 }, function(error) { | 82 }, function(error) { |
| 80 console.log(error); | 83 console.log(error); |
| 81 }); | 84 }); |
| 82 } | 85 } |
| OLD | NEW |