Open wanderview opened 7 years ago
I think we should do it for all events.
https://w3c.github.io/ServiceWorker/#handle-functional-event-algorithm covers it for "functional events", but "message" isn't one of those. We should be consistent here.
Hmm, I didn't realize this mechanism had been expanded beyond FetchEvent. Does chrome do this for other events yet?
Not sure about implementation. I'm looking at changing that functional event algorithm btw, but not that particular behaviour https://github.com/w3c/ServiceWorker/pull/1199
I just thought making event handlers observable at all was contentious so we limited it to fetch.
I don't have strong feelings here. Happy to make it just fetch.
Chrome just does the optimization for fetch currently.
Action: We should make this behaviour optional in the spec, but allow it for any top level event, including message
.
Action: As before. Make it a may.
Addressed in https://github.com/w3c/ServiceWorker/pull/1417
At https://github.com/whatwg/dom/pull/653 @annevk argues it should be limited to fetch or should be a must rather than a may.
Consider this code:
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?