| <!doctype html> |
| <meta charset="utf-8"> |
| <title>Background Sync API: Verifies that the sync promise is rejected if |
| permission is denied.</title> |
| <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> |
| |
| promise_test(test => { |
| const url = '/resources/empty-worker.js'; |
| const scope = '/resources/scope/' + location.pathname; |
| |
| let sync_manager = null; |
| |
| // This test verifies that registration of one-shots fails from an iframe. |
| return service_worker_unregister_and_register(test, url, scope) |
| .then(registration => { |
| sync_manager = registration.sync; |
| return wait_for_state(test, registration.installing, 'activated'); |
| }) |
| .then(() => PermissionsHelper.setPermission('background-sync', 'denied')) |
| .then(() => sync_manager.register('sync')) |
| .then(() => assert_unreached('sync.register() must not succeed when permission is denied'), |
| error => { |
| assert_equals(error.name, 'NotAllowedError'); |
| assert_equals(error.message, 'Permission denied.'); |
| }); |
| }, 'Registering a sync should reject the promise if permission is denied'); |
| </script> |