From c1be1a0eea9b45e6aa3ee088f76aee7955092693 Mon Sep 17 00:00:00 2001 From: Mike Taylor Date: Tue, 26 Oct 2021 14:29:32 -0700 Subject: [PATCH] Update Sec-CH-UA tests: fix existing tests, and test brand size. As of https://github.com/WICG/ua-client-hints/issues/179, https://wicg.github.io/ua-client-hints/#user-agent-brand now requires that a brand in a brand list not be longer than 32 bytes. This CL adds a new test for the userAgentData.brands interface, and modifies the existing sec-ch-ua HTTP tests. Also, the existing sec-ch-ua HTTP tests were updated to more closely reflect the current state of UA-CH ("UA" is not a valid token, and "Accept-CH-Lifetime" is not shipping). Bug: 1263180 Change-Id: Ifa7cbf18d67271e2dd1dc1d485f432d4ca9327fa Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3243544 Commit-Queue: Aaron Tagliaboschi Auto-Submit: Mike Taylor Reviewed-by: Aaron Tagliaboschi Cr-Commit-Position: refs/heads/main@{#935138} --- client-hints/resources/sec-ch-ua.py | 4 +- client-hints/sec-ch-ua.https.html | 51 +++++++++++++--------- ua-client-hints/useragentdata.https.any.js | 7 +++ 3 files changed, 38 insertions(+), 24 deletions(-) create mode 100644 ua-client-hints/useragentdata.https.any.js diff --git a/client-hints/resources/sec-ch-ua.py b/client-hints/resources/sec-ch-ua.py index 01bcb9682a1ae9..ddeb582a19bc8e 100644 --- a/client-hints/resources/sec-ch-ua.py +++ b/client-hints/resources/sec-ch-ua.py @@ -1,8 +1,6 @@ def main(request, response): - ua = request.headers.get(b'sec-ch-ua', b'') + ua = request.headers.get(b'Sec-CH-UA', b'') response.headers.set(b"Content-Type", b"text/html") - response.headers.set(b"Accept-CH", b"UA") - response.headers.set(b"Accept-CH-Lifetime", b"10") response.content = b''' diff --git a/ua-client-hints/useragentdata.https.any.js b/ua-client-hints/useragentdata.https.any.js new file mode 100644 index 00000000000000..fc1e9e0b3c9890 --- /dev/null +++ b/ua-client-hints/useragentdata.https.any.js @@ -0,0 +1,7 @@ +// META: title=tests for navigator.userAgentData + +test(t => { + const brands = navigator.userAgentData.brands; + assert_true(brands.every(brand => brand.brand.length < 32), + "No brand should be longer than 32 characters."); +});