blob: 15afc1b830e956973b70946c166a289d832d6a5a [file] [log] [blame]
<!DOCTYPE html>
<html>
<head>
<title>Push API: permissionState fails with NotSupportedError if userVisibleOnly is not used</title>
<link rel="manifest" href="resources/push_manifest.json">
<script src="../resources/permissions-helper.js"></script>
<script src="../resources/testharness.js"></script>
<script src="../resources/testharnessreport.js"></script>
<script src="../serviceworker/resources/test-helpers.js"></script>
</head>
<body>
<script>
promise_test(test => {
const workerUrl = 'resources/empty_worker.js';
const workerScope = 'resources/scope/' + location.pathname;
// If running manually, clear permissions before running this test.
return PermissionsHelper.setPermission('push-messaging', 'prompt')
.then(() => service_worker_unregister_and_register(test, workerUrl, workerScope))
.then(serviceWorkerRegistration => {
return serviceWorkerRegistration.pushManager.permissionState();
})
.then(permissionStatus => {
assert_unreached('permissionStatus should have failed with a NotSupported exception');
}, error => {
assert_equals(error.name, 'NotSupportedError');
assert_equals(
error.message,
'Push subscriptions that don\'t enable userVisibleOnly are not supported.');
});
}, 'Push API: permissionState fails with NotSupportedError if userVisibleOnly is not used');
</script>
</body>
</html>