Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5136)

Unified Diff: chrome/test/data/push_messaging/service_worker.js

Issue 673783003: BrowserTest for delivering push message to service worker. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@PushIntegrationTest2
Patch Set: Break long line. Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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);
+ });
+}
« no previous file with comments | « chrome/browser/services/gcm/push_messaging_browsertest.cc ('k') | chrome/test/data/push_messaging/test.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698