@duckduckgo/autoconsent 14.95.1 → 14.96.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.agents/skills/proxy-testing/SKILL.md +122 -0
- package/.agents/skills/proxy-testing/scripts/regional-proxy.mjs +599 -0
- package/.claude/skills/proxy-testing/SKILL.md +6 -0
- package/AGENTS.md +3 -3
- package/CHANGELOG.md +16 -0
- package/dist/addon-firefox/background.bundle.js +298 -43
- package/dist/addon-firefox/manifest.json +1 -1
- package/dist/addon-firefox/popup.bundle.js +298 -43
- package/dist/addon-mv3/background.bundle.js +298 -43
- package/dist/addon-mv3/manifest.json +1 -1
- package/dist/addon-mv3/popup.bundle.js +298 -43
- package/dist/autoconsent.extra.cjs.js +309 -49
- package/dist/autoconsent.extra.esm.js +298 -43
- package/package.json +1 -1
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: proxy-testing
|
|
3
|
+
description: Test autoconsent via regional proxies in Playwright. Use when verifying rule changes across regions (US, EU, UK, etc.), or investigating region-dependent CMP behavior.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Proxy Testing
|
|
7
|
+
|
|
8
|
+
All rule changes must be tested across ALL supported geographic regions to catch regional popup variations. This skill provides a JS library to run autoconsent via regional proxies in Playwright.
|
|
9
|
+
|
|
10
|
+
Important! Autoconsent results can have false positives. When testing, always inspect the screenshots and confirm that opt-out was successful.
|
|
11
|
+
|
|
12
|
+
## Prerequisites
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
npm run prepublish # builds dist/autoconsent.playwright.js and rules/rules.json
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
Environment variables:
|
|
19
|
+
|
|
20
|
+
- `REGIONAL_PROXY_<TWO_LETTER_REGION_CODE>` (for example, `REGIONAL_PROXY_US`, `REGIONAL_PROXY_GB`, `REGIONAL_PROXY_AU`, etc.) - the domain endpoint
|
|
21
|
+
- `REGIONAL_PROXY_USERNAME`
|
|
22
|
+
- `REGIONAL_PROXY_PASSWORD`
|
|
23
|
+
|
|
24
|
+
- Endpoints must be bare hostnames: no scheme, credentials, or port.
|
|
25
|
+
- The library adds `https://` and port `443`.
|
|
26
|
+
- Credentials are shared across regions.
|
|
27
|
+
|
|
28
|
+
## Usage
|
|
29
|
+
|
|
30
|
+
Test one URL:
|
|
31
|
+
|
|
32
|
+
```javascript
|
|
33
|
+
import { formatResult, testUrl } from './.agents/skills/proxy-testing/scripts/regional-proxy.mjs';
|
|
34
|
+
|
|
35
|
+
const result = await testUrl('https://www.wohnen.de/', 'de');
|
|
36
|
+
console.log(formatResult(result));
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
Test multiple regions:
|
|
40
|
+
|
|
41
|
+
```javascript
|
|
42
|
+
import { formatResult, testRegions } from './.agents/skills/proxy-testing/scripts/regional-proxy.mjs';
|
|
43
|
+
|
|
44
|
+
const results = await testRegions('https://www.wohnen.de/', ['us', 'de', 'fr']);
|
|
45
|
+
for (const result of results) {
|
|
46
|
+
console.log(formatResult(result));
|
|
47
|
+
}
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
Use an existing page:
|
|
51
|
+
|
|
52
|
+
```javascript
|
|
53
|
+
import { launchRegionalProxyBrowser, testPage } from './.agents/skills/proxy-testing/scripts/regional-proxy.mjs';
|
|
54
|
+
|
|
55
|
+
const browser = await launchRegionalProxyBrowser('de');
|
|
56
|
+
const page = await browser.newPage();
|
|
57
|
+
const result = await testPage(page, 'https://www.wohnen.de/', 'de');
|
|
58
|
+
await browser.close();
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
Get proxy config for Playwright Test:
|
|
62
|
+
|
|
63
|
+
```javascript
|
|
64
|
+
import { defineConfig } from '@playwright/test';
|
|
65
|
+
import { buildProxyConfig } from './.agents/skills/proxy-testing/scripts/regional-proxy.mjs';
|
|
66
|
+
|
|
67
|
+
export default defineConfig({
|
|
68
|
+
use: {
|
|
69
|
+
proxy: buildProxyConfig('us'),
|
|
70
|
+
},
|
|
71
|
+
});
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
## API
|
|
75
|
+
|
|
76
|
+
- `testUrl(url, regionKey, options?)` — test one URL in a single region; launches a proxied browser, runs autoconsent, returns a `TestResult`.
|
|
77
|
+
- `testRegions(url, regions?, options?)` — test one URL across several regions (defaults to all supported regions), a fresh browser per region; returns `TestResult[]`.
|
|
78
|
+
- `testPage(page, url, regionKey, options?)` — run a full test on a page you created yourself (you own the browser/context); returns a `TestResult`.
|
|
79
|
+
- `injectAutoconsent(page, options?)` — set up isolated-world injection; call before `page.goto()`. Returns a context (`received`, `hasMessage`, `waitForCompletion`, `waitForMessage`, `collectResult`).
|
|
80
|
+
- `buildProxyConfig(regionKey)` — build the Playwright `{ server, username, password }` proxy object for a region from its env vars.
|
|
81
|
+
- `launchRegionalProxyBrowser(regionKey, options?)` — launch a Chromium browser routed through the region's proxy.
|
|
82
|
+
- `formatResult(result)` — format a `TestResult` as a human-readable summary line.
|
|
83
|
+
|
|
84
|
+
Options (all optional):
|
|
85
|
+
|
|
86
|
+
- `action` — `'optOut'` (default), `'optIn'`, or `null` to only detect (no opt-out/opt-in performed).
|
|
87
|
+
- `screenshotsDir` — directory for the final screenshots (default: `test-results/regional-proxy`).
|
|
88
|
+
- `navigationTimeout` — `page.goto` timeout in ms (default `45000`).
|
|
89
|
+
- `completionTimeout` — max wait for autoconsent to finish opt-out/opt-in in ms (default `45000`).
|
|
90
|
+
- `detectionTimeout` — max wait for `cmpDetected` before giving up (default: `completionTimeout`).
|
|
91
|
+
- `headless` — run Chromium headless (default `true`).
|
|
92
|
+
- `launchOptions` — extra options merged into `chromium.launch()` (e.g. `args`); the regional `proxy` is always applied on top.
|
|
93
|
+
|
|
94
|
+
## Smoke Test
|
|
95
|
+
|
|
96
|
+
```javascript
|
|
97
|
+
import { launchRegionalProxyBrowser } from './.agents/skills/proxy-testing/scripts/regional-proxy.mjs';
|
|
98
|
+
|
|
99
|
+
const browser = await launchRegionalProxyBrowser('us');
|
|
100
|
+
|
|
101
|
+
const page = await browser.newPage();
|
|
102
|
+
await page.goto('https://api.ipify.org?format=json', { waitUntil: 'domcontentloaded', timeout: 30000 });
|
|
103
|
+
console.log(await page.textContent('body'));
|
|
104
|
+
await browser.close();
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
## Rule Checks
|
|
108
|
+
|
|
109
|
+
1. Run `npm run build-rules` after changing rule JSON.
|
|
110
|
+
2. Smoke-test each regional proxy.
|
|
111
|
+
3. Test in ALL supported regions.
|
|
112
|
+
4. Inspect screenshots, not just API results.
|
|
113
|
+
5. Reload after dismissal and confirm the rule does not keep matching, unless cosmetic-only.
|
|
114
|
+
|
|
115
|
+
## Gotchas
|
|
116
|
+
|
|
117
|
+
- Use Playwright's proxy auth object: `{ server, username, password }`.
|
|
118
|
+
- Never embed proxy credentials in URLs, command lines, logs, traces, or source.
|
|
119
|
+
- Call `injectAutoconsent(page)` before `page.goto()` so the init script is installed before page scripts run.
|
|
120
|
+
- The content script runs in an isolated world (via CDP) and `eval` snippets run in the page's main world, matching the extension. Chromium only.
|
|
121
|
+
- Use a fresh browser per region to avoid leaking proxy state, cookies, cache, or DNS.
|
|
122
|
+
- Some sites localize by more than IP; only add locale/geolocation settings intentionally.
|