background-fetch.https.html (1144B)
1 <!DOCTYPE html> 2 <script src="/resources/testharness.js"></script> 3 <script src="/resources/testharnessreport.js"></script> 4 <script src="/speculation-rules/prerender/resources/utils.js"></script> 5 <script src="/speculation-rules/prerender/resources/deferred-promise-utils.js"></script> 6 <script> 7 8 // The main test page (restriction-background-fetch.https.html) loads the 9 // initiator page, then the initiator page will prerender itself with the 10 // `prerendering` parameter. 11 const params = new URLSearchParams(location.search); 12 const isPrerendering = params.has('prerendering'); 13 14 if (!isPrerendering) { 15 const rule_extras = {'target_hint': getTargetHint()}; 16 loadInitiatorPage(rule_extras); 17 } else { 18 async function loadPrerenderPage() { 19 const prerenderEventCollector = new PrerenderEventCollector(); 20 const scope = `resources/`; 21 const registration = await navigator.serviceWorker.getRegistration(scope); 22 const fetch_promise = registration.backgroundFetch.fetch( 23 'my-fetch', '/', {icons: [{src: '/'}]}); 24 prerenderEventCollector.start(fetch_promise, 'backgroundFetch.fetch'); 25 } 26 loadPrerenderPage(); 27 } 28 29 </script>