Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 <!DOCTYPE html> | |
| 2 <html> | |
|
harkness
2016/10/25 10:11:22
FYI: In the future we're going to move to an inden
awdf
2016/10/25 13:18:18
Acknowledged.
| |
| 3 <head> | |
| 4 <title>subscribe() is rejected when called with a different sender id</title> | |
| 5 <link rel="manifest" href="resources/push_manifest.json"> | |
| 6 <script src="../resources/testharness.js"></script> | |
| 7 <script src="../resources/testharnessreport.js"></script> | |
| 8 <script src="../serviceworker/resources/test-helpers.js"></script> | |
| 9 </head> | |
| 10 <body> | |
| 11 <script> | |
| 12 async_test(function(test) { | |
| 13 var workerUrl = 'resources/instrumentation-service-worker.js'; | |
| 14 var workerScope = 'resources/scope/' + location.pathname; | |
| 15 var swRegistration; | |
| 16 const FIRST_SENDER_ID_OPTIONS = { | |
| 17 userVisibleOnly: true, | |
| 18 // This is equal to the gcm_sender_id in push_manifest.json | |
|
harkness
2016/10/25 10:11:22
Since you're setting the applicationServerKey, you
awdf
2016/10/25 13:18:18
Good spot. (I copied another test and didn't notic
| |
| 19 applicationServerKey: new TextEncoder().encode('1234567890') | |
| 20 }; | |
| 21 const SECOND_SENDER_ID_OPTIONS = { | |
| 22 userVisibleOnly: true, | |
| 23 applicationServerKey: new TextEncoder().encode('0987654321') | |
| 24 }; | |
| 25 service_worker_unregister_and_register(test, workerUrl, workerScope) | |
| 26 .then(function(serviceWorkerRegistration) { | |
| 27 swRegistration = serviceWorkerRegistration; | |
| 28 return wait_for_state(test, swRegistration.installing, 'activated'); | |
| 29 }) | |
| 30 .then(function() { | |
| 31 // If running manually, grant permission when prompted. | |
| 32 if (window.testRunner) | |
| 33 testRunner.setPermission( | |
| 34 'push-messaging', 'granted', location.origin, location.origi n); | |
|
harkness
2016/10/25 10:11:22
We are trying to convert to 80 column width, if yo
awdf
2016/10/25 13:18:18
Done.
| |
| 35 return swRegistration.pushManager.subscribe(FIRST_SENDER_ID_OPTIONS) ; | |
| 36 }) | |
| 37 .then(function(pushSubscription) { | |
| 38 return swRegistration.pushManager.subscribe(SECOND_SENDER_ID_OPTIONS ); | |
| 39 }) | |
| 40 .then(function(pushSubscription) { | |
| 41 assert_unreached('Second subscribe() must not succeed with different sender ID'); | |
| 42 }, function(e) { | |
| 43 assert_equals(e.name, 'InvalidStateError'); | |
| 44 assert_equals(e.message, | |
| 45 'Registration failed - A subscription with a different sender ID already exists'); | |
| 46 return service_worker_unregister_and_done(test, workerScope); | |
| 47 }) | |
| 48 .catch(unreached_rejection(test)); | |
| 49 }, 'subscribe() is rejected when a subscription with a different sender ID alrea dy exists'); | |
| 50 </script> | |
| 51 </body> | |
| 52 </html> | |
| OLD | NEW |