Index: chrome/test/data/push_messaging/service_worker.js |
diff --git a/chrome/test/data/push_messaging/service_worker.js b/chrome/test/data/push_messaging/service_worker.js |
index 116b355671ff082a20266841e8ebf2d2a6726a1a..26021215d5d6e029275e70b958064df2208e7182 100644 |
--- a/chrome/test/data/push_messaging/service_worker.js |
+++ b/chrome/test/data/push_messaging/service_worker.js |
@@ -2,6 +2,20 @@ |
// Use of this source code is governed by a BSD-style license that can be |
// found in the LICENSE file. |
-// Empty service worker script. |
+this.onpush = function(event) { |
+ sendMessageToClients('push', event.data); |
+}; |
-// TODO(mvanouwerkerk): Add test coverage for push event delivery. |
+function sendMessageToClients(type, data) { |
+ var message = JSON.stringify({ |
+ 'type': type, |
+ 'data': data |
+ }); |
+ clients.getAll().then(function(clients) { |
+ clients.forEach(function(client) { |
+ client.postMessage(message); |
+ }); |
+ }, function(error) { |
+ console.log(error); |
+ }); |
+} |