Skip to content

Commit

Permalink
Validate that third party trackers load correctly (#1938)
Browse files Browse the repository at this point in the history
* Validate that third party trackers load correctly

Requires:
duckduckgo/privacy-test-pages#158

* Bump privacy-test-pages dep
  • Loading branch information
jonathanKingston authored Apr 28, 2023
1 parent c092c75 commit 464ce77
Show file tree
Hide file tree
Showing 4 changed files with 158 additions and 42 deletions.
19 changes: 19 additions & 0 deletions integration-test/data/configs/storage-blocking.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,23 @@
{
"globalThis.dbg.tds.config.features.trackerAllowlist": {
"state": "enabled",
"exceptions": [ ],
"settings": {
"allowlistedTrackers": {
"ad-company.site": {
"rules": [
{
"rule": "convert.ad-company.site",
"domains": [
"<all>"
],
"reason": "Validation of the cookie rules and not blocking"
}
]
}
}
}
},
"globalThis.dbg.tds.config.features.trackingCookies3p": {
"state": "enabled",
"exceptions": [ ],
Expand Down
11 changes: 11 additions & 0 deletions integration-test/storage-blocking.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { routeFromLocalhost } from './helpers/testPages'
const testPageDomain = 'privacy-test-pages.glitch.me'
const thirdPartyDomain = 'good.third-party.site'
const thirdPartyTracker = 'broken.third-party.site'
const thirdPartyAd = 'convert.ad-company.site'

async function waitForAllResults (page) {
while ((await page.$$('#tests-details > li > span > ul')).length < 2) {
Expand Down Expand Up @@ -40,6 +41,11 @@ test.describe('Storage blocking Tests', () => {
thirdparty_firstparty_headerdata: expectUnmodified('allows 1st party HTTP cookies from non-tracker frames'),
jsdata: expectUnmodified('does not block 3rd party JS cookies not on block list')
},
[thirdPartyAd]: {
top_thirdparty_headerdata: expectUnmodified('allows 3rd party HTTP cookies not on block list'),
thirdparty_firstparty_headerdata: expectUnmodified('allows 1st party HTTP cookies from non-tracker frames'),
jsdata: expectUnmodified('does not block 3rd party JS cookies not on block list')
},
[thirdPartyTracker]: {
thirdpartytracker_thirdparty_headerdata: expectUnmodified('allows 3rd party tracker HTTP cookies from tracker frames'),
top_tracker_headerdata: expectBlocked('blocks 3rd party HTTP cookies for trackers'),
Expand All @@ -55,6 +61,11 @@ test.describe('Storage blocking Tests', () => {
if (jsCookies.has(cookie.name)) {
expect(cookie.expires - nowSeconds).toBeGreaterThan(0)
expect(cookie.expires - nowSeconds).toBeLessThan(604800)
if (cookie.domain === thirdPartyTracker) {
expect(cookie.expires - nowSeconds, `cookie expires for ${cookie.domain}`).toBeLessThan(86400)
} else if (cookie.domain === thirdPartyAd) {
expect(cookie.expires - nowSeconds, `cookie expires for ${cookie.domain}`).toBeGreaterThan(86400)
}
}
}
})
Expand Down
168 changes: 127 additions & 41 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@
"is-plain-object": "5.0.0",
"jquery": "3.6.4",
"normalize.scss": "0.1.0",
"privacy-test-pages": "github:duckduckgo/privacy-test-pages#1.1.0",
"privacy-test-pages": "github:duckduckgo/privacy-test-pages#1.2.0",
"punycode": "2.3.0",
"seedrandom": "^3.0.5",
"tldts": "^6.0.3",
Expand Down

0 comments on commit 464ce77

Please sign in to comment.