Re: [ServiceWorker] Clients & postMessage (#609)

Update:

We're in agreement that `serviceWorkerInstance.postMessage` should land at `self.onmessage` within the ServiceWorker. The `messageEvent.source` will be an instance of `WindowClient` or `Client` depending on the sender.

`clientInstance.postMessage` will land at `navigator.serviceWorker.onmessage`. The `messageEvent.source` will be an instance of `ServiceWorker` representing the sender.

This changes what Chrome has already shipped, but it gives us a sensible place to land messages in SharedWorkers, and doesn't overload `window.onmessage`.

I don't think this can be specced in terms of ports, as it isn't 1:1 (both `onmessage` destinations can receive messages from multiple sources). The spec for [BroadcastChannel](https://html.spec.whatwg.org/multipage/comms.html#broadcasting-to-other-browsing-contexts) will be a good reference, as it does something similar, although less specific.

@jungkees do you have any time to have a go at specing this? I'm snowed under with talk-writing :(

---
Reply to this email directly or view it on GitHub:
https://github.com/slightlyoff/ServiceWorker/issues/609#issuecomment-74714928

Received on Tuesday, 17 February 2015 17:50:25 UTC