Skip to content

Commit

Permalink
Implement Sec-CH-Prefers-Reduced-Transparency
Browse files Browse the repository at this point in the history
The `Sec-CH-Prefers-Reduced-Transparency` client hint is modeled after
the `prefers-reduced-transparency` user preference media feature as
defined in Media Queries 5.

Intent to prototype: https://groups.google.com/a/chromium.org/g/blink-dev/c/GFHrc2-lOo8

Bug: 1466423
Change-Id: I7b1e37d879dcc05b19475ba184daf28275d6ae9e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4705483
Reviewed-by: Nate Fischer <[email protected]>
Reviewed-by: Jeremy Roman <[email protected]>
Reviewed-by: Ari Chivukula <[email protected]>
Reviewed-by: Mike Taylor <[email protected]>
Reviewed-by: Reilly Grant <[email protected]>
Reviewed-by: Avi Drissman <[email protected]>
Reviewed-by: Daniel Cheng <[email protected]>
Commit-Queue: Luke <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1188705}
  • Loading branch information
lukewarlow authored and chromium-wpt-export-bot committed Aug 26, 2023
1 parent 505737c commit ac39608
Show file tree
Hide file tree
Showing 13 changed files with 18 additions and 8 deletions.
2 changes: 1 addition & 1 deletion client-hints/accept-ch/__dir__.headers
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Accept-CH: device-memory, dpr, width, viewport-width, rtt, downlink, ect, sec-ch-ua, sec-ch-ua-arch, sec-ch-ua-platform, sec-ch-ua-model, sec-ch-ua-mobile, sec-ch-ua-full-version, sec-ch-ua-platform-version, sec-ch-prefers-color-scheme, sec-ch-prefers-reduced-motion, sec-ch-ua-bitness, sec-ch-viewport-height, sec-ch-device-memory, sec-ch-dpr, sec-ch-width, sec-ch-viewport-width, sec-ch-ua-full-version-list, sec-ch-ua-wow64
Accept-CH: device-memory, dpr, width, viewport-width, rtt, downlink, ect, sec-ch-ua, sec-ch-ua-arch, sec-ch-ua-platform, sec-ch-ua-model, sec-ch-ua-mobile, sec-ch-ua-full-version, sec-ch-ua-platform-version, sec-ch-prefers-color-scheme, sec-ch-prefers-reduced-motion, sec-ch-ua-bitness, sec-ch-viewport-height, sec-ch-device-memory, sec-ch-dpr, sec-ch-width, sec-ch-viewport-width, sec-ch-ua-full-version-list, sec-ch-ua-wow64, sec-ch-prefers-reduced-transparency
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Accept-CH: device-memory, dpr, width, viewport-width, rtt, downlink, ect, sec-ch-ua, sec-ch-ua-arch, sec-ch-ua-platform, sec-ch-ua-model, sec-ch-ua-mobile, sec-ch-ua-full-version, sec-ch-ua-platform-version, sec-ch-prefers-color-scheme, sec-ch-prefers-reduced-motion, sec-ch-ua-bitness, sec-ch-viewport-height, sec-ch-device-memory, sec-ch-dpr, sec-ch-width, sec-ch-viewport-width, sec-ch-ua-full-version-list, sec-ch-ua-wow64
Accept-CH: device-memory, dpr, width, viewport-width, rtt, downlink, ect, sec-ch-ua, sec-ch-ua-arch, sec-ch-ua-platform, sec-ch-ua-model, sec-ch-ua-mobile, sec-ch-ua-full-version, sec-ch-ua-platform-version, sec-ch-prefers-color-scheme, sec-ch-prefers-reduced-motion, sec-ch-ua-bitness, sec-ch-viewport-height, sec-ch-device-memory, sec-ch-dpr, sec-ch-width, sec-ch-viewport-width, sec-ch-ua-full-version-list, sec-ch-ua-wow64, sec-ch-prefers-reduced-transparency
2 changes: 2 additions & 0 deletions client-hints/accept-ch/feature-policy.sub.https.html
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
assert_in_array(r.headers.get("mobile-received"), ["?0", "?1"], 'mobile is unexpected');
assert_false(r.headers.has("prefers-color-scheme-received"), "prefers-color-scheme-received");
assert_false(r.headers.has("prefers-reduced-motion-received"), "prefers-reduced-motion-received");
assert_false(r.headers.has("prefers-reduced-transparency-received"), "prefers-reduced-transparency-received");
assert_false(r.headers.has("viewport-height-received"), "viewport-height-received");
});
}, "Accept-CH header test");
Expand All @@ -65,6 +66,7 @@
assert_false(r.headers.has("ect-received"), "ect-received");
assert_false(r.headers.has("prefers-color-scheme-received"), "prefers-color-scheme-received");
assert_false(r.headers.has("prefers-reduced-motion-received"), "prefers-reduced-motion-received");
assert_false(r.headers.has("prefers-reduced-transparency-received"), "prefers-reduced-transparency-received");
assert_false(r.headers.has("viewport-height-received"), "viewport-height-received");
});
}, "Cross-Origin Accept-CH header test");
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Permissions-Policy: ch-device-memory=*, ch-dpr=(), ch-viewport-width=(self), ch-mobile, ch-prefers-color-scheme=(), ch-prefers-reduced-motion=(), ch-viewport-height=()
Permissions-Policy: ch-device-memory=*, ch-dpr=(), ch-viewport-width=(self), ch-mobile, ch-prefers-color-scheme=(), ch-prefers-reduced-motion=(), ch-viewport-height=(), ch-prefers-reduced-transparency=()
3 changes: 2 additions & 1 deletion client-hints/http-equiv-accept-ch-merge.https.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<head>
<meta http-equiv="Accept-CH" content="sec-ch-viewport-width, viewport-width, rtt">
<meta http-equiv="Accept-CH" content="downlink, ect, sec-ch-prefers-color-scheme">
<meta http-equiv="Accept-CH" content="sec-ch-prefers-reduced-motion">
<meta http-equiv="Accept-CH" content="sec-ch-prefers-reduced-motion, sec-ch-prefers-reduced-transparency">
<body>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
Expand Down Expand Up @@ -40,6 +40,7 @@
"3g", "4g"], 'ect-received is unexpected');
assert_true(r.headers.has("prefers-color-scheme-received"), "prefers-color-scheme-received");
assert_true(r.headers.has("prefers-reduced-motion-received"), "prefers-reduced-motion-received");
assert_true(r.headers.has("prefers-reduced-transparency-received"), "prefers-reduced-transparency-received");
});
}, "Accept-CH header test");

Expand Down
3 changes: 2 additions & 1 deletion client-hints/meta-equiv-delegate-ch-injection.https.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
document.getElementsByTagName('meta')[0].setAttribute("content", "dpr;sec-ch-dpr;device-memory;sec-ch-device-memory;viewport-width;sec-ch-viewport-width;rtt;downlink;ect");
document.head.outerHTML += '<meta http-equiv="Delegate-CH" content="sec-ch-ua-arch;sec-ch-ua-platform;sec-ch-ua-model">';
document.head.innerHTML += '<meta http-equiv="Delegate-CH" content="sec-ch-ua-full-version;sec-ch-ua-bitness;sec-ch-ua-full-version-list">';
document.write('<meta http-equiv="Delegate-CH" content="sec-ch-ua-platform-version;sec-ch-prefers-color-scheme;sec-ch-prefers-reduced-motion;sec-ch-viewport-height">');
document.write('<meta http-equiv="Delegate-CH" content="sec-ch-ua-platform-version;sec-ch-prefers-color-scheme;sec-ch-prefers-reduced-motion;sec-ch-viewport-height;sec-ch-prefers-reduced-transparency">');

// resources/echo-client-hints-received.py sets the response headers depending on the set
// of client hints it receives in the request headers.
Expand All @@ -34,6 +34,7 @@
assert_false(r.headers.has("downlink-received"), "downlink-received");
assert_false(r.headers.has("ect-received"), "ect-received");
assert_false(r.headers.has("prefers-color-scheme-received"), "prefers-color-scheme-received");
assert_false(r.headers.has("prefers-reduced-transparency-received"), "prefers-reduced-transparency-received");
});
}, "Delegate-CH meta-equiv injection test");

Expand Down
3 changes: 2 additions & 1 deletion client-hints/meta-equiv-delegate-ch-merge.https.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<head>
<meta http-equiv="Delegate-CH" content="sec-ch-viewport-width; viewport-width; rtt">
<meta http-equiv="Delegate-CH" content="downlink; ect; sec-ch-prefers-color-scheme">
<meta http-equiv="Delegate-CH" content="sec-ch-prefers-reduced-motion">
<meta http-equiv="Delegate-CH" content="sec-ch-prefers-reduced-motion; sec-ch-prefers-reduced-transparency">
<body>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
Expand Down Expand Up @@ -41,6 +41,7 @@
"3g", "4g"], 'ect-received is unexpected');
assert_true(r.headers.has("prefers-color-scheme-received"), "prefers-color-scheme-received");
assert_true(r.headers.has("prefers-reduced-motion-received"), "prefers-reduced-motion-received");
assert_true(r.headers.has("prefers-reduced-transparency-received"), "prefers-reduced-transparency-received");
});
}, "Delegate-CH header test");

Expand Down
1 change: 1 addition & 0 deletions client-hints/resources/clienthintslist.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ def client_hints_list():
b"sec-ch-viewport-width",
b"sec-ch-ua-full-version-list",
b"sec-ch-ua-wow64",
b"sec-ch-prefers-reduced-transparency",
]

def client_hints_full_list():
Expand Down
2 changes: 2 additions & 0 deletions client-hints/resources/echo-client-hints-received.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,5 @@ def main(request, response):
response.headers.set(b"prefers-color-scheme-received", request.headers.get(b"sec-ch-prefers-color-scheme"))
if b"sec-ch-prefers-reduced-motion" in request.headers:
response.headers.set(b"prefers-reduced-motion-received", request.headers.get(b"sec-ch-prefers-reduced-motion"))
if b"sec-ch-prefers-reduced-transparency" in request.headers:
response.headers.set(b"prefers-reduced-transparency-received", request.headers.get(b"sec-ch-prefers-reduced-transparency"))
1 change: 1 addition & 0 deletions client-hints/resources/export.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ const client_hints_list = [
"sec-ch-viewport-width",
"sec-ch-ua-full-version-list",
"sec-ch-ua-wow64",
"sec-ch-prefers-reduced-transparency",
];

const client_hints_full_list = client_hints_list.concat(["width", "sec-ch-width"])
Expand Down
2 changes: 1 addition & 1 deletion client-hints/sandbox/__dir__.headers
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Accept-CH: device-memory, dpr, width, viewport-width, rtt, downlink, ect, sec-ch-ua, sec-ch-ua-arch, sec-ch-ua-platform, sec-ch-ua-model, sec-ch-ua-mobile, sec-ch-ua-full-version, sec-ch-ua-platform-version, sec-ch-prefers-color-scheme, sec-ch-prefers-reduced-motion, sec-ch-ua-bitness, sec-ch-viewport-height, sec-ch-device-memory, sec-ch-dpr, sec-ch-width, sec-ch-viewport-width, sec-ch-ua-full-version-list, sec-ch-ua-wow64
Accept-CH: device-memory, dpr, width, viewport-width, rtt, downlink, ect, sec-ch-ua, sec-ch-ua-arch, sec-ch-ua-platform, sec-ch-ua-model, sec-ch-ua-mobile, sec-ch-ua-full-version, sec-ch-ua-platform-version, sec-ch-prefers-color-scheme, sec-ch-prefers-reduced-motion, sec-ch-ua-bitness, sec-ch-viewport-height, sec-ch-device-memory, sec-ch-dpr, sec-ch-width, sec-ch-viewport-width, sec-ch-ua-full-version-list, sec-ch-ua-wow64, sec-ch-prefers-reduced-transparency
1 change: 1 addition & 0 deletions client-hints/sec-ch-quotes.https.html
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
"sec-ch-prefers-reduced-motion",
"sec-ch-ua-full-version-list",
"sec-ch-ua-wow64",
"sec-ch-prefers-reduced-transparency",
];
const boolean_client_hint_headers = [
"sec-ch-mobile",
Expand Down
2 changes: 1 addition & 1 deletion client-hints/sec-ch-quotes.https.html.headers
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Accept-CH: sec-ch-ua,sec-ch-ua-arch,sec-ch-ua-platform,sec-ch-ua-platform-version,sec-ch-ua-model,sec-ch-prefers-color-scheme,sec-ch-prefers-reduced-motion
Accept-CH: sec-ch-ua,sec-ch-ua-arch,sec-ch-ua-platform,sec-ch-ua-platform-version,sec-ch-ua-model,sec-ch-prefers-color-scheme,sec-ch-prefers-reduced-motion,sec-ch-prefers-reduced-transparency

0 comments on commit ac39608

Please sign in to comment.