blob: 842d058b2df988d80bc9ed2d1d72556c3414f18e [file] [log] [blame]
<!DOCTYPE html>
<html>
<head>
<title>Subscribing with an applicationServerKey should return a standardized endpoint</title>
<script src="resources/push-constants.js"></script>
<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>
function test_standardized_endpoint(test, applicationServerKey) {
var workerUrl = 'resources/empty_worker.js';
var workerScope = 'resources/scope/' + location.pathname;
var swRegistration;
return 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: applicationServerKey
});
})
.then(function(pushSubscription) {
assert_true(pushSubscription.endpoint.includes('StandardizedEndpoint'));
});
}
// 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.
promise_test(function(test) {
return test_standardized_endpoint(test, new Uint8Array(PUBLIC_KEY));
}, 'Subscribing with an applicationServerKey should return the standardized endpoint');
// When running this test manually, grant permission when prompted.
// This test verifies that push subscriptions made with a valid base64url encoded
// applicationServerKey return the standardized endpoint.
promise_test(function(test) {
return test_standardized_endpoint(test, VALID_BASE64URL_ENCODED_KEY);
}, 'Subscribing with a base64url encoded key should return the standardized endpoint');
</script>
</body>
</html>