blob: eee08009d0a815639d2cdc28def008903fb3a172 [file] [log] [blame]
<!DOCTYPE html>
<html>
<head>
<title>
Push API: permissionState when called in service worker 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>
<script src="../notifications/resources/test-helpers.js"></script>
</head>
<body>
<script>
// This test uses the test runner. If running manually, clear permissions before running this test.
async_test(test => {
const script = 'resources/instrumentation-service-worker.js';
const scope = 'resources/scope/' + location.pathname;
PermissionsHelper.setPermission('push-messaging', 'prompt')
.then(() => getActiveServiceWorkerWithMessagePort(test, script, scope))
.then(workerInfo => {
workerInfo.port.postMessage({command: 'permissionState', options: {}});
workerInfo.port.addEventListener('message', event => {
assert_equals(
event.data.errorMessage,
'Push subscriptions that don\'t enable userVisibleOnly are not supported.');
test.done();
});
})
.catch(unreached_rejection(test));
}, 'Push API: permissionState when called in service worker fails with NotSupportedError if ' +
'userVisibleOnly is not used');
</script>
</body>
</html>