background-sync-inner.https.html (1112B)
1 <!DOCTYPE html> 2 <script src="/resources/testharness.js"></script> 3 <script src="/resources/testharnessreport.js"></script> 4 <script src="utils.js"></script> 5 <title>Fenced frame content to report the result of background sync's register</title> 6 7 <body> 8 <script type="module"> 9 import {getOneShotSyncPromise, getPeriodicSyncPromise} from './background-sync-helper.js'; 10 11 const [background_sync_register_key] = parseKeylist(); 12 const searchParams = new URL(location.href).searchParams; 13 const method = searchParams.get('method'); 14 const periodic = searchParams.get('periodic'); 15 16 navigator.serviceWorker.register("empty-worker.js", { scope: location.href }); 17 const registration = await navigator.serviceWorker.ready; 18 19 try { 20 if (periodic) { 21 await getPeriodicSyncPromise(registration, method); 22 } else { 23 await getOneShotSyncPromise(registration, method); 24 } 25 writeValueToServer(background_sync_register_key, "unexpectedly registered"); 26 } catch (e) { 27 writeValueToServer(background_sync_register_key, e.message); 28 } finally { 29 registration.unregister(); 30 } 31 </script> 32 </body>