Bug 1611320 [wpt PR 21400] - Gate Longtasks and PaintTiming tests under assert_precon...
[gecko.git] / testing / web-platform / tests / PeriodicBackgroundSync / periodicsync.https.window.js
bloba9aebdbfe891b5175c8b85d7da9ff75269b619fe
1 // META: script=/common/get-host-info.sub.js
2 // META: script=/service-workers/service-worker/resources/test-helpers.sub.js
4 'use strict'
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);
13   assert_equals(
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(
20           'test_tag'),
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);
31   assert_equals(
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');