| 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. | |
| 42 assert_idl_attribute(pushSubscription, 'curve25519dh'); | |
| 43 | |
| 44 assert_own_property(PushSubscription.prototype, 'getKey'
); | 41 assert_own_property(PushSubscription.prototype, 'getKey'
); |
| 45 assert_not_equals(pushSubscription.getKey('curve25519dh'
), null); | 42 assert_not_equals(pushSubscription.getKey('curve25519dh'
), null); |
| 46 assert_equals(pushSubscription.getKey('curve25519dh').by
teLength, EXPECTED_KEY_LENGTH); | 43 assert_equals(pushSubscription.getKey('curve25519dh').by
teLength, EXPECTED_KEY_LENGTH); |
| 47 | 44 |
| 48 // The returned ArrayBuffers are expected to be the same
. | 45 // The returned ArrayBuffers are expected to be the same
. |
| 49 assert_equals(pushSubscription.getKey('curve25519dh'), p
ushSubscription.getKey('curve25519dh')); | 46 assert_equals(pushSubscription.getKey('curve25519dh'), p
ushSubscription.getKey('curve25519dh')); |
| 50 | 47 |
| 51 // Getting a key with an unsupported algorithm should th
row an exception. | 48 // Getting a key with an unsupported algorithm should th
row an exception. |
| 52 assert_throws(TypeError(), () => pushSubscription.getKey
('petercurve9001')); | 49 assert_throws(TypeError(), () => pushSubscription.getKey
('petercurve9001')); |
| 53 | 50 |
| 54 encryptionKey = SerializeArrayBuffer(pushSubscription.ge
tKey('curve25519dh')); | 51 encryptionKey = SerializeArrayBuffer(pushSubscription.ge
tKey('curve25519dh')); |
| 55 | 52 |
| 56 return swRegistration.pushManager.getSubscription(); | 53 return swRegistration.pushManager.getSubscription(); |
| 57 }) | 54 }) |
| 58 .then(function(pushSubscription) { | 55 .then(function(pushSubscription) { |
| 59 assert_equals(SerializeArrayBuffer(pushSubscription.getK
ey('curve25519dh')), encryptionKey); | 56 assert_equals(SerializeArrayBuffer(pushSubscription.getK
ey('curve25519dh')), encryptionKey); |
| 60 | 57 |
| 61 return service_worker_unregister_and_done(test, workerSc
ope); | 58 return service_worker_unregister_and_done(test, workerSc
ope); |
| 62 }) | 59 }) |
| 63 .catch(unreached_rejection(test)); | 60 .catch(unreached_rejection(test)); |
| 64 | 61 |
| 65 }, 'Subscribing should provide a Curve25519 ECDH public key'); | 62 }, 'Subscribing should provide a Curve25519 ECDH public key'); |
| 66 </script> | 63 </script> |
| 67 </body> | 64 </body> |
| 68 </html> | 65 </html> |
| OLD | NEW |