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

Unified 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: Rename registration_id -> push_registration_id 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/LayoutTests/http/tests/push_messaging/subscribe-failure-mismatched-sender-id.html
diff --git a/third_party/WebKit/LayoutTests/http/tests/push_messaging/subscribe-failure-mismatched-sender-id.html b/third_party/WebKit/LayoutTests/http/tests/push_messaging/subscribe-failure-mismatched-sender-id.html
new file mode 100644
index 0000000000000000000000000000000000000000..83e37afe98c2ca2b4bbfe177336c2d07b9ba106c
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/http/tests/push_messaging/subscribe-failure-mismatched-sender-id.html
@@ -0,0 +1,52 @@
+<!DOCTYPE html>
+<html>
harkness 2016/10/25 10:11:22 FYI: In the future we're going to move to an inden
awdf 2016/10/25 13:18:18 Acknowledged.
+<head>
+<title>subscribe() is rejected when called with a different sender id</title>
+<link rel="manifest" href="resources/push_manifest.json">
+<script src="../resources/testharness.js"></script>
+<script src="../resources/testharnessreport.js"></script>
+<script src="../serviceworker/resources/test-helpers.js"></script>
+</head>
+<body>
+<script>
+async_test(function(test) {
+ var workerUrl = 'resources/instrumentation-service-worker.js';
+ var workerScope = 'resources/scope/' + location.pathname;
+ var swRegistration;
+ const FIRST_SENDER_ID_OPTIONS = {
+ userVisibleOnly: true,
+ // This is equal to the gcm_sender_id in push_manifest.json
harkness 2016/10/25 10:11:22 Since you're setting the applicationServerKey, you
awdf 2016/10/25 13:18:18 Good spot. (I copied another test and didn't notic
+ applicationServerKey: new TextEncoder().encode('1234567890')
+ };
+ const SECOND_SENDER_ID_OPTIONS = {
+ userVisibleOnly: true,
+ applicationServerKey: new TextEncoder().encode('0987654321')
+ };
+ service_worker_unregister_and_register(test, workerUrl, workerScope)
+ .then(function(serviceWorkerRegistration) {
+ swRegistration = serviceWorkerRegistration;
+ return wait_for_state(test, swRegistration.installing, 'activated');
+ })
+ .then(function() {
+ // If running manually, grant permission when prompted.
+ if (window.testRunner)
+ testRunner.setPermission(
+ 'push-messaging', 'granted', location.origin, location.origin);
harkness 2016/10/25 10:11:22 We are trying to convert to 80 column width, if yo
awdf 2016/10/25 13:18:18 Done.
+ return swRegistration.pushManager.subscribe(FIRST_SENDER_ID_OPTIONS);
+ })
+ .then(function(pushSubscription) {
+ return swRegistration.pushManager.subscribe(SECOND_SENDER_ID_OPTIONS);
+ })
+ .then(function(pushSubscription) {
+ assert_unreached('Second subscribe() must not succeed with different sender ID');
+ }, function(e) {
+ assert_equals(e.name, 'InvalidStateError');
+ assert_equals(e.message,
+ 'Registration failed - A subscription with a different sender ID already exists');
+ return service_worker_unregister_and_done(test, workerScope);
+ })
+ .catch(unreached_rejection(test));
+}, 'subscribe() is rejected when a subscription with a different sender ID already exists');
+</script>
+</body>
+</html>

Powered by Google App Engine
This is Rietveld 408576698