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

Side by Side Diff: third_party/WebKit/LayoutTests/http/tests/push_messaging/subscribe-failure-mismatched-sender-id.html

Issue 2436393002: Disallow repeated PushManager.subscribes with different sender ids (Closed)
Patch Set: Make error message more informative Created 4 years, 1 month 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>subscribe() is rejected when called with a different sender id</title>
5 <script src="../resources/testharness.js"></script>
6 <script src="../resources/testharnessreport.js"></script>
7 <script src="../serviceworker/resources/test-helpers.js"></script>
8 </head>
9 <body>
10 <script>
11 async_test(function(test) {
12 var workerUrl = 'resources/instrumentation-service-worker.js';
13 var workerScope = 'resources/scope/' + location.pathname;
14 var swRegistration;
15 const FIRST_SENDER_ID_OPTIONS = {
16 userVisibleOnly: true,
17 applicationServerKey: new TextEncoder().encode('1234567890')
18 };
19 const SECOND_SENDER_ID_OPTIONS = {
20 userVisibleOnly: true,
21 applicationServerKey: new TextEncoder().encode('0987654321')
22 };
23 service_worker_unregister_and_register(test, workerUrl, workerScope)
24 .then(function(serviceWorkerRegistration) {
25 swRegistration = serviceWorkerRegistration;
26 return wait_for_state(test, swRegistration.installing, 'activated');
27 })
28 .then(function() {
29 // If running manually, grant permission when prompted.
30 if (window.testRunner) {
31 testRunner.setPermission('push-messaging', 'granted',
32 location.origin, location.origin);
33 }
34 return swRegistration.pushManager.subscribe(
35 FIRST_SENDER_ID_OPTIONS);
36 })
37 .then(function(pushSubscription) {
38 return swRegistration.pushManager.subscribe(
39 SECOND_SENDER_ID_OPTIONS);
40 })
41 .then(function(pushSubscription) {
42 assert_unreached(
43 'Second subscribe() must not succeed with different sender ID');
44 }, function(e) {
45 assert_equals(e.name, 'InvalidStateError');
46 assert_equals(e.message, 'Registration failed - ' +
47 'A subscription with a different applicationServerKey ' +
48 '(or gcm_sender_id) already exists; to change the ' +
49 'applicationServerKey, unsubscribe then resubscribe.');
50 return service_worker_unregister_and_done(test, workerScope);
51 })
52 .catch(unreached_rejection(test));
53 }, 'subscribe() is rejected when a subscription with a different sender ID' +
54 'already exists');
55 </script>
56 </body>
57 </html>
OLDNEW
« no previous file with comments | « content/public/common/push_messaging_status.cc ('k') | third_party/WebKit/Source/modules/push_messaging/PushError.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698