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 // The "onpush" event currently understands two values as message payload | 5 // The "onpush" event currently understands two values as message payload |
6 // data coming from the test. Any other input is passed through to the | 6 // data coming from the test. Any other input is passed through to the |
7 // document unchanged. | 7 // document unchanged. |
8 // | 8 // |
9 // "shownotification" - Display a Web Notification with event.waitUntil(). | 9 // "shownotification" - Display a Web Notification with event.waitUntil(). |
10 // "shownotification-without-waituntil" | 10 // "shownotification-without-waituntil" |
(...skipping 20 matching lines...) Expand all Loading... |
31 }, function(ex) { | 31 }, function(ex) { |
32 sendMessageToClients('push', String(ex)); | 32 sendMessageToClients('push', String(ex)); |
33 })); | 33 })); |
34 }; | 34 }; |
35 | 35 |
36 function sendMessageToClients(type, data) { | 36 function sendMessageToClients(type, data) { |
37 var message = JSON.stringify({ | 37 var message = JSON.stringify({ |
38 'type': type, | 38 'type': type, |
39 'data': data | 39 'data': data |
40 }); | 40 }); |
41 clients.getAll().then(function(clients) { | 41 clients.matchAll().then(function(clients) { |
42 clients.forEach(function(client) { | 42 clients.forEach(function(client) { |
43 client.postMessage(message); | 43 client.postMessage(message); |
44 }); | 44 }); |
45 }, function(error) { | 45 }, function(error) { |
46 console.log(error); | 46 console.log(error); |
47 }); | 47 }); |
48 } | 48 } |
OLD | NEW |