[w3c/ServiceWorker] is the browser required to start the ServiceWorker for postMessage() if there is no message event handler? (#1200)

Consider this code:

```
// main window script
let bc = new BroadcastChannel('sw_side_channel');
sw.onmessage = evt => console.log('service worker started up');
navigator.serviceWorker.controller.postMessage('ping');

// service worker script
let bc = new BroadcastChannel('sw_side_channel');
bc.postMessage('pong');
self.onmessage = null;  // no direct message event handler
```

Is the browser required to start the service worker if its not running and a postMessage() is fired at while there is no message event handler?  Worker startup is observable thanks to things like BroadcastChannel or Clients API.

Or can the browser do similar optimizations like we do for FetchEvent where we don't start the worker if there is no message handler?

-- 
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/1200

Received on Monday, 25 September 2017 13:58:02 UTC