Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions request-blocklist/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Request Blocklist tests

## Intro

These are test cases for the Request Blocklist feature, that lets us block
requests where necessary, e.g. to fix website breakage. There are also test
cases included for how the Request Blocking feature interacts with other
features such as the Tracker Allowlist and the Tracker Blocklist.


## Files

```
.
├── config-reference.json # Reference configuration.
├── surrogates-reference.txt # Reference surrogates.txt
├── tds-reference.json # Reference Tracker Blocklist.
├── tests.json # The test cases.
└── user-allowlist-reference.json # Reference list of user-allowlisted domains.
```


## Test structure

```js
{
// Test name
"name": "matching rule, <all> domains",

// Details of the test request
"requestUrl": "https://request-blocklist.example/block",
"requestType": "image",
"websiteUrl": "https://website.example",

// Expected action (either "block" or "allow")
"expectAction": "block"

// Platform exceptions for the test
"exceptPlatforms": []
}
```
151 changes: 151 additions & 0 deletions request-blocklist/config-reference.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
{
"version": 1,
"features": {
"contentBlocking": {
"state": "enabled",
"exceptions": [
{
"domain": "content-blocking-exception.example",
"reason": "Example content blocking exception"
}
]
},
"requestBlocklist": {
"state": "enabled",
"settings": {
"blockedRequests": {
"request-blocklist.example": {
"rules": [
{
"rule": "request-blocklist.example/block",
"domains": ["<all>"],
"reason": "Example all-domain blocking rule"
},
{
"rule": "request-blocklist.example/*/block",
"domains": ["<all>"],
"reason": "Example all-domain wildcard blocking rule"
},
{
"rule": "request-blocklist.example/sometimes-block",
"domains": ["sometimes.example", "subdomain.different.example"],
"reason": "Example domain-limited blocking rule"
},
{
"rule": "request-blocklist.example/.*/regex",
"domains": ["<all>"],
"reason": "Example rule incorrectly using regex syntax"
},
{
"rule": "request-blocklist.example/CASE",
"domains": ["<all>"],
"reason": "Example rule for case sensitive matching"
},
{
"rule": "||request-blocklist.example^adblock-filter",
"domains": ["<all>"],
"reason": "Example rule incorrectly using adblock filter syntax"
},
{
"rule": "request-blocklist.example/missing-prop",
"reason": "Example rule incorrectly missing domains property"
},
{
"rule": "request-blocklist.example/extra-prop",
"domains": ["<all>"],
"unknown": "value",
"reason": "Example rule incorrectly including unknown property"
},
{
"rule": "request-blocklist.example:3000/port-block",
"domains": ["<all>"],
"reason": "Example blocking rule with port part"
},
{
"rule": "request-blocklist.example:443/incorrect-port-block",
"domains": ["<all>"],
"reason": "Example blocking rule that incorrectly includes redundant port"
},
{
"rule": "request-blocklist.example/incorrect*query-part",
"domains": ["<all>"],
"reason": "Example blocking rule that incorrectly matches query string"
}
]
},
"subdomain.request-blocklist.example": {
"rules": [
{
"rule": "subdomain.request-blocklist.example/subdomain",
"domains": ["<all>"],
"reason": "Example tracker entry and blocking rule for subdomain"
}
]
},
"request-blocklist-ordering.example": {
"rules": [
{
"rule": "request-blocklist-ordering.example/block",
"domains": ["sometimes.example"],
"reason": "Example domain-specific blocking rule"
},
{
"rule": "request-blocklist-ordering.example/block/path",
"domains": ["<all>"],
"reason": "Example blocking rule with extra path part"
},
{
"rule": "request-blocklist-ordering.example/block",
"domains": ["<all>"],
"reason": "Example blocking rule that should still apply to all domains"
}
]
},
"tracker.example": {
"rules": [
{
"rule": "tracker.example/*.js",
"domains": ["<all>"],
"reason": "Example blocking rule that applies to tracking requests"
},
{
"rule": "tracker.example/block-first-party",
"domains": ["tracker.example"],
"reason": "Example blocking rule that applies to first-party requests"
}
]
}
}
},
"exceptions": [
{
"domain": "request-blocking-exception.example",
"reason": "Example request-blocking exception"
}
]
},
"trackerAllowlist": {
"state": "enabled",
"settings": {
"allowlistedTrackers": {
"request-blocklist.example": {
"rules": [
{
"rule": "request-blocklist.example/block",
"domains": ["allowlisted-website.example"],
"reason": "Example tracker allowlist entry"
}
]
}
},
"exceptions": []
}
}
},
"unprotectedTemporary": [
{
"domain": "unprotected-temporary.example",
"reason": "Unprotected temporary example"
}
]
}
4 changes: 4 additions & 0 deletions request-blocklist/surrogates-reference.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
tracker.example/noop.js application/javascript
(() => {
'use strict';
})();
42 changes: 42 additions & 0 deletions request-blocklist/tds-reference.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
"trackers": {
"tracker.example": {
"domain": "tracker.example",
"owner": {
"name": "Example Entity",
"displayName": "Example Entity"
},
"prevalence": 0,
"fingerprinting": 0,
"cookies": 0,
"categories": [],
"default": "ignore",
"rules": [
{
"rule": "tracker.example/analytics.js",
"surrogate": "noop.js",
"fingerprinting": 0,
"cookies": 0
},
{
"rule": "tracker.example/block.js",
"fingerprinting": 0,
"cookies": 0
}
]
}
},
"entities": {
"Example Entity": {
"domains": ["tracker.example"],
"prevalence": 0,
"displayName": "Example Entity"
}
},
"domains": {
"tracker.example": "Example Entity"
},
"cnames": {
"tracker.example": "tracker-example.cname.example"
}
}
Loading
Loading