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

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: Use generic data requesting class in js. 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) {
Peter Beverloo 2014/10/24 14:54:58 This doesn't seem to be used for anything other th
Michael van Ouwerkerk 2014/10/27 15:14:30 Deleted.
6 console.log(event);
7 console.log(event.data);
8 sendMessageToClients('message', '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);
Peter Beverloo 2014/10/24 14:54:58 nit: are the console.log() calls here necessary fo
Michael van Ouwerkerk 2014/10/27 15:14:30 Deleted.
14 sendMessageToClients('push', event.data);
15 };
16
17 function sendMessageToClients(type, data) {
18 var message = JSON.stringify({
19 'type': type,
20 'data': data
21 });
22 this.clients.getAll().then(function(clients) {
Peter Beverloo 2014/10/24 14:54:58 |this| is a bit odd here -- normally |this| would
Michael van Ouwerkerk 2014/10/27 15:14:30 Done. I think it's perfectly normal for the execut
23 clients.forEach(function(client) {
24 client.postMessage(message);
25 });
26 }, function(error) {
27 console.log(error);
28 });
29 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698