Automatic update from web-platform-tests 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 <aarontag@chromium.org> Auto-Submit: Mike Taylor <miketaylr@chromium.org> Reviewed-by: Aaron Tagliaboschi <aarontag@chromium.org> Cr-Commit-Position: refs/heads/main@{#935138} -- wpt-commits: c1be1a0eea9b45e6aa3ee088f76aee7955092693 wpt-pr: 31381
51 lines
1.6 KiB
HTML
51 lines
1.6 KiB
HTML
<!DOCTYPE html>
|
|
<head>
|
|
<script src=/resources/testharness.js></script>
|
|
<script src=/resources/testharnessreport.js></script>
|
|
<script>
|
|
var sec_ch_ua_header = "";
|
|
|
|
function grabSECCHUAHeader(t) {
|
|
return new Promise((resolve, reject) => {
|
|
var w;
|
|
window.onmessage = e => {
|
|
try {
|
|
resolve(e.data.header)
|
|
} catch (ex) {
|
|
reject(ex);
|
|
}
|
|
};
|
|
w = window.open("./resources/sec-ch-ua.py");
|
|
t.add_cleanup(w.close);
|
|
});
|
|
}
|
|
promise_test(t => {
|
|
return grabSECCHUAHeader(t).then(header => {
|
|
sec_ch_ua_header = header;
|
|
assert_not_equals(sec_ch_ua_header, "", "`Sec-CH-UA` is sent.");
|
|
});
|
|
}, "Open HTTPS window: `Sec-CH-UA` header returned by default.");
|
|
|
|
promise_test(t => {
|
|
return grabSECCHUAHeader(t).then(header => {
|
|
assert_not_equals(header, "", "The `Sec-CH-UA` header is delivered.");
|
|
assert_equals(header, sec_ch_ua_header,
|
|
"The `Sec-CH-UA` header did not change between requests.");
|
|
});
|
|
}, "Open HTTPS window: `Sec-CH-UA` header is consistent across versions.");
|
|
|
|
promise_test(t => {
|
|
return grabSECCHUAHeader(t).then(header => {
|
|
assert_true(header.split(", ").every((brand) => {
|
|
let brandEnd = brand.indexOf(";v=");
|
|
assert_true(brandEnd !== -1,
|
|
"A well-formed Sec-CH-UA header must have version (v=) params");
|
|
/* 32 + 2, becuase of the extra quotes padding the brand,
|
|
e.g. '"lol";v=22"' */
|
|
return brandEnd < 34;
|
|
}));
|
|
});
|
|
}, "Open HTTPS window: No brand in `Sec-CH-UA` header is > than 32 chars.");
|
|
</script>
|
|
</head>
|