Bug 205720 - WKUserContentController Block rules introspection
Summary: WKUserContentController Block rules introspection
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKit2 (show other bugs)
Version: Safari 13
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2020-01-03 05:42 PST by Krzysztof Jan Modras [:chrmod]
Modified: 2021-05-28 07:41 PDT (History)
6 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Krzysztof Jan Modras [:chrmod] 2020-01-03 05:42:47 PST
WKWebView provides no way to introspect what is blocked by the Block Rules. 
This, firstly, makes it more difficult to debug rules, as we cannot be sure if a rule matches the intended url, or if a particular rule is too aggressive and matching too many urls. 
Secondly, most browser using this feature like to include a counter to show how many requests were blocked on a specific page.
Currently, in Firefox and Cliqz, this is implemented by a UserScript that tries to collect urls from the document and re-match against a blocklist in the app (which is both inefficient and imprecise).

Introspection API would be helpful to detect the breakage introduced by blocking rules.
Comment 1 Radar WebKit Bug Importer 2020-01-03 20:22:15 PST
<rdar://problem/58312877>
Comment 2 Maciej Stachowiak 2020-02-19 02:41:43 PST
To be clear, you're asking for WKWebView API for this, for the embedding app, rather than exposing this to content blocker extensions?
Comment 3 Krzysztof Jan Modras [:chrmod] 2020-02-19 03:08:33 PST
Correct, our context is a privacy oriented web browser.

For example it would be useful to ask WKContentRuleListStore if the given URL will be blocked.

This is partially related to https://bugs.webkit.org/show_bug.cgi?id=152598#c9

Not sure how this would work for content blocking extensions. Perhaps Andrey Meshkov can provide some insights on it.
Comment 4 Andrey Meshkov 2020-02-19 03:28:22 PST
Well, if WKContentRuleListStore would provide a "checkRequest" method, we could benefit from this as well. For instance, we could add a simple "rule testing" tool right in the app.