update-missing-import-scripts.https.html (1144B)
1 <!DOCTYPE html> 2 <title>Service Worker: update with missing importScripts</title> 3 <script src="/resources/testharness.js"></script> 4 <script src="/resources/testharnessreport.js"></script> 5 <script src="resources/test-helpers.sub.js"></script> 6 <script src="/common/utils.js"></script> 7 <body> 8 <script> 9 /** 10 * Test ServiceWorkerRegistration.update() when importScripts in a service worker 11 * script is no longer available (but was initially). 12 */ 13 let registration = null; 14 15 promise_test(async (test) => { 16 const script = `resources/update-missing-import-scripts-main-worker.py?key=${token()}`; 17 const scope = 'resources/update-missing-import-scripts'; 18 19 registration = await service_worker_unregister_and_register(test, script, scope); 20 21 add_completion_callback(() => { registration.unregister(); }); 22 23 await wait_for_state(test, registration.installing, 'activated'); 24 }, 'Initialize global state'); 25 26 promise_test(test => { 27 return new Promise(resolve => { 28 registration.addEventListener('updatefound', resolve); 29 registration.update(); 30 }); 31 }, 'Update service worker with new script that\'s missing importScripts()'); 32 </script> 33 </body>