Service Workers missing from Chrome Extension APIs

1,171 views
Skip to first unread message

Thomas Gallagher

unread,
Aug 23, 2018, 3:24:03 PM8/23/18
to Chromium-Extensions-Announce
It seems to me that Service Workers are operating in a blind spot for Chrome Extensions.

If I am using the webRequest API, any requests for main_frame or sub-resources that are served by a Service Worker are invisible, much like requests served from the Chrome cache.

As Service Workers become more common, this means that the webRequest API becomes increasingly irrelevant for cancelling / redirecting web requests.

It would be good if these requests could at least be reported by the extension APIs, even if blocking or redirecting proves to be more difficult.

Apologies if I am speaking out of turn but I can't see any way to deal with Service Workers at the moment, short of injecting a content script and interfering with the Service Worker itself, which is unsatisfactory.

Devlin Cronin

unread,
Aug 23, 2018, 4:16:56 PM8/23/18
to Chromium-Extensions-Announce
I agree with this that we would, ideally, add full support for intercepting or modifying service worker requests in extensions.  It could be a bit tricky to figure out, though, since there's definitely some fun edge cases.  Would you mind filing a bug at https://crbug.com/new, and pasting the link here?  We can continue the discussion there, and see what we can come up with.

Cheers,
- Devlin

Andreas0607

unread,
Aug 23, 2018, 4:22:03 PM8/23/18
to Chromium-Extensions-Announce
This is a problem that is not just for serviceworkers, but for all workers. My understanding is that because the chrome webrequest API does not catch dynamically loaded objects, the workers won't get scanned. I have already created a bug report for this, and I think I found what code needs to be added to change it. However Google seems reluctant to answer. You can look at the issue that I created here: https://bugs.chromium.org/p/chromium/issues/detail?id=872297

Thomas Gallagher

unread,
Aug 23, 2018, 5:59:56 PM8/23/18
to Chromium-Extensions-Announce
I've taken a look at the issue you linked. We're talking about slightly different things. I would like to find a way of monitoring web requests that are served to the browser by the Service Worker from its cache. I'm not trying to monitor the creation of the Service Worker, or a normal worker, as in your example. I hadn't even thought about that. Are you sure that the absence of 'blob' from the scheme is the problem? One way to do this for you might be to run a content script in the page that listened for the creation of a worker, then reported it to the background script via messaging. Although I notice on Stack Overflow you have a tumbleweed question out on this already. Have you tried all the resource types in web request - including "script""object""xmlhttprequest"or "other"?

Thomas Gallagher

unread,
Aug 23, 2018, 6:06:10 PM8/23/18
to Chromium-Extensions-Announce
Bug Report Filed here
Reply all
Reply to author
Forward
0 new messages