Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 <!DOCTYPE html> | |
| 2 <html> | |
| 3 <head> | |
| 4 <title>Subscribing should provide a Curve25519 ECDH public key.</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="../resources/testharness-helpers.js"></script> | |
| 9 <script src="../serviceworker/resources/test-helpers.js"></script> | |
| 10 </head> | |
| 11 <body> | |
| 12 <script> | |
| 13 // When running this test manually, grant permission when prompted. | |
| 14 // This test verifies that push subscriptions get an ECDH Curve25519 | |
| 15 // key that can be used on the application server to encrypt payload s. | |
| 16 async_test(function(test) { | |
| 17 var workerUrl = 'resources/empty_worker.js'; | |
| 18 var workerScope = 'resources/scope/' + location.pathname; | |
| 19 var swRegistration, encryptionKey; | |
| 20 | |
| 21 // Size of an ECDH curve25519 public key, in bytes. | |
| 22 var EXPECTED_KEY_LENGTH = 32; | |
| 23 | |
| 24 service_worker_unregister_and_register(test, workerUrl, workerSc ope) | |
| 25 .then(function(serviceWorkerRegistration) { | |
| 26 swRegistration = serviceWorkerRegistration; | |
| 27 return wait_for_state(test, swRegistration.installing, ' activated'); | |
| 28 }) | |
| 29 .then(function() { | |
| 30 if (window.testRunner) | |
| 31 testRunner.setPermission('push-messaging', 'granted' , location.origin, location.origin); | |
| 32 | |
| 33 return swRegistration.pushManager.subscribe(); | |
| 34 }) | |
| 35 .then(function(pushSubscription) { | |
| 36 assert_idl_attribute(pushSubscription, 'curve25519dh'); | |
| 37 assert_equals(pushSubscription.curve25519dh, pushSubscri ption.curve25519dh); | |
| 38 assert_readonly(pushSubscription, 'curve25519dh'); | |
| 39 | |
| 40 encryptionKey = pushSubscription.curve25519dh; | |
| 41 assert_equals(encryptionKey.byteLength, EXPECTED_KEY_LEN GTH); | |
| 42 | |
| 43 return swRegistration.pushManager.getSubscription(); | |
| 44 }) | |
| 45 .then(function(pushSubscription) { | |
| 46 assert_equals(pushSubscription.curve25519dh.byteLength, | |
|
johnme
2015/07/14 16:49:50
Seems you might as well add whichever of assert_eq
Peter Beverloo
2015/07/14 17:06:05
The contents of the ArrayBuffer will be identical,
| |
| 47 encryptionKey.byteLength); | |
| 48 | |
| 49 return service_worker_unregister_and_done(test, workerSc ope); | |
|
johnme
2015/07/14 16:49:50
Please also test that after unsubscribing and re-s
Peter Beverloo
2015/07/14 17:06:05
This is the value returned by the LayoutTestPushMe
| |
| 50 }) | |
| 51 .catch(unreached_rejection(test)); | |
| 52 | |
| 53 }, 'Subscribing should provide a Curve25519 ECDH public key'); | |
| 54 </script> | |
| 55 </body> | |
| 56 </html> | |
| OLD | NEW |