blob: 773cb96ee3832ea985ab1a37dfd71cca412c8498 [file] [log] [blame]
async function registerServiceWorker()
{
try {
const registration = await navigator.serviceWorker.register("../skipFetchEvent-worker.js", { scope : '' });
activeWorker = registration.active;
if (activeWorker) {
self.postMessage('already active');
return;
}
activeWorker = registration.installing;
await new Promise(resolve => {
activeWorker.addEventListener('statechange', () => {
if (activeWorker.state === "activated")
resolve();
});
});
self.postMessage('registration is now active');
} catch (e) {
self.postMessage('error: '+ e);
}
}
registerServiceWorker();