Bug 154811 - Feature request: add "xmlhttprequest" resource type for content blockers
Summary: Feature request: add "xmlhttprequest" resource type for content blockers
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKit Misc. (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2016-02-29 02:13 PST by Andrey Meshkov
Modified: 2020-02-19 21:35 PST (History)
5 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Andrey Meshkov 2016-02-29 02:13:13 PST
Currently there is no way to distinguish XHR requests from other requests, yet it may be very useful for ad blocking.

For instance, ad blocking on speedtest.net involves blocking scripts and XHR requests
|http://$script,xmlhttprequest,domain=speedtest.net
|https://$script,xmlhttprequest,domain=speedtest.net
Comment 1 Radar WebKit Bug Importer 2019-04-11 22:54:04 PDT
<rdar://problem/49841405>
Comment 2 Alex Christensen 2019-04-15 13:09:20 PDT
I assume this would still package xhr and fetch together, right?  We wouldn't want to block xhr but not fetch.
Comment 3 Andrey Meshkov 2019-04-15 13:34:21 PDT
Hi Alex, I can't think of any case when distinguishing fetch from xhr would be useful.
Comment 4 Maciej Stachowiak 2020-02-18 22:50:01 PST
What type do XHR and Fetch currently show up as? "raw"? Or are they not blockable?
Comment 5 Andrey Meshkov 2020-02-18 23:56:57 PST
They show up as "raw".
Comment 6 Maciej Stachowiak 2020-02-19 02:30:08 PST
I guess it's worthwhile to distinguish from other "raw" types such as WebSockets? Perhaps every distinct use of "raw" should also have a more specific type. (For compatibility reasons "raw" would likely remain defined as it is currently.)
Comment 7 Andrey Meshkov 2020-02-19 03:47:10 PST
> I guess it's worthwhile to distinguish from other "raw" types such as WebSockets? Perhaps every distinct use of "raw" should also have a more specific type. (For compatibility reasons "raw" would likely remain defined as it is currently.)

To be honest, I wanted to request a distinct request type for websocket as well.

WebSockets are often used by adblocking circumvention scripts and this would be really useful to be able to distinguish them.

For instance, there are a couple of rules in EasyList that block WebSocket connections on >300 websites.
Comment 8 Andrey Meshkov 2020-02-19 03:54:24 PST
Oh, and there's another feature request - about "subdocument" resource type: https://bugs.webkit.org/show_bug.cgi?id=153559

Should I merge them all in one?

The final list of resource types we'd like to have is:
* "subdocument" -- for non-top-level frames
* "xmlhttprequest" -- fetch/xhr
* "websocket"
Comment 9 Maciej Stachowiak 2020-02-19 21:35:01 PST
No need to merge (unless somebody wants to add all of them in a single patch).

If anyone wants to post a patch for this, some thoughts:

- The type should probably be named "fetch" rather than "xmlhttprequest", better to name it after the modern API than the legacy version.
- We likely need to keep "raw" matching everything it does not, so the xhr/fetch and web socket types would have to be synonyms for subsets of "raw". I believe we already did this with "ping", so there should be an example to follow.
- Same thing for "subdocument" being a subset of "document" (maybe this means we would need a separate "main-document"?)