frame-for-getregistrations.html (519B)
1 <!DOCTYPE html> 2 <title>Service Worker: frame for getRegistrations()</title> 3 <script> 4 var scope = 'scope-for-getregistrations'; 5 var script = 'empty-worker.js'; 6 var registration; 7 8 navigator.serviceWorker.register(script, { scope: scope }) 9 .then(function(r) { registration = r; window.parent.postMessage('ready', '*'); }) 10 11 self.onmessage = function(e) { 12 if (e.data == 'unregister') { 13 registration.unregister() 14 .then(function() { 15 e.ports[0].postMessage('unregistered'); 16 }); 17 } 18 }; 19 </script>