chromium/third_party/blink/web_tests/http/tests/push_messaging/permission-state-denied-in-service-worker.html

<!DOCTYPE html>
<html>
<head>
<title>
  Push API: permissionState when called in service worker resolves with denied when permission is
  denied
</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, deny permission when prompted.
async_test(test => {
    var script = 'resources/instrumentation-service-worker.js';
    var scope = 'resources/scope/' + location.pathname;

    PermissionsHelper.setPermission('push-messaging', 'denied')
        .then(() => getActiveServiceWorkerWithMessagePort(test, script, scope))
        .then(workerInfo => {
            workerInfo.port.postMessage({ command: 'permissionState',
                                          options: { userVisibleOnly: true } });

            workerInfo.port.addEventListener('message', event => {
                if (typeof event.data != 'object' || !event.data.command)
                    assert_unreached('Invalid message from the service worker');

                assert_equals(event.data.command, 'permissionState');
                assert_true(event.data.success,
                            'permissionState should succeed. Error message: ' +
                                event.data.errorMessage);

                assert_equals(event.data.permission, 'denied');
                test.done();
            });
        })
        .catch(unreached_rejection(test));
}, 'permissionState when called in service worker resolves with denied when permission is denied');
</script>
</body>
</html>