iframe_1502055.html (690B)
1 <!DOCTYPE HTML> 2 <html> 3 <body> 4 <script type="application/javascript"> 5 6 function info(msg) { 7 parent.postMessage({type: "info", msg }, "*"); 8 } 9 10 let registration; 11 12 info("Registering a ServiceWorker"); 13 navigator.serviceWorker.register('sw_1502055.js', {scope: "foo/"}) 14 .then(reg => { 15 registration = reg; 16 info("Fetching a resource"); 17 return fetch("file_1502055.sjs") 18 }).then(r => r.text()) 19 .then(() => { 20 info("Fetching a resource, again"); 21 return fetch("file_1502055.sjs") 22 }).then(r => r.text()).then(() => { 23 info("Unregistering the ServiceWorker"); 24 return registration.unregister(); 25 }) 26 .then(() => { 27 parent.postMessage({ type: "finish" }, "*"); 28 }); 29 30 </script> 31 32 </body> 33 </html>