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

Side by Side Diff: chrome/test/data/push_messaging/service_worker.js

Issue 2511133003: Revert of Handle push resubscribes with no sender info (avoids DCHECK) (Closed)
Patch Set: Created 4 years, 1 month 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 // Use an absolute path since this could be loaded from a different scope, 5 // Use an absolute path since this could be loaded from a different scope,
6 // which would affect the scope of the importScripts call here. 6 // which would affect the scope of the importScripts call here.
7 self.importScripts('/push_messaging/push_constants.js'); 7 self.importScripts('/push_messaging/push_constants.js');
8 8
9 var pushSubscriptionOptions = { 9 var pushSubscriptionOptions = {
10 userVisibleOnly: true 10 userVisibleOnly: true
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 event.waitUntil(result.then(function() { 42 event.waitUntil(result.then(function() {
43 sendMessageToClients('push', data); 43 sendMessageToClients('push', data);
44 }, function(ex) { 44 }, function(ex) {
45 sendMessageToClients('push', String(ex)); 45 sendMessageToClients('push', String(ex));
46 })); 46 }));
47 }; 47 };
48 48
49 self.addEventListener('message', function handler (event) { 49 self.addEventListener('message', function handler (event) {
50 if (event.data.command == 'workerSubscribe') { 50 if (event.data.command == 'workerSubscribe') {
51 pushSubscriptionOptions.applicationServerKey = kApplicationServerKey.buffer; 51 pushSubscriptionOptions.applicationServerKey = kApplicationServerKey.buffer;
52 } else if (event.data.command == 'workerSubscribeWithNumericKey') {
53 pushSubscriptionOptions.applicationServerKey =
54 new TextEncoder().encode('1234567890');
55 } else if (event.data.command == 'workerSubscribeNoKey') { 52 } else if (event.data.command == 'workerSubscribeNoKey') {
56 // Nothing to set up 53 // Nothing to set up
57 } else { 54 } else {
58 sendMessageToClients('message', 'error - unknown message request'); 55 sendMessageToClients('message', 'error - unknown message request');
59 return; 56 return;
60 } 57 }
61 58
62 self.registration.pushManager.subscribe(pushSubscriptionOptions) 59 self.registration.pushManager.subscribe(pushSubscriptionOptions)
63 .then(function(subscription) { 60 .then(function(subscription) {
64 sendMessageToClients('message', subscription.endpoint); 61 sendMessageToClients('message', subscription.endpoint);
(...skipping 12 matching lines...) Expand all
77 'data': data 74 'data': data
78 }); 75 });
79 clients.matchAll().then(function(clients) { 76 clients.matchAll().then(function(clients) {
80 clients.forEach(function(client) { 77 clients.forEach(function(client) {
81 client.postMessage(message); 78 client.postMessage(message);
82 }); 79 });
83 }, function(error) { 80 }, function(error) {
84 console.log(error); 81 console.log(error);
85 }); 82 });
86 } 83 }
OLDNEW
« no previous file with comments | « chrome/test/data/push_messaging/push_test.js ('k') | chrome/test/data/push_messaging/test_no_manifest.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698