Skip to content

Commit 716e925

Browse files
authored
Add js user agent client hints brand header-matching feature (#4224)
* Add ua-ch-brands feature * Lint * Add schema * Zap extraneous comments * Liiint * Gate to internal & preview channels * Merge conditions into 1 * Fix angry test * Experiment w/ swtiching syntax * Annnnd that was not the problem it seems
1 parent de7662d commit 716e925

File tree

6 files changed

+42
-0
lines changed

6 files changed

+42
-0
lines changed

features/ua-ch-brands.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"_meta": {
3+
"description": "User agent client hint brands for the browser JavaScript API."
4+
},
5+
"state": "disabled",
6+
"exceptions": []
7+
}

index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@ const featuresToIncludeTempUnprotectedExceptions = [
144144
'trackingCookies1p',
145145
'trackingCookies3p',
146146
'trackingParameters',
147+
'uaChBrands',
147148
'unprotectedTemporary',
148149
'webCompat',
149150
];

overrides/windows-override.json

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2555,6 +2555,26 @@
25552555
"clientBrandHint": {
25562556
"state": "enabled"
25572557
},
2558+
"uaChBrands": {
2559+
"state": "enabled",
2560+
"settings": {
2561+
"additionalCheck": "disabled",
2562+
"conditionalChanges": [
2563+
{
2564+
"condition": [
2565+
{ "internal": true },
2566+
{ "preview": true }],
2567+
"patchSettings": [
2568+
{
2569+
"op": "replace",
2570+
"path": "/additionalCheck",
2571+
"value": "enabled"
2572+
}
2573+
]
2574+
}
2575+
]
2576+
}
2577+
},
25582578
"privacyPro": {
25592579
"state": "enabled",
25602580
"features": {

schema/config.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import { Taskbar } from './features/taskbar';
2424
import { AppHealth } from './features/appHealth';
2525
import { ElementHidingFeature } from './features/element-hiding';
2626
import { RequestBlocklistFeature } from './features/request-blocklist';
27+
import { UaChBrandsFeature } from './features/ua-ch-brands';
2728
import { UrlPredictorFeature } from './features/url-predictor';
2829

2930
export { WebCompatSettings } from './features/webcompat';
@@ -73,6 +74,7 @@ export type ConfigV5<VersionType> = {
7374
customUserAgent?: CustomUserAgentFeature<VersionType>;
7475
elementHiding?: ElementHidingFeature<VersionType>;
7576
requestBlocklist?: RequestBlocklistFeature<VersionType>;
77+
uaChBrands?: UaChBrandsFeature<VersionType>;
7678
urlPredictor?: UrlPredictorFeature<VersionType>;
7779
};
7880
unprotectedTemporary: SiteException[];

schema/feature.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ type ConditionBlock = {
6565
minSupportedVersion?: number;
6666
maxSupportedVersion?: number;
6767
internal?: boolean;
68+
preview?: boolean;
6869
context?: {
6970
top?: boolean;
7071
frame?: boolean;

schema/features/ua-ch-brands.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { CSSInjectFeatureSettings, Feature, FeatureState } from '../feature';
2+
3+
type StateToggle = 'enabled' | 'disabled';
4+
5+
type UaChBrandsSettings = CSSInjectFeatureSettings<{
6+
filterWebView2?: StateToggle;
7+
overrideEdge?: StateToggle;
8+
additionalCheck?: FeatureState;
9+
}>;
10+
11+
export type UaChBrandsFeature<VersionType> = Feature<UaChBrandsSettings, VersionType>;

0 commit comments

Comments
 (0)