periodicsync.https.window.js (1282B)
1 // META: script=/common/get-host-info.sub.js 2 // META: script=/service-workers/service-worker/resources/test-helpers.sub.js 3 4 'use strict' 5 6 promise_test(async test => { 7 const script = 'service_workers/sw.js'; 8 const scope = 'service_workers' + location.pathname; 9 10 const serviceWorkerRegistration = 11 await service_worker_unregister_and_register(test, script, scope); 12 13 assert_equals( 14 serviceWorkerRegistration.active, null, 15 'There must not be an activated worker'); 16 17 await promise_rejects_dom( 18 test, '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'); 23 24 promise_test(async test => { 25 const script = 'service_workers/sw.js'; 26 const scope = 'service_workers' + location.pathname; 27 28 const serviceWorkerRegistration = 29 await service_worker_unregister_and_register(test, script, scope); 30 31 assert_equals( 32 serviceWorkerRegistration.active, null, 33 'There must not be an activated worker'); 34 35 await serviceWorkerRegistration.periodicSync.unregister('test_tag'); 36 }, 'Periodic Background Sync unregister silently succeeds when Service Worker is unactivated');