1 // META: script=/common/get-host-info.sub.js
2 // META: script=/service-workers/service-worker/resources/test-helpers.sub.js
6 promise_test(async test => {
7 const script = 'service_workers/sw.js';
8 const scope = 'service_workers' + location.pathname;
10 const serviceWorkerRegistration =
11 await service_worker_unregister_and_register(test, script, scope);
14 serviceWorkerRegistration.active, null,
15 'There must not be an activated worker');
17 await promise_rejects(
18 test, new DOMException('', 'InvalidStateError'),
19 serviceWorkerRegistration.periodicSync.register(
21 'register() must reject on pending and installing workers');
22 }, 'Periodic Background Sync requires an activated Service Worker');
24 promise_test(async test => {
25 const script = 'service_workers/sw.js';
26 const scope = 'service_workers' + location.pathname;
28 const serviceWorkerRegistration =
29 await service_worker_unregister_and_register(test, script, scope);
32 serviceWorkerRegistration.active, null,
33 'There must not be an activated worker');
35 await serviceWorkerRegistration.periodicSync.unregister('test_tag');
36 }, 'Periodic Background Sync unregister silently succeeds when Service Worker is unactivated');