Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proposal: allow webRequest with background.persistent: false / SW #148

Open
carlosjeurissen opened this issue Jan 20, 2022 · 11 comments
Open
Labels
implemented: firefox Implemented in Firefox inconsistency Inconsistent behavior across browsers proposal Proposal for a change or new feature topic: dnr Related to declarativeNetRequest

Comments

@carlosjeurissen
Copy link
Contributor

carlosjeurissen commented Jan 20, 2022

Currently the webRequest and webRequestBlocking permission require a persistent background page. This seems to be an arbitrary limitation. The proposal is to allow these APIs under a non-persistent / SW API as well.

Use cases are using this API in extension popups, or in contentScripts. The background-page doesn't need to keep running in the background for this to be useful.

Edit 2022-09-01: Firefox currently allows loading extensions with thewebRequest permission when persistent is set to false in mv2. In mv3, the persistent key is unsupported.

Related: a proposal for adding support for the webRequest API in non-persistent background pages has been added to the chrome issue tracker by @Rob--W https://bugs.chromium.org/p/chromium/issues/detail?id=447270

@Rob--W
Copy link
Member

Rob--W commented Jan 20, 2022

Could you clarify, why do you believe that this API requires a persistent background page? The use cases for extension popups/tabs sound reasonable, and I'd imagine the API to work in extensions without a background script (persistent or not).

I know that there were some technical reasons (implementation details) that prevented (blocking) webRequest from being supported in Chrome when event pages are enabled, but does this issue also extend to other browsers? Is this issue a bug report about Chrome, or is it broader than that?

@carlosjeurissen
Copy link
Contributor Author

@Rob--W Currently I'm not aware of any reasoning behind this. I can only speculate on that. Potentially it was seen that webRequest listeners would mostly make sense when they are constantly there. But that is not necessarily true.

@Rob--W
Copy link
Member

Rob--W commented Jan 21, 2022

..., but does this issue also extend to other browsers? Is this issue a bug report about Chrome, or is it broader than that?

@carlosjeurissen ^

@carlosjeurissen
Copy link
Contributor Author

@Rob--W Just tested in Safari on macOS and turns out just like in Google Chrome one cannot use the webRequest API with a non-persistent background page.

As for Mozilla Firefox, not sure what the current behaviour is with the WebRequest API and the limited event page (#134)

@Rob--W
Copy link
Member

Rob--W commented Feb 3, 2022

This topic came up during today's WECG meeting. Relevant part from the meeting notes (currently pending review, will be merged and published at https://github.com/w3c/webextensions/blob/main/_minutes/2022-02-03-wecg.md)

  • [timothy] webRequest is not supported in non-persistent background pages in Safari, because we looked at Chrome, which didn't support it either.

@tophf
Copy link

tophf commented Mar 6, 2022

Chrome didn't support webRequest in an event page because it wasn't exactly trivial to support waking up the event page and it would cause frequent restarts of the event page as such events tend to happen frequently.

The support for SW, which are conceptually the same as event pages, is being implemented currently in https://crbug.com/1024211, so there's no reason it can't be made to work with an event page. Note that webRequest + webRequestBlocking as optional permissions always worked in an event page while it was running, it just didn't wake up.

@carlosjeurissen
Copy link
Contributor Author

@tophf Thanks for clarifying! My use case for the webRequest API is only in non-background contexts. In which case it's a pity a permanent background page has to run for this to work.

@tophf
Copy link

tophf commented Mar 17, 2022

But you don't need the background script at all if you use webRequest only in a visible page.

@carlosjeurissen
Copy link
Contributor Author

@tophf correct! Yet Google Chrome doesn't allow loading an extension with the webRequest permission and a non-persistent background page at this moment.

@tophf
Copy link

tophf commented Mar 18, 2022

As I mentioned in my comment, all you need is to use optional permissions and it'll work with a non-persistent background script.

@xeenon xeenon added the proposal Proposal for a change or new feature label Aug 31, 2022
@carlosjeurissen carlosjeurissen added implemented: firefox Implemented in Firefox inconsistency Inconsistent behavior across browsers labels Sep 1, 2022
@carlosjeurissen
Copy link
Contributor Author

Firefox currently allows loading extensions with thewebRequest permission when persistent is set to false in mv2. In mv3, the persistent key is unsupported.

Related: a proposal for adding support for the webRequest API in non-persistent background pages has been added to the chrome issue tracker by @Rob--W https://bugs.chromium.org/p/chromium/issues/detail?id=447270

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
implemented: firefox Implemented in Firefox inconsistency Inconsistent behavior across browsers proposal Proposal for a change or new feature topic: dnr Related to declarativeNetRequest
Projects
None yet
Development

No branches or pull requests

4 participants