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

Side by Side Diff: third_party/WebKit/LayoutTests/http/tests/push_messaging/application-server-key-format-test.html

Issue 2411733002: Check the format of an applicationServerKey when used to register a push subscription. (Closed)
Patch Set: More formatting Created 4 years, 2 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
OLDNEW
(Empty)
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <title>
5 Subscribing with applicationServerKey should succeed only when the
6 applicationServerKey is valid.
7 </title>
8 <script src="resources/push-constants.js"></script>
9 <script src="resources/test-helpers.js"></script>
10 <script src="../resources/testharness.js"></script>
11 <script src="../resources/testharnessreport.js"></script>
12 <script src="../resources/testharness-helpers.js"></script>
13 <script src="../serviceworker/resources/test-helpers.js"></script>
14 </head>
15 <body>
16 <script>
17 // Subscribe should succeed given a valid numeric sender ID.
18 promise_test(function(test) {
19 return registerAndSubscribePushWithString(test, '0123456789')
20 .then(function(pushSubscription) {
21 assert_true(
22 pushSubscription.endpoint.includes('LayoutTestEndpoint'));
23 });
24 }, 'Subscribing with a valid numeric sender ID should succeed');
25
26 // Subscribe should succeed given a valid p256 key.
27 promise_test(function(test) {
28 return registerAndSubscribePush(test, new Uint8Array(PUBLIC_KEY))
29 .then(function(pushSubscription) {
30 assert_true(
31 pushSubscription.endpoint.includes('StandardizedEndpoint'));
32 });
33 }, 'Subscribing with a valid p256 applicationServerKey should succeed');
34
35 // Subscribe should fail given a non-numeric sender ID.
36 promise_test(function(test) {
37 return registerAndSubscribePushWithString(test, '01234a56789')
38 .then(function(pushSubscription) {
39 assert_unreached('Subscribe should have failed.');
40 })
41 .catch (function(e) {
42 assert_true(e.message.includes(
43 'The provided applicationServerKey is not valid.'));
44 });
45 }, 'Subscribing with a non-numeric sender ID should fail');
46
47 // Subscribe should fail given an empty applicationServerKey.
48 promise_test(function(test) {
49 return registerAndSubscribePushWithString(test, '')
50 .then(function(pushSubscription) {
51 assert_unreached('Subscribe should have failed.');
52 })
53 .catch (function(e) {
54 assert_true(e.message.includes(
55 'The provided applicationServerKey is not valid.'));
56 });
57 }, 'Subscribing with an empty applicationServerKey should fail');
58
59 // Subscribe should fail given a too long applicationServerKey.
60 promise_test(function(test) {
61 const longKey = new Uint8Array(300);
62 return registerAndSubscribePush(test, longKey)
63 .then(function(pushSubscription) {
64 assert_unreached('Subscribe should have failed.');
65 })
66 .catch (function(e) {
67 assert_true(e.message.includes(
68 'The provided applicationServerKey is not valid.'));
69 });
70 }, 'Subscribing with a too long applicationServerKey should fail');
71 </script>
72 </body>
73 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698