- From: Joseph Liccini <notifications@github.com>
- Date: Tue, 03 Nov 2020 10:29:08 -0800
- To: w3c/ServiceWorker <ServiceWorker@noreply.github.com>
- Cc: Subscribed <subscribed@noreply.github.com>
Received on Tuesday, 3 November 2020 18:29:20 UTC
Hi! I am doing some exploration into Web Workers and Service Workers and the communication mechanism between them. I was expecting inside `DedicatedWorkerGlobalScope` -> `WorkerNavigator` there to be the `seviceWorker` property for the `ServiceWorkerContainer`. ```js // Inside web-worker.js async function postMessageToServiceWorker() { const reg = await self.navigator.serviceWorker.getRegistration(); // <-- throws exception, 'serviceWorker' undefined reg.active.postMessage({ some: 'message' }); } ``` According to [the spec](https://w3c.github.io/ServiceWorker/#serviceworkercontainer), I think this is supposed to be populated? But I haven't found a clear answer one way or another. ![image](https://user-images.githubusercontent.com/7726025/98025654-d76a6d00-1dbe-11eb-8c51-ebef8ddfdf5c.png) Is this just a browser compatibility bug? Is there a clear answer to whether or not the `ServiceWorkerContainer` is supposed to be available in Web Workers? I tried testing in Chromium Edge, Chrome, and Firefox latest. -- You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/w3c/ServiceWorker/issues/1552
Received on Tuesday, 3 November 2020 18:29:20 UTC