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

Side by Side 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 unified diff | Download patch
OLDNEW
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 // Empty service worker script. 5 this.onmessage = function(event) {
6 console.log(event);
7 console.log(event.data);
8 sendDataToClients('Message from service worker.');
9 };
6 10
7 // TODO(mvanouwerkerk): Add test coverage for push event delivery. 11 this.onpush = function(event) {
12 console.log(event);
13 console.log(event.data);
14 sendDataToClients(event.data);
15 };
16
17 function sendDataToClients(data) {
18 this.clients.getAll().then(function(clients) {
19 clients.forEach(function(client) {
20 client.postMessage(data);
21 });
22 }, function(error) {
23 console.log(error);
24 });
25 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698