Skip to content

Commit a84135f

Browse files
Merge branch 'main' into diego/support-website-notifications
2 parents 6b6a332 + 9561b9c commit a84135f

File tree

11 files changed

+573
-0
lines changed

11 files changed

+573
-0
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"readme": "This config tests that uaChBrands can override navigator.userAgentData brands",
3+
"version": 1,
4+
"unprotectedTemporary": [],
5+
"features": {
6+
"uaChBrands": {
7+
"state": "enabled",
8+
"exceptions": []
9+
}
10+
}
11+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"readme": "This config tests domain-specific brand overrides using conditionalChanges",
3+
"version": 1,
4+
"unprotectedTemporary": [],
5+
"features": {
6+
"uaChBrands": {
7+
"state": "enabled",
8+
"exceptions": [],
9+
"settings": {
10+
"conditionalChanges": [
11+
{
12+
"domain": "localhost",
13+
"patchSettings": [
14+
{
15+
"op": "add",
16+
"path": "/brandName",
17+
"value": "Netscape Navigator"
18+
}
19+
]
20+
}
21+
]
22+
}
23+
}
24+
}
25+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"readme": "Test config with overrideEdge disabled but filterWebView2 enabled (default)",
3+
"version": 1,
4+
"unprotectedTemporary": [],
5+
"features": {
6+
"uaChBrands": {
7+
"state": "enabled",
8+
"exceptions": [],
9+
"settings": {
10+
"overrideEdge": "disabled"
11+
}
12+
}
13+
}
14+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<meta charset="utf-8">
5+
<meta name="viewport" content="width=device-width">
6+
<title>UA CH Brands</title>
7+
<link rel="stylesheet" href="../shared/style.css">
8+
</head>
9+
<body>
10+
<p><a href="../index.html">[Home]</a></p>
11+
12+
<p>UA CH Brands</p>
13+
<ul>
14+
<li><a href="./pages/brand-override.html">Brand Override</a> - <a href="./config/brand-override.json">Config</a></li>
15+
</ul>
16+
</body>
17+
</html>
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<meta charset="utf-8">
5+
<meta name="viewport" content="width=device-width">
6+
<title>UA CH Brands - Brand Override</title>
7+
<link rel="stylesheet" href="../../shared/style.css">
8+
</head>
9+
<body>
10+
<script src="../../shared/utils.js"></script>
11+
<p><a href="../index.html">[UA CH Brands]</a></p>
12+
13+
<p>This page verifies that navigator.userAgentData overwrites the UA CH brands to match the Sec-CH-UA header when the uaChBrands feature is enabled.</p>
14+
15+
<script>
16+
test('Brand override', async () => {
17+
const results = [];
18+
19+
if (navigator.userAgentData && navigator.userAgentData.brands) {
20+
const brands = navigator.userAgentData.brands;
21+
const brandNames = new Set(brands.map(b => b.brand));
22+
23+
results.push({
24+
name: 'navigator.userAgentData.brands contains DuckDuckGo',
25+
result: brandNames.has('DuckDuckGo'),
26+
expected: true
27+
});
28+
29+
if (navigator.userAgentData.getHighEntropyValues) {
30+
try {
31+
const highEntropyValues = await navigator.userAgentData.getHighEntropyValues(['brands']);
32+
if (highEntropyValues.brands) {
33+
const heBrandNames = new Set(highEntropyValues.brands.map(b => b.brand));
34+
35+
results.push({
36+
name: 'navigator.userAgentData.getHighEntropyValues brands contains DuckDuckGo',
37+
result: heBrandNames.has('DuckDuckGo'),
38+
expected: true
39+
});
40+
}
41+
} catch (error) {
42+
results.push({
43+
name: 'getHighEntropyValues brands works',
44+
result: false,
45+
expected: true
46+
});
47+
}
48+
49+
try {
50+
const fullVersionData = await navigator.userAgentData.getHighEntropyValues(['fullVersionList']);
51+
if (fullVersionData.fullVersionList) {
52+
const fvlBrandNames = new Set(fullVersionData.fullVersionList.map(b => b.brand));
53+
54+
results.push({
55+
name: 'navigator.userAgentData.getHighEntropyValues fullVersionList contains DuckDuckGo',
56+
result: fvlBrandNames.has('DuckDuckGo'),
57+
expected: true
58+
});
59+
}
60+
} catch (error) {
61+
results.push({
62+
name: 'getHighEntropyValues fullVersionList works',
63+
result: false,
64+
expected: true
65+
});
66+
}
67+
}
68+
} else {
69+
results.push({
70+
name: 'navigator.userAgentData.brands available',
71+
result: false,
72+
expected: true
73+
});
74+
}
75+
76+
return results;
77+
});
78+
79+
renderResults();
80+
</script>
81+
</body>
82+
</html>
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<meta charset="UTF-8">
5+
<title>UA-CH-Brands: Domain Brand Override Test</title>
6+
</head>
7+
<body>
8+
<h1>UA-CH-Brands Domain Brand Override Test</h1>
9+
<div id="results"></div>
10+
11+
<script type="module">
12+
const results = [];
13+
14+
if (navigator.userAgentData?.brands) {
15+
const brands = navigator.userAgentData.brands;
16+
const netscapeCount = brands.filter(b => b.brand === 'Netscape Navigator').length;
17+
const ddgCount = brands.filter(b => b.brand === 'DuckDuckGo').length;
18+
19+
results.push({
20+
test: 'brands-contains-netscape',
21+
result: netscapeCount > 0 ? 'PASS' : 'FAIL',
22+
details: `Found ${netscapeCount} Netscape Navigator brand(s)`
23+
});
24+
25+
results.push({
26+
test: 'brands-no-duckduckgo',
27+
result: ddgCount === 0 ? 'PASS' : 'FAIL',
28+
details: `Found ${ddgCount} DuckDuckGo brand(s) (expected 0)`
29+
});
30+
}
31+
32+
if (navigator.userAgentData?.getHighEntropyValues) {
33+
try {
34+
const highEntropy = await navigator.userAgentData.getHighEntropyValues(['brands']);
35+
if (highEntropy.brands) {
36+
const brands = highEntropy.brands;
37+
const netscapeCount = brands.filter(b => b.brand === 'Netscape Navigator').length;
38+
const ddgCount = brands.filter(b => b.brand === 'DuckDuckGo').length;
39+
40+
results.push({
41+
test: 'getHighEntropyValues-brands-contains-netscape',
42+
result: netscapeCount > 0 ? 'PASS' : 'FAIL',
43+
details: `Found ${netscapeCount} Netscape Navigator brand(s) in getHighEntropyValues brands`
44+
});
45+
46+
results.push({
47+
test: 'getHighEntropyValues-brands-no-duckduckgo',
48+
result: ddgCount === 0 ? 'PASS' : 'FAIL',
49+
details: `Found ${ddgCount} DuckDuckGo brand(s) in getHighEntropyValues brands (expected 0)`
50+
});
51+
}
52+
} catch (e) {
53+
results.push({
54+
test: 'getHighEntropyValues-brands-error',
55+
result: 'ERROR',
56+
details: e.message
57+
});
58+
}
59+
}
60+
61+
if (navigator.userAgentData?.getHighEntropyValues) {
62+
try {
63+
const highEntropy = await navigator.userAgentData.getHighEntropyValues(['fullVersionList']);
64+
if (highEntropy.fullVersionList) {
65+
const fvl = highEntropy.fullVersionList;
66+
const netscapeCount = fvl.filter(b => b.brand === 'Netscape Navigator').length;
67+
const ddgCount = fvl.filter(b => b.brand === 'DuckDuckGo').length;
68+
69+
results.push({
70+
test: 'fullVersionList-contains-netscape',
71+
result: netscapeCount > 0 ? 'PASS' : 'FAIL',
72+
details: `Found ${netscapeCount} Netscape Navigator brand(s) in fullVersionList`
73+
});
74+
75+
results.push({
76+
test: 'fullVersionList-no-duckduckgo',
77+
result: ddgCount === 0 ? 'PASS' : 'FAIL',
78+
details: `Found ${ddgCount} DuckDuckGo brand(s) in fullVersionList (expected 0)`
79+
});
80+
}
81+
} catch (e) {
82+
results.push({
83+
test: 'fullVersionList-error',
84+
result: 'ERROR',
85+
details: e.message
86+
});
87+
}
88+
}
89+
90+
window.results = results;
91+
92+
const resultsDiv = document.getElementById('results');
93+
resultsDiv.innerHTML = '<pre>' + JSON.stringify(results, null, 2) + '</pre>';
94+
</script>
95+
</body>
96+
</html>
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<meta charset="UTF-8">
5+
<title>UA-CH-Brands: Override Edge Disabled Test</title>
6+
</head>
7+
<body>
8+
<h1>UA-CH-Brands Override Edge Disabled Test</h1>
9+
<div id="results"></div>
10+
11+
<script type="module">
12+
const results = [];
13+
14+
if (navigator.userAgentData?.brands) {
15+
const brands = navigator.userAgentData.brands;
16+
const ddgCount = brands.filter(b => b.brand === 'DuckDuckGo').length;
17+
18+
results.push({
19+
test: 'brands-no-duckduckgo',
20+
result: ddgCount === 0 ? 'PASS' : 'FAIL',
21+
details: `Found ${ddgCount} DuckDuckGo brand(s) (expected 0 - overrideEdge disabled)`
22+
});
23+
}
24+
25+
if (navigator.userAgentData?.getHighEntropyValues) {
26+
try {
27+
const highEntropy = await navigator.userAgentData.getHighEntropyValues(['brands']);
28+
if (highEntropy.brands) {
29+
const brands = highEntropy.brands;
30+
const ddgCount = brands.filter(b => b.brand === 'DuckDuckGo').length;
31+
32+
results.push({
33+
test: 'getHighEntropyValues-brands-no-duckduckgo',
34+
result: ddgCount === 0 ? 'PASS' : 'FAIL',
35+
details: `Found ${ddgCount} DuckDuckGo brand(s) in getHighEntropyValues brands (expected 0)`
36+
});
37+
}
38+
} catch (e) {
39+
results.push({
40+
test: 'getHighEntropyValues-brands-error',
41+
result: 'ERROR',
42+
details: e.message
43+
});
44+
}
45+
}
46+
47+
if (navigator.userAgentData?.getHighEntropyValues) {
48+
try {
49+
const highEntropy = await navigator.userAgentData.getHighEntropyValues(['fullVersionList']);
50+
if (highEntropy.fullVersionList) {
51+
const fvl = highEntropy.fullVersionList;
52+
const ddgCount = fvl.filter(b => b.brand === 'DuckDuckGo').length;
53+
54+
results.push({
55+
test: 'fullVersionList-no-duckduckgo',
56+
result: ddgCount === 0 ? 'PASS' : 'FAIL',
57+
details: `Found ${ddgCount} DuckDuckGo brand(s) in fullVersionList (expected 0)`
58+
});
59+
}
60+
} catch (e) {
61+
results.push({
62+
test: 'fullVersionList-error',
63+
result: 'ERROR',
64+
details: e.message
65+
});
66+
}
67+
}
68+
69+
window.results = results;
70+
71+
const resultsDiv = document.getElementById('results');
72+
resultsDiv.innerHTML = '<pre>' + JSON.stringify(results, null, 2) + '</pre>';
73+
</script>
74+
</body>
75+
</html>

0 commit comments

Comments
 (0)