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

Side by Side Diff: LayoutTests/http/tests/push_messaging/get_subscription.html

Issue 841333002: Push API: rename registration to subscription. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Use https in the spec link. Created 5 years, 11 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 | Annotate | Revision Log
OLDNEW
1 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <html> 2 <html>
3 <head> 3 <head>
4 <title>Test PushManager.getRegistration()</title> 4 <title>Test PushManager.getSubscription()</title>
5 <link rel="manifest" href="resources/push_manifest.json"> 5 <link rel="manifest" href="resources/push_manifest.json">
6 <script src="../resources/testharness.js"></script> 6 <script src="../resources/testharness.js"></script>
7 <script src="../resources/testharnessreport.js"></script> 7 <script src="../resources/testharnessreport.js"></script>
8 <script src="../serviceworker/resources/test-helpers.js"></script> 8 <script src="../serviceworker/resources/test-helpers.js"></script>
9 </head> 9 </head>
10 <body> 10 <body>
11 <script> 11 <script>
12 async_test(function(test) { 12 async_test(function(test) {
13 var workerUrl = 'resources/empty_worker.js'; 13 var workerUrl = 'resources/empty_worker.js';
14 var workerScope = 'resources/scope/' + location.pathname; 14 var workerScope = 'resources/scope/' + location.pathname;
15 var swRegistration = null; 15 var swRegistration = null;
16 service_worker_unregister_and_register(test, workerUrl, workerScope) 16 service_worker_unregister_and_register(test, workerUrl, workerScope)
17 .then(function(serviceWorkerRegistration) { 17 .then(function(serviceWorkerRegistration) {
18 swRegistration = serviceWorkerRegistration; 18 swRegistration = serviceWorkerRegistration;
19 return wait_for_state(test, swRegistration.installing, 'activated'); 19 return wait_for_state(test, swRegistration.installing, 'activated');
20 }) 20 })
21 .then(function() { 21 .then(function() {
22 // If running manually, grant permission when prompted. 22 // If running manually, grant permission when prompted.
23 if (self.testRunner) 23 if (self.testRunner)
24 testRunner.setPushMessagingPermission(location.origin, true); 24 testRunner.setPushMessagingPermission(location.origin, true);
25 25
26 assert_inherits(swRegistration.pushManager, 'getRegistration', 26 assert_inherits(swRegistration.pushManager, 'getSubscription',
27 'getRegistration() should be exposed on the PushMana ger object'); 27 'getSubscription() should be exposed on the PushMana ger object');
28 assert_equals(typeof(swRegistration.pushManager.getRegistration), 'f unction', 28 assert_equals(typeof(swRegistration.pushManager.getSubscription), 'f unction',
29 'PushManager.getRegistration() is a function.'); 29 'PushManager.getSubscription() is a function.');
30 30
31 return swRegistration.pushManager.getRegistration(); 31 return swRegistration.pushManager.getSubscription();
32 }) 32 })
33 .then(function(pushRegistration) { 33 .then(function(pushSubscription) {
34 assert_equals(pushRegistration, null, 34 assert_equals(pushSubscription, null,
35 "pushRegistration should be null if there is no active push registration.") 35 "pushSubscription should be null if there is no active push registration.")
36 return swRegistration.pushManager.register(); 36 return swRegistration.pushManager.subscribe();
37 }) 37 })
38 .then(function(pushRegistration) { 38 .then(function(pushSubscription) {
39 previousPushRegistration = pushRegistration; 39 previousPushSubscription = pushSubscription;
40 return swRegistration.pushManager.getRegistration(); 40 return swRegistration.pushManager.getSubscription();
41 }) 41 })
42 .then(function(pushRegistration) { 42 .then(function(pushSubscription) {
43 assert_equals(previousPushRegistration.endPoint, pushRegistration.en dPoint, 43 assert_equals(previousPushSubscription.endPoint, pushSubscription.en dPoint,
44 "Both registration objects should have the same endpoi nt."); 44 "Both subscription objects should have the same endpoi nt.");
45 assert_equals(previousPushRegistration.registrationId, pushRegistrat ion.registrationId, 45 assert_equals(previousPushSubscription.subscriptionId, pushSubscript ion.subscriptionId,
46 "Both registration objects should have the same regist ration id."); 46 "Both subscription objects should have the same id.");
47 return pushRegistration.unregister(); 47 return pushSubscription.unsubscribe();
48 }) 48 })
49 .then(function(unregistered) { 49 .then(function(unsubscribed) {
50 assert_true(unregistered, "unregistration was successful"); 50 assert_true(unsubscribed, "unsubscription was successful");
51 return swRegistration.pushManager.getRegistration(); 51 return swRegistration.pushManager.getSubscription();
52 }) 52 })
53 .then(function(pushRegistration) { 53 .then(function(pushSubscription) {
54 assert_equals(pushRegistration, null, 54 assert_equals(pushSubscription, null,
55 "pushRegistration should be null after unregistering." ) 55 "pushSubscription should be null after unsubscribing." )
56 return swRegistration.pushManager.register(); 56 return swRegistration.pushManager.subscribe();
57 }) 57 })
58 .then(function(pushRegistration) { 58 .then(function(pushSubscription) {
59 assert_not_equals(pushRegistration, null, 59 assert_not_equals(pushSubscription, null,
60 "Registration should have succeeded."); 60 "Subscription should have succeeded.");
61 return service_worker_unregister(test, workerScope); 61 return service_worker_unregister(test, workerScope);
62 }) 62 })
63 .then(function() { 63 .then(function() {
64 return swRegistration.pushManager.getRegistration(); 64 return swRegistration.pushManager.getSubscription();
65 }) 65 })
66 .then(function(pushRegistration) { 66 .then(function(pushSubscription) {
67 assert_equals(pushRegistration, null, 67 assert_equals(pushSubscription, null,
68 "After unregistration from SW, there should be no regi stration."); 68 "After unregistration of SW, there should be no push s ubscription.");
69 return service_worker_unregister_and_done(test, workerScope); 69 return service_worker_unregister_and_done(test, workerScope);
70 }) 70 })
71 .catch(unreached_rejection(test)); 71 .catch(unreached_rejection(test));
72 }); 72 });
73 </script> 73 </script>
74 </body> 74 </body>
75 </html> 75 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698