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

Unified Diff: third_party/WebKit/LayoutTests/http/tests/push_messaging/application-server-key-standard-endpoint.html

Issue 1931843002: Ship Web Push subscription restrictions (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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/application-server-key-standard-endpoint.html
diff --git a/third_party/WebKit/LayoutTests/http/tests/push_messaging/application-server-key-standard-endpoint.html b/third_party/WebKit/LayoutTests/http/tests/push_messaging/application-server-key-standard-endpoint.html
new file mode 100644
index 0000000000000000000000000000000000000000..536b383d406f32e33e299d677c5045356bb8d79a
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/http/tests/push_messaging/application-server-key-standard-endpoint.html
@@ -0,0 +1,52 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <title>Subscribing with an applicationServerKey should return a standardized endpoint</title>
+ <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>
+ const PUBLIC_KEY = [
+ 0x04, 0x56, 0x23, 0xC0, 0x45, 0xD7, 0x6C, 0x5D, 0x45, 0x1A, 0x29,
+ 0x19, 0xAA, 0xE5, 0x02, 0x2F, 0x43, 0x55, 0xC2, 0x5C, 0x59, 0x86,
+ 0x69, 0xA0, 0xAD, 0xD7, 0x2D, 0x54, 0x22, 0xD8, 0x43, 0xB6, 0xCD,
+ 0xE3, 0x33, 0xB4, 0xBB, 0x66, 0x2F, 0x47, 0xE5, 0xE6, 0x20, 0xFF,
+ 0x0E, 0x10, 0x7F, 0xCD, 0xA3, 0x44, 0x8C, 0x65, 0x54, 0x64, 0x7E,
+ 0x25, 0xF3, 0x67, 0xF4, 0x7C, 0x4B, 0x0C, 0xBD, 0xCF, 0xF4
+ ];
+
+ // When running this test manually, grant permission when prompted.
+ // This test verifies that push subscriptions made with a valid P-256
+ // applicationServerKey return the standardized endpoint.
+ async_test(function(test) {
Michael van Ouwerkerk 2016/04/29 17:21:21 nit: use a promise_test?
Peter Beverloo 2016/05/18 17:43:24 Done.
+ var workerUrl = 'resources/empty_worker.js';
+ var workerScope = 'resources/scope/' + location.pathname;
+ var swRegistration;
+
+ 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({
+ userVisibleOnly: true,
+ applicationServerKey: new Uint8Array(PUBLIC_KEY)
+ });
+ })
+ .then(function(pushSubscription) {
+ assert_true(pushSubscription.endpoint.includes('StandardizedEndpoint'));
+ test.done();
+ })
+ .catch(unreached_rejection(test));
+
+ }, 'Subscribing with an applicationServerKey should return the standardized endpoint');
+ </script>
+ </body>
+ </html>

Powered by Google App Engine
This is Rietveld 408576698