So the question is: What's the solution to needing access to chrome.* apis in a shared context between tabs?
You are right that an extension can literally do the same thing as a web page. But what I intended to convey with the analogy was:
joeshmoe.com's web page can do the things that
it normally has permission to do in a shared context. Extensions do not have that ability.
I disagree that my question would be better framed as "why is Chrome moving away from background pages". I'm not trying to relitigate that question :-).
My request is for an extension that has pages open to also have the ability to have a shared context between its open pages in which to do the things it can normally do, (chrome.*-y things). I'm not asking for persistence beyond that, although in our context, a slight delay of being allowed to live between the short closing of one tab and the opening of another may be important (and would be nicely covered by the current service worker lifetime implementation).
One solution to this would be to allow a service worker to stay open as long as an extension has web pages open that are connected to it.
For that matter, I think the general exception should be: Don't close the service worker if the extension has an actual page open (not a content script). You might argue that this could be abused, but it would require the extension to have a page open, which can already do all of these things, you aren't stopping any abuse by closing an extension's service worker when it has pages open, you're just preventing the extension from having a shared context to do work on behalf of those pages.
--
Don