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

Side by Side Diff: LayoutTests/http/tests/push_messaging/get-subscription-in-service-worker.html

Issue 1148763005: Remove support for PushSubscription.subscriptionId. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 6 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>getSubscription must return the details of the active subscription if the re is one</title> 4 <title>getSubscription must return the details of the active subscription if the re is one</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 <script src="../notifications/resources/test-helpers.js"></script> 9 <script src="../notifications/resources/test-helpers.js"></script>
10 <script src="resources/test-helpers.js"></script> 10 <script src="resources/test-helpers.js"></script>
11 </head> 11 </head>
12 <body> 12 <body>
13 <script> 13 <script>
14 // This test uses the test runner. If running manually, grant permission when pr ompted. 14 // This test uses the test runner. If running manually, grant permission when pr ompted.
15 async_test(function(test) { 15 async_test(function(test) {
16 if (window.testRunner) 16 if (window.testRunner)
17 testRunner.setPermission('push-messaging', 'granted', location.origin, locat ion.origin); 17 testRunner.setPermission('push-messaging', 'granted', location.origin, locat ion.origin);
18 18
19 var script = 'resources/instrumentation-service-worker.js'; 19 var script = 'resources/instrumentation-service-worker.js';
20 var scope = 'resources/scope/' + location.pathname; 20 var scope = 'resources/scope/' + location.pathname;
21 var port; 21 var port;
22 var registration; 22 var registration;
23 var previousSubscriptionId; 23 var previousEndpoint;
24 24
25 getActiveServiceWorkerWithMessagePort(test, script, scope) 25 getActiveServiceWorkerWithMessagePort(test, script, scope)
26 .then(function(workerInfo) { 26 .then(function(workerInfo) {
27 port = workerInfo.port; 27 port = workerInfo.port;
28 registration = workerInfo.registration; 28 registration = workerInfo.registration;
29 return subscribeAndUnsubscribePush(registration); 29 return subscribeAndUnsubscribePush(registration);
30 }) 30 })
31 .then(function() { 31 .then(function() {
32 return runCommandInServiceWorker(port, 'getSubscription'); 32 return runCommandInServiceWorker(port, 'getSubscription');
33 }) 33 })
34 .then(function(data) { 34 .then(function(data) {
35 assert_equals(data.subscriptionId, null, 35 assert_equals(data.endpoint, null,
36 'There must be no subscription after unsubscribing in the document.' ); 36 'There must be no subscription after unsubscribing in the document.' );
37 return runCommandInServiceWorker(port, 'subscribe'); 37 return runCommandInServiceWorker(port, 'subscribe');
38 }) 38 })
39 .then(function(data) { 39 .then(function(data) {
40 previousSubscriptionId = data.subscriptionId; 40 previousEndpoint = data.endpoint;
41 return runCommandInServiceWorker(port, 'getSubscription'); 41 return runCommandInServiceWorker(port, 'getSubscription');
42 }) 42 })
43 .then(function(data) { 43 .then(function(data) {
44 assert_equals(data.subscriptionId, previousSubscriptionId, 44 assert_equals(data.endpoint, previousEndpoint,
45 'Both PushSubscription instances should have the same id.'); 45 'Both PushSubscription instances should have the same endpoint.');
46 return registration.pushManager.getSubscription(); 46 return registration.pushManager.getSubscription();
47 }) 47 })
48 .then(function(subscription) { 48 .then(function(subscription) {
49 assert_equals(subscription.subscriptionId, previousSubscriptionId, 49 assert_equals(subscription.endpoint, previousEndpoint,
50 'The ids for the PushSubscription instances from document and worker must match.'); 50 'The endpoints for the PushSubscription instances from document and worker must match.');
51 return runCommandInServiceWorker(port, 'unsubscribe'); 51 return runCommandInServiceWorker(port, 'unsubscribe');
52 }) 52 })
53 .then(function(data) { 53 .then(function(data) {
54 assert_true(data.unsubscribeResult, 54 assert_true(data.unsubscribeResult,
55 'Calling unsubscribe on an active subscription must resolve with tru e.'); 55 'Calling unsubscribe on an active subscription must resolve with tru e.');
56 return runCommandInServiceWorker(port, 'getSubscription'); 56 return runCommandInServiceWorker(port, 'getSubscription');
57 }) 57 })
58 .then(function(data) { 58 .then(function(data) {
59 assert_equals(data.subscriptionId, null, 59 assert_equals(data.endpoint, null,
60 'There must be no subscription after unsubscribing in the service wo rker.'); 60 'There must be no subscription after unsubscribing in the service wo rker.');
61 return runCommandInServiceWorker(port, 'subscribe'); 61 return runCommandInServiceWorker(port, 'subscribe');
62 }) 62 })
63 .then(function(data) { 63 .then(function(data) {
64 assert_equals(typeof data.subscriptionId, 'string', 64 assert_equals(typeof data.endpoint, 'string', 'Subscribing again should succeed.');
65 'Subscribing again should succeed.');
66 return registration.unregister(); 65 return registration.unregister();
67 }) 66 })
68 .then(function(unregisterResult) { 67 .then(function(unregisterResult) {
69 assert_true(unregisterResult, 68 assert_true(unregisterResult,
70 'Calling unregister on an active registration must resolve with true .'); 69 'Calling unregister on an active registration must resolve with true .');
71 return registration.pushManager.getSubscription(); 70 return registration.pushManager.getSubscription();
72 }) 71 })
73 .then(function(subscription) { 72 .then(function(subscription) {
74 assert_equals(subscription, null, 73 assert_equals(subscription, null,
75 'Unregistering the service worker should clear the push subscription .'); 74 'Unregistering the service worker should clear the push subscription .');
76 test.done(); 75 test.done();
77 }) 76 })
78 .catch(unreached_rejection(test)); 77 .catch(unreached_rejection(test));
79 }, 'getSubscription must return the details of the active subscription if there is one'); 78 }, 'getSubscription must return the details of the active subscription if there is one');
80 </script> 79 </script>
81 </body> 80 </body>
82 </html> 81 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698