Update: Declarative Net Request available on Stable from M84.

610 views
Skip to first unread message

Karan Bhatia

unread,
Jun 15, 2020, 5:50:30 PM6/15/20
to Chromium Extensions
Hi,

The declarativeNetRequest API will be available on Stable starting M84 (current Beta channel). Please feel free to experiment with the API and file any bugs or feature requests. 

Still to come:
- Header modification support
- Changes to rule limits as described at https://blog.chromium.org/2019/06/web-request-and-declarative-net-request.html. We'll send a more concrete proposal on this soon.

Thanks, 
Karan

Jackie Han

unread,
Jul 18, 2020, 8:33:45 PM7/18/20
to Karan Bhatia, Chromium Extensions
I wrote a few static rules manually to try this new api. And thought of a few issues:
  • Handwriting rule's id and priority is a bit tedious. Especially for rule id, why can’t it be generated automatically, since each rule is unique naturally.
  • JSON files can't support comments, but I need a name and/or description for every rule. Otherwise I can’t remember the purpose of the rule.
Maybe I need a generator tool for editing and generating static rules to solve these issues?

--
You received this message because you are subscribed to the Google Groups "Chromium Extensions" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-extens...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-extensions/ebcba98f-aec5-4799-b5a7-2c2e96143215o%40chromium.org.


--
韩国恺(Jackie)

Jackie Han

unread,
Jul 20, 2020, 8:20:55 AM7/20/20
to Karan Bhatia, Chromium Extensions
Another common issue I found is service worker will intercept web request before declarativeNetRequest/webRequest api.
So declarativeNetRequest api can't redirect a web request if service worker intercepted(cached) that request. For example, https://developer.android.com/ use SW cache visited page, so declarativeNetRequest can't redirect that page to another url by refresh page but can redirect by force refresh page.
I think this is intentional by design.
--
Jackie Han

wOxxOm

unread,
Jul 20, 2020, 1:25:49 PM7/20/20
to Chromium Extensions, Jackie Han, Chromium Extensions, karan...@chromium.org
Hmm, I'd say this a bug because AFAIK the classic webRequest can intercept requests made/handled by a site's service worker e.g. https://crbug.com/1012977 recently fixed a similar bug with webRequest.

Karan Bhatia

unread,
Jul 20, 2020, 9:37:51 PM7/20/20
to Chromium Extensions, han.g...@gmail.com, karan...@chromium.org
Handwriting rule's id and priority is a bit tedious. Especially for rule id, why can’t it be generated automatically, since each rule is unique naturally.
Some of the API functions/events return the matched rule ID. Hence we want developers to specify it.

Maybe I need a generator tool for editing and generating static rules to solve these issues?
Yeah it might make sense to write a simple script to generate rulesets.

Another common issue I found is service worker will intercept web request before declarativeNetRequest/webRequest api.
Yeah that is true. The declarativeNetRequest/webRequest APIs are meant to be abstraction of the network stack. So if a SW intercepts a request and returns a cached response, preventing the request from going to the network, the APIs won't see the request.

Hmm, I'd say this a bug because AFAIK the classic webRequest can intercept requests made/handled by a site's service worker e.g. https://crbug.com/1012977 recently fixed a similar bug with webRequest.
In the bug you cite, the SW had an empty fetch listener, hence the request goes to the network and is seen by the extension APIs. There are no differences between webRequest and dNR in the handling of such requests.

Jackie Han

unread,
Jul 21, 2020, 2:11:02 AM7/21/20
to Karan Bhatia, Chromium Extensions
Thanks for your explanation.



--
Jackie Han
Reply all
Reply to author
Forward
0 new messages