Bug 207543 - WKContentRuleList rules does not allow you to block ThirdParty cookies
Summary: WKContentRuleList rules does not allow you to block ThirdParty cookies
Status: RESOLVED INVALID
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKit API (show other bugs)
Version: WebKit Nightly Build
Hardware: iPhone / iPad iOS 13
: P2 Enhancement
Assignee: Nobody
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2020-02-11 06:42 PST by Brandon
Modified: 2020-03-19 16:45 PDT (History)
5 users (show)

See Also:


Attachments
Example where it throws an error (32.25 KB, application/zip)
2020-02-11 06:42 PST, Brandon
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Brandon 2020-02-11 06:42:56 PST
Created attachment 390362 [details]
Example where it throws an error

If you call `WKContentRuleStore.compileContentRuleList` with the rules:

```
[{
			"trigger": {
				"url-filter": ".*",
				"load-type": "thirdparty"
			},
			"action": {
				"type": "block-cookies"
			}
		}]
```

It will say `"Error Domain=WKErrorDomain Code=6 "(null)" UserInfo={NSHelpAnchor=Rule list compilation failed: Invalid trigger flags array.}"`

Because the `load-type` is set to `thirdparty` for `block-cookies` action type. Sample application uploaded.

Expected Behaviour: Should allow developers to block ThirdParty cookies using the content rules list because WKWebView's HTTPCookieStore set to `never` does NOT work.
Comment 1 Radar WebKit Bug Importer 2020-02-11 09:25:09 PST
<rdar://problem/59350850>
Comment 2 Maciej Stachowiak 2020-02-19 02:27:00 PST
Do you specifically want to do it this way, or would a WKWebView preference to block all third-party cookies (as requested elsewhere) do the trick?

(This does seem like a strange limitation. Blocking cookies for third-party loads using content blockers may be complicated by the fact that redirects can alter third-party-ness.)
Comment 3 Krzysztof Jan Modras [:chrmod] 2020-02-19 02:39:12 PST
Having a configuration option on WKWebView would work fine in Cliqz perspective. 
Would WKPreferences `thirdPartyCookiesEnabled` make sense?
Comment 4 Alex Christensen 2020-03-19 16:45:35 PDT
As documented in https://developer.apple.com/documentation/safariservices/creating_a_content_blocker you need to make at least two changes:
"load-type": "thirdparty"
needs to be changed to 
"load-type": ["third-party"]