push.https.html (1134B)
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 const params = new URLSearchParams(location.search); 9 10 // The main test page (restriction-push.https.html) loads the initiator page, 11 // then the initiator page will prerender itself with the `prerendering` 12 // parameter. 13 const isPrerendering = params.has('prerendering'); 14 15 if (!isPrerendering) { 16 loadInitiatorPage(); 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 subscribe_promise = registration.pushManager.subscribe({ 23 userVisibleOnly: true, 24 applicationServerKey: new TextEncoder().encode('0987654321') 25 }); 26 prerenderEventCollector.start(subscribe_promise, 'pushManager.subscribe'); 27 } 28 loadPrerenderPage(); 29 } 30 31 </script>