OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <html> | 2 <html> |
3 <head> | 3 <head> |
4 <title>subscribe succeeds when permission is granted and resolves with a valid s
ubscription</title> | 4 <title>subscribe succeeds when permission is granted and resolves with a valid s
ubscription</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 </head> | 10 </head> |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 // details were stored previously. | 43 // details were stored previously. |
44 port.postMessage({command: 'subscribe'}); | 44 port.postMessage({command: 'subscribe'}); |
45 | 45 |
46 port.addEventListener('message', function(event) { | 46 port.addEventListener('message', function(event) { |
47 if (typeof event.data != 'object' || !event.data.command) | 47 if (typeof event.data != 'object' || !event.data.command) |
48 assert_unreached('Invalid message from the service worker'); | 48 assert_unreached('Invalid message from the service worker'); |
49 | 49 |
50 assert_equals(event.data.command, 'subscribe'); | 50 assert_equals(event.data.command, 'subscribe'); |
51 assert_true(event.data.success, | 51 assert_true(event.data.success, |
52 'subscribe should succeed. Error message: ' + event.
data.errorMessage); | 52 'subscribe should succeed. Error message: ' + event.
data.errorMessage); |
53 assert_equals(typeof event.data.subscriptionId, 'string'); | |
54 assert_equals(typeof event.data.endpoint, 'string'); | 53 assert_equals(typeof event.data.endpoint, 'string'); |
55 try { | 54 try { |
56 var endpointUrl = new URL(event.data.endpoint); | 55 var endpointUrl = new URL(event.data.endpoint); |
57 } catch(e) { | 56 } catch(e) { |
58 assert_unreached('Constructing a URL from the endpoint should
not throw.'); | 57 assert_unreached('Constructing a URL from the endpoint should
not throw.'); |
59 } | 58 } |
60 | 59 |
61 test.done(); | 60 test.done(); |
62 }); | 61 }); |
63 }) | 62 }) |
64 .catch(unreached_rejection(test)); | 63 .catch(unreached_rejection(test)); |
65 }, 'subscribe succeeds when permission is granted and resolves with a valid subs
cription'); | 64 }, 'subscribe succeeds when permission is granted and resolves with a valid subs
cription'); |
66 </script> | 65 </script> |
67 </body> | 66 </body> |
68 </html> | 67 </html> |
OLD | NEW |