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

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: Minor cleanups. 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..69f56461627579129304e02217b3aa383b3aa024 100644
--- a/chrome/test/data/push_messaging/service_worker.js
+++ b/chrome/test/data/push_messaging/service_worker.js
@@ -2,6 +2,24 @@
// 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.onmessage = function(event) {
+ console.log(event);
+ console.log(event.data);
+ sendDataToClients('Message from service worker.');
+};
-// TODO(mvanouwerkerk): Add test coverage for push event delivery.
+this.onpush = function(event) {
+ console.log(event);
+ console.log(event.data);
+ sendDataToClients(event.data);
+};
+
+function sendDataToClients(data) {
+ this.clients.getAll().then(function(clients) {
+ clients.forEach(function(client) {
+ client.postMessage(data);
+ });
+ }, function(error) {
+ console.log(error);
+ });
+}

Powered by Google App Engine
This is Rietveld 408576698