Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 <!DOCTYPE html> | |
| 2 <html> | |
| 3 <head> | |
| 4 <title>Subscribing with applicationServerKey should succeed only when th e applicationServerKey is valid.</title> | |
| 5 <script src="resources/push-constants.js"></script> | |
| 6 <script src="resources/test-helpers.js"></script> | |
| 7 <script src="../resources/testharness.js"></script> | |
| 8 <script src="../resources/testharnessreport.js"></script> | |
| 9 <script src="../resources/testharness-helpers.js"></script> | |
| 10 <script src="../serviceworker/resources/test-helpers.js"></script> | |
| 11 </head> | |
| 12 <body> | |
| 13 <script> | |
| 14 // Subscribe should succeed given a valid numeric sender ID. | |
| 15 promise_test(function(test) { | |
| 16 return registerAndSubscribePushWithString(test, '0123456789') | |
| 17 .then(function(pushSubscription) { | |
| 18 assert_true( | |
| 19 pushSubscription.endpoint.includes('LayoutTestEndpoint')); | |
| 20 }); | |
| 21 }, 'Subscribing with a valid numeric sender ID should succeed'); | |
| 22 | |
| 23 // Subscribe should succeed given a valid p256 key. | |
| 24 promise_test(function(test) { | |
| 25 return registerAndSubscribePush(test, new Uint8Array(PUBLIC_KEY)) | |
| 26 .then(function(pushSubscription) { | |
| 27 assert_true( | |
| 28 pushSubscription.endpoint.includes('StandardizedEndpoint') ); | |
| 29 }); | |
| 30 }, 'Subscribing with a valid p256 applicationServerKey should succee d'); | |
| 31 | |
| 32 // Subscribe should fail given a non-numeric sender ID. | |
| 33 promise_test(function(test) { | |
| 34 return registerAndSubscribePushWithString(test, '01234a56789') | |
| 35 .then(function(pushSubscription) { | |
| 36 assert_unreached('Subscribe should have failed.'); | |
| 37 }) | |
| 38 .catch (function(e) { | |
| 39 assert_regexp_match( | |
| 40 e.message, /The provided applicationServerKey is not valid./ ); | |
|
Peter Beverloo
2016/10/14 14:36:30
Why don't you use includes() like you use on line
harkness
2016/10/14 15:13:46
Done.
| |
| 41 }); | |
| 42 }, 'Subscribing with a non-numeric sender ID should fail'); | |
| 43 | |
| 44 // Subscribe should fail given an empty applicationServerKey. | |
| 45 promise_test(function(test) { | |
| 46 return registerAndSubscribePushWithString(test, '') | |
| 47 .then(function(pushSubscription) { | |
| 48 assert_unreached('Subscribe should have failed.'); | |
| 49 }) | |
| 50 .catch (function(e) { | |
| 51 assert_regexp_match( | |
| 52 e.message, /The provided applicationServerKey is not valid./ ); | |
| 53 }); | |
| 54 }, 'Subscribing with an empty applicationServerKey should fail'); | |
| 55 | |
| 56 // Subscribe should fail given a too long applicationServerKey. | |
| 57 promise_test(function(test) { | |
| 58 const longKey = new Uint8Array(300); | |
| 59 return registerAndSubscribePush(test, longKey) | |
| 60 .then(function(pushSubscription) { | |
| 61 assert_unreached('Subscribe should have failed.'); | |
| 62 }) | |
| 63 .catch (function(e) { | |
| 64 assert_regexp_match( | |
| 65 e.message, /The provided applicationServerKey is not valid./ ); | |
| 66 }); | |
| 67 }, 'Subscribing with a too long applicationServerKey should fail'); | |
| 68 </script> | |
| 69 </body> | |
| 70 </html> | |
| OLD | NEW |