Index: LayoutTests/http/tests/push_messaging/subscribe-encryption-public-key.html |
diff --git a/LayoutTests/http/tests/push_messaging/subscribe-encryption-public-key.html b/LayoutTests/http/tests/push_messaging/subscribe-encryption-public-key.html |
new file mode 100644 |
index 0000000000000000000000000000000000000000..c15aff30cbcf3b46b10ec9c9de734d0c721b6d67 |
--- /dev/null |
+++ b/LayoutTests/http/tests/push_messaging/subscribe-encryption-public-key.html |
@@ -0,0 +1,56 @@ |
+<!DOCTYPE html> |
+<html> |
+ <head> |
+ <title>Subscribing should provide a Curve25519 ECDH public key.</title> |
+ <link rel="manifest" href="resources/push_manifest.json"> |
+ <script src="../resources/testharness.js"></script> |
+ <script src="../resources/testharnessreport.js"></script> |
+ <script src="../resources/testharness-helpers.js"></script> |
+ <script src="../serviceworker/resources/test-helpers.js"></script> |
+ </head> |
+ <body> |
+ <script> |
+ // When running this test manually, grant permission when prompted. |
+ // This test verifies that push subscriptions get an ECDH Curve25519 |
+ // key that can be used on the application server to encrypt payloads. |
+ async_test(function(test) { |
+ var workerUrl = 'resources/empty_worker.js'; |
+ var workerScope = 'resources/scope/' + location.pathname; |
+ var swRegistration, encryptionKey; |
+ |
+ // Size of an ECDH curve25519 public key, in bytes. |
+ var EXPECTED_KEY_LENGTH = 32; |
+ |
+ service_worker_unregister_and_register(test, workerUrl, workerScope) |
+ .then(function(serviceWorkerRegistration) { |
+ swRegistration = serviceWorkerRegistration; |
+ return wait_for_state(test, swRegistration.installing, 'activated'); |
+ }) |
+ .then(function() { |
+ if (window.testRunner) |
+ testRunner.setPermission('push-messaging', 'granted', location.origin, location.origin); |
+ |
+ return swRegistration.pushManager.subscribe(); |
+ }) |
+ .then(function(pushSubscription) { |
+ assert_idl_attribute(pushSubscription, 'curve25519dh'); |
+ assert_equals(pushSubscription.curve25519dh, pushSubscription.curve25519dh); |
+ assert_readonly(pushSubscription, 'curve25519dh'); |
+ |
+ encryptionKey = pushSubscription.curve25519dh; |
+ assert_equals(encryptionKey.byteLength, EXPECTED_KEY_LENGTH); |
+ |
+ return swRegistration.pushManager.getSubscription(); |
+ }) |
+ .then(function(pushSubscription) { |
+ 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,
|
+ encryptionKey.byteLength); |
+ |
+ return service_worker_unregister_and_done(test, workerScope); |
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
|
+ }) |
+ .catch(unreached_rejection(test)); |
+ |
+ }, 'Subscribing should provide a Curve25519 ECDH public key'); |
+ </script> |
+ </body> |
+</html> |