Bug 207543

Summary: WKContentRuleList rules does not allow you to block ThirdParty cookies
Product: WebKit Reporter: Brandon <bthomas>
Component: WebKit APIAssignee: Nobody <webkit-unassigned>
Status: RESOLVED INVALID    
Severity: Enhancement CC: achristensen, beidson, krzysztof.modras, mjs, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: iPhone / iPad   
OS: iOS 13   
Attachments:
Description Flags
Example where it throws an error none

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"]