| <!DOCTYPE html> |
| <html> |
| <head> |
| <title>Push API: permissionState resolves with granted when permission is granted</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, grant permission when prompted. |
| return PermissionsHelper.setPermission('push-messaging', 'granted') |
| .then(() => service_worker_unregister_and_register(test, workerUrl, workerScope)) |
| .then(serviceWorkerRegistration => { |
| return serviceWorkerRegistration.pushManager.permissionState({userVisibleOnly: true}); |
| }) |
| .then(permissionStatus => { |
| assert_equals(permissionStatus, 'granted'); |
| return service_worker_unregister_and_done(test, workerScope); |
| }); |
| }, 'Push API: permissionState resolves with granted when permission is granted'); |
| </script> |
| </body> |
| </html> |