Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(114)

Side by Side Diff: LayoutTests/http/tests/push_messaging/subscribe-encryption-public-key.html

Issue 1237673002: Introduce the PushSubscription.curve25519dh attribute (3/3) (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | LayoutTests/http/tests/serviceworker/webexposed/global-interface-listing-service-worker-expected.txt » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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 // Serializes |buffer| to a base64-encoded string.
14 function SerializeArrayBuffer(buffer) {
15 return btoa(String.fromCharCode.apply(null, new Uint8Array(buffe r)));
16 }
17
18 // When running this test manually, grant permission when prompted.
19 // This test verifies that push subscriptions get an ECDH Curve25519
20 // key that can be used on the application server to encrypt payload s.
21 async_test(function(test) {
22 var workerUrl = 'resources/empty_worker.js';
23 var workerScope = 'resources/scope/' + location.pathname;
24 var swRegistration, encryptionKey;
25
26 // Size of an ECDH curve25519 public key, in bytes.
27 var EXPECTED_KEY_LENGTH = 32;
28
29 service_worker_unregister_and_register(test, workerUrl, workerSc ope)
30 .then(function(serviceWorkerRegistration) {
31 swRegistration = serviceWorkerRegistration;
32 return wait_for_state(test, swRegistration.installing, ' activated');
33 })
34 .then(function() {
35 if (window.testRunner)
36 testRunner.setPermission('push-messaging', 'granted' , location.origin, location.origin);
37
38 return swRegistration.pushManager.subscribe();
39 })
40 .then(function(pushSubscription) {
41 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
46 encryptionKey = SerializeArrayBuffer(pushSubscription.cu rve25519dh);
47
48 return swRegistration.pushManager.getSubscription();
49 })
50 .then(function(pushSubscription) {
51 assert_equals(SerializeArrayBuffer(pushSubscription.curv e25519dh), encryptionKey);
52
53 return service_worker_unregister_and_done(test, workerSc ope);
54 })
55 .catch(unreached_rejection(test));
56
57 }, 'Subscribing should provide a Curve25519 ECDH public key');
58 </script>
59 </body>
60 </html>
OLDNEW
« no previous file with comments | « no previous file | LayoutTests/http/tests/serviceworker/webexposed/global-interface-listing-service-worker-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698