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

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

Issue 778243002: Push API: Return cached registration if available. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@store2
Patch Set: Rebase Created 6 years 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 strict'; 5 'use strict';
6 6
7 var pushData = new FutureData(); 7 var pushData = new FutureData();
8 8
9 // Sends data back to the test. This must be in response to an earlier 9 // Sends data back to the test. This must be in response to an earlier
10 // request, but it's ok to respond asynchronously. The request blocks until 10 // request, but it's ok to respond asynchronously. The request blocks until
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 54
55 // Notification permission has been coalesced with Push permission. After 55 // Notification permission has been coalesced with Push permission. After
56 // this is granted, Push API registration can succeed. 56 // this is granted, Push API registration can succeed.
57 function requestNotificationPermission() { 57 function requestNotificationPermission() {
58 Notification.requestPermission(function(permission) { 58 Notification.requestPermission(function(permission) {
59 sendResultToTest('permission status - ' + permission); 59 sendResultToTest('permission status - ' + permission);
60 }); 60 });
61 } 61 }
62 62
63 function registerServiceWorker() { 63 function registerServiceWorker() {
64 // The base dir used to resolve service_worker.js and the scope depends on
65 // whether this script is included from an html file in ./, subscope1/, or
66 // subscope2/.
64 navigator.serviceWorker.register('service_worker.js', {scope: './'}).then( 67 navigator.serviceWorker.register('service_worker.js', {scope: './'}).then(
65 function(swRegistration) { 68 function(swRegistration) {
66 sendResultToTest('ok - service worker registered'); 69 sendResultToTest('ok - service worker registered');
67 }, sendErrorToTest); 70 }, sendErrorToTest);
68 } 71 }
69 72
70 function unregisterServiceWorker() { 73 function unregisterServiceWorker() {
71 navigator.serviceWorker.getRegistration().then(function(swRegistration) { 74 navigator.serviceWorker.getRegistration().then(function(swRegistration) {
72 swRegistration.unregister().then(function(result) { 75 swRegistration.unregister().then(function(result) {
73 sendResultToTest('service worker unregistration status: ' + result); 76 sendResultToTest('service worker unregistration status: ' + result);
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 sendResultToTest('false - is not controlled'); 115 sendResultToTest('false - is not controlled');
113 } 116 }
114 } 117 }
115 118
116 addEventListener('message', function(event) { 119 addEventListener('message', function(event) {
117 var message = JSON.parse(event.data); 120 var message = JSON.parse(event.data);
118 if (message.type == 'push') { 121 if (message.type == 'push') {
119 pushData.set(message.data); 122 pushData.set(message.data);
120 } 123 }
121 }, false); 124 }, false);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698