Skip to content

Commit

Permalink
Add format tests for trackerAllowlist rules
Browse files Browse the repository at this point in the history
  • Loading branch information
GuiltyDolphin committed Nov 22, 2023
1 parent a3acc21 commit 341d66d
Show file tree
Hide file tree
Showing 3 changed files with 219 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -150,5 +150,149 @@
"site": "https://testsite.com",
"request": "http://a.b.c.videos.allowlist-tracker-2.com/a.js",
"isAllowlisted": true
},
{
"name": "format.test - supports unescaped slashes",
"site": "https://example.com",
"request": "https://format.test/test1.js",
"isAllowlisted": true
},
{
"name": "format.test - supports simple regexp - matching request",
"site": "https://example.com",
"request": "https://format.test/1/test2.js",
"isAllowlisted": true
},
{
"name": "format.test - supports simple regexp - nonmatching request",
"site": "https://example.com",
"request": "https://format.test/a/test2.js",
"isAllowlisted": false
},
{
"name": "format.test - supports simple wildcard regexp - matching request",
"site": "https://example.com",
"request": "https://format.test/abc/test3.js",
"isAllowlisted": true
},
{
"name": "format.test - supports simple wildcard regexp - nonmatching request",
"site": "https://example.com",
"request": "https://format.test/abc/test3a.js",
"isAllowlisted": false
},
{
"name": "format.test - supports CBR regexp - matching request (1)",
"site": "https://example.com",
"request": "https://format.test/aa123b.cdeffffg/test2b.js",
"isAllowlisted": true
},
{
"name": "format.test - supports CBR regexp - matching request (2)",
"site": "https://example.com",
"request": "https://format.test/ab.cd/test2b.js",
"isAllowlisted": true
},
{
"name": "format.test - supports CBR regexp - nonmatching request (1)",
"site": "https://example.com",
"request": "https://format.test/aa123b.cffffg/test2b.js",
"isAllowlisted": false
},
{
"name": "format.test - supports CBR regexp - nonmatching request (2)",
"site": "https://example.com",
"request": "https://format.test/ab1cd/test2b.js",
"isAllowlisted": false
},
{
"name": "format.test - with subdomain - match on sub subdomain",
"site": "https://example.com",
"request": "https://sub0.sub1.sub2.format.test/test4.js",
"isAllowlisted": true
},
{
"name": "format.test - with subdomain - don't match on just lower subdomain",
"site": "https://example.com",
"request": "https://sub1.format.test/test4.js",
"isAllowlisted": false
},
{
"name": "format.test - with subdomain - match on full subdomain",
"site": "https://example.com",
"request": "https://sub1.sub2.format.test/test4.js",
"isAllowlisted": true
},
{
"name": "format.test - with subdomain - don't match for incorrect subdomain",
"site": "https://example.com",
"request": "https://sub1nsub2.format.test/test4.js",
"isAllowlisted": false
},
{
"name": "format.test - with subdomain - don't match on incorrect subdomain",
"site": "https://example.com",
"request": "https://sub0.sub2.format.test/test4.js",
"isAllowlisted": false
},
{
"name": "format.test - with subdomain and regexp - match on sub subdomain",
"site": "https://example.com",
"request": "https://sub0.sub1.sub2.format.test/a/test4a.js",
"isAllowlisted": true
},
{
"name": "format.test - with subdomain and regexp - don't match on just lower subdomain",
"site": "https://example.com",
"request": "https://sub1.format.test/a/test4a.js",
"isAllowlisted": false
},
{
"name": "format.test - with subdomain and regexp - match on full subdomain",
"site": "https://example.com",
"request": "https://sub1.sub2.format.test/a/test4a.js",
"isAllowlisted": true
},
{
"name": "format.test - with subdomain and regexp - don't match for incorrect subdomain",
"site": "https://example.com",
"request": "https://sub1nsub2.format.test/a/test4a.js",
"isAllowlisted": false
},
{
"name": "format.test - with subdomain and regexp - don't match on incorrect subdomain",
"site": "https://example.com",
"request": "https://sub0.sub2.format.test/a/test4a.js",
"isAllowlisted": false
},
{
"name": "format.test - domain in rule - match on full request",
"site": "https://example.com",
"request": "https://sub1.format.test/sub2.format.test/test4b.js",
"isAllowlisted": true
},
{
"name": "format.test - domain in rule - don't match the inner request",
"site": "https://example.com",
"request": "https://sub2.format.test/test4b.js",
"isAllowlisted": false
},
{
"name": "format.test - no escape on domain - matching request",
"site": "https://example.com",
"request": "https://format.test/test5.js",
"isAllowlisted": true
},
{
"name": "format.test - no escape on subdomain - match with periods",
"site": "https://example.com",
"request": "https://sub1.sub2.format.test/test6.js",
"isAllowlisted": true
},
{
"name": "format.test - no escape on subdomain - match with replacements",
"site": "https://example.com",
"request": "https://sub1asub2.format.test/test6.js",
"isAllowlisted": true
}
]
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@
"domains": ["<all>"],
"reason": "match all sites and all paths"
},
{
"rule": "allowlist-tracker-2.com/login.js",
"domains": ["<all>"],
"reason": "match single resource on all sites"
},
{
"rule": "allowlist-tracker-2.com/login.js",
"domains": ["<all>"],
Expand All @@ -40,6 +45,55 @@
"reason": "match all requests"
}
]
},
"format.test": {
"rules": [
{
"rule": "format\\.test/test1\\.js",
"reason": "Unescaped slash should be allowed.",
"domains": ["<all>"]
},
{
"rule": "format\\.test/[0-9]+/test2\\.js",
"reason": "Simple regexp",
"domains": ["<all>"]
},
{
"rule": "format\\.test/.*/test3\\.js",
"reason": "Simple regexp wildcard",
"domains": ["<all>"]
},
{
"rule": "format\\.test/a.*.\\.[c]([de]+)f*g?/test2b\\.js",
"reason": "Simple regexp (full CBR), see https://developer.apple.com/documentation/safariservices/creating_a_content_blocker#3030754",
"domains": ["<all>"]
},
{
"rule": "sub1\\.sub2\\.format\\.test/test4\\.js",
"reason": "With subdomain",
"domains": ["<all>"]
},
{
"rule": "sub1\\.sub2\\.format\\.test/[abc]/test4a\\.js",
"reason": "With subdomain and regexp",
"domains": ["<all>"]
},
{
"rule": "sub1\\.format\\.test/sub2\\.format\\.test/test4b\\.js",
"reason": "Domain in rule",
"domains": ["<all>"]
},
{
"rule": "format.test/test5\\.js",
"reason": "No escape on the domain.",
"domains": ["<all>"]
},
{
"rule": "sub1.sub2.format.test/test6\\.js",
"reason": "No escape on the domain with subdomain.",
"domains": ["<all>"]
}
]
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,18 @@
"cookies": 0.1,
"categories": [],
"default": "block"
},
"format.test": {
"domain": "format.test",
"owner": {
"name": "Tests for formatting",
"displayName": "Tests for formatting"
},
"prevalence": 0.1,
"fingerprinting": 3,
"cookies": 0.1,
"categories": [],
"default": "block"
}
},
"entities": {
Expand All @@ -52,6 +64,13 @@
],
"prevalence": 0.1,
"displayName": "Test Site for Tracker Blocking"
},
"Tests for formatting": {
"domains": [
"format.test"
],
"prevalence": 0.1,
"displayName": "Tests for formatting"
}
},
"cnames": {
Expand All @@ -60,6 +79,7 @@
"domains": {
"allowlist-tracker-1.com": "Test Site for Tracker Blocking",
"allowlist-tracker-2.com": "Test Site for Tracker Blocking",
"allowlist-tracker-3.com": "Test Site for Tracker Blocking"
"allowlist-tracker-3.com": "Test Site for Tracker Blocking",
"format.test": "Tests for formatting"
}
}

0 comments on commit 341d66d

Please sign in to comment.