| OLD | NEW |
| 1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
| 2 <html> | 2 <html> |
| 3 <head> | 3 <head> |
| 4 <title>Subscribing should provide a Curve25519 ECDH public key.</title> | 4 <title>Subscribing should provide a Curve25519 ECDH public key.</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="../resources/testharness-helpers.js"></script> | 8 <script src="../resources/testharness-helpers.js"></script> |
| 9 <script src="../serviceworker/resources/test-helpers.js"></script> | 9 <script src="../serviceworker/resources/test-helpers.js"></script> |
| 10 </head> | 10 </head> |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 swRegistration = serviceWorkerRegistration; | 31 swRegistration = serviceWorkerRegistration; |
| 32 return wait_for_state(test, swRegistration.installing, '
activated'); | 32 return wait_for_state(test, swRegistration.installing, '
activated'); |
| 33 }) | 33 }) |
| 34 .then(function() { | 34 .then(function() { |
| 35 if (window.testRunner) | 35 if (window.testRunner) |
| 36 testRunner.setPermission('push-messaging', 'granted'
, location.origin, location.origin); | 36 testRunner.setPermission('push-messaging', 'granted'
, location.origin, location.origin); |
| 37 | 37 |
| 38 return swRegistration.pushManager.subscribe(); | 38 return swRegistration.pushManager.subscribe(); |
| 39 }) | 39 }) |
| 40 .then(function(pushSubscription) { | 40 .then(function(pushSubscription) { |
| 41 // TODO(peter): Remove support for the attribute when th
e embedder has been updated. |
| 41 assert_idl_attribute(pushSubscription, 'curve25519dh'); | 42 assert_idl_attribute(pushSubscription, 'curve25519dh'); |
| 42 assert_equals(pushSubscription.curve25519dh, pushSubscri
ption.curve25519dh); | |
| 43 assert_readonly(pushSubscription, 'curve25519dh'); | |
| 44 assert_equals(pushSubscription.curve25519dh.byteLength,
EXPECTED_KEY_LENGTH); | |
| 45 | 43 |
| 46 encryptionKey = SerializeArrayBuffer(pushSubscription.cu
rve25519dh); | 44 assert_own_property(PushSubscription.prototype, 'getKey'
); |
| 45 assert_not_equals(pushSubscription.getKey('curve25519dh'
), null); |
| 46 assert_equals(pushSubscription.getKey('curve25519dh').by
teLength, EXPECTED_KEY_LENGTH); |
| 47 |
| 48 // The returned ArrayBuffers are expected to be the same
. |
| 49 assert_equals(pushSubscription.getKey('curve25519dh'), p
ushSubscription.getKey('curve25519dh')); |
| 50 |
| 51 // Getting a key with an unsupported algorithm should th
row an exception. |
| 52 assert_throws(TypeError(), () => pushSubscription.getKey
('petercurve9001')); |
| 53 |
| 54 encryptionKey = SerializeArrayBuffer(pushSubscription.ge
tKey('curve25519dh')); |
| 47 | 55 |
| 48 return swRegistration.pushManager.getSubscription(); | 56 return swRegistration.pushManager.getSubscription(); |
| 49 }) | 57 }) |
| 50 .then(function(pushSubscription) { | 58 .then(function(pushSubscription) { |
| 51 assert_equals(SerializeArrayBuffer(pushSubscription.curv
e25519dh), encryptionKey); | 59 assert_equals(SerializeArrayBuffer(pushSubscription.getK
ey('curve25519dh')), encryptionKey); |
| 52 | 60 |
| 53 return service_worker_unregister_and_done(test, workerSc
ope); | 61 return service_worker_unregister_and_done(test, workerSc
ope); |
| 54 }) | 62 }) |
| 55 .catch(unreached_rejection(test)); | 63 .catch(unreached_rejection(test)); |
| 56 | 64 |
| 57 }, 'Subscribing should provide a Curve25519 ECDH public key'); | 65 }, 'Subscribing should provide a Curve25519 ECDH public key'); |
| 58 </script> | 66 </script> |
| 59 </body> | 67 </body> |
| 60 </html> | 68 </html> |
| OLD | NEW |