Commit 6319a59f authored by Aaron Tagliaboschi's avatar Aaron Tagliaboschi Committed by Chromium LUCI CQ

[UA-CH] Rename Accept-CH tokens

Bring tokens inline with Section 3.1 of the Client Hints spec, which
recommends tokens be the same as the header name they're associated
with.

Also fixing the *copious* tests associated with this change...

Intent to Remove: https://groups.google.com/u/1/a/chromium.org/g/blink-dev/c/t-S9nnos9qU

Bug: 1153688
Change-Id: I2bfe038abe887713d56ef835e8f9d61246001040
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2595089Reviewed-by: default avatarMaksim Orlovich <morlovich@chromium.org>
Reviewed-by: default avatarYoav Weiss <yoavweiss@chromium.org>
Reviewed-by: default avatarAvi Drissman <avi@chromium.org>
Commit-Queue: Aaron Tagliaboschi <aarontag@chromium.org>
Cr-Commit-Position: refs/heads/master@{#846075}
parent 00d9c86f
...@@ -281,7 +281,7 @@ public class NavigateTest { ...@@ -281,7 +281,7 @@ public class NavigateTest {
// TODO(https://crbug.com/928669) Remove switch when UA-CH-* launched. // TODO(https://crbug.com/928669) Remove switch when UA-CH-* launched.
public void testRequestDesktopSiteClientHints() throws Exception { public void testRequestDesktopSiteClientHints() throws Exception {
String url1 = mTestServer.getURL( String url1 = mTestServer.getURL(
"/set-header?Accept-CH: ua-arch,ua-platform,ua-model&Accept-CH-Lifetime: 86400"); "/set-header?Accept-CH: sec-ch-ua-arch,sec-ch-ua-platform,sec-ch-ua-model&Accept-CH-Lifetime: 86400");
String url2 = mTestServer.getURL( String url2 = mTestServer.getURL(
"/echoheader?sec-ch-ua-arch&sec-ch-ua-mobile&sec-ch-ua-model&sec-ch-ua-platform"); "/echoheader?sec-ch-ua-arch&sec-ch-ua-mobile&sec-ch-ua-model&sec-ch-ua-platform");
......
HTTP/1.1 200 OK HTTP/1.1 200 OK
Accept-CH: dpr,device-memory,viewport-width,rtt,downlink,ect,lang,ua-arch,ua-platform,ua-platform-version,ua-model,ua-full-version Accept-CH: dpr,device-memory,viewport-width,rtt,downlink,ect,lang,sec-ch-ua-arch,sec-ch-ua-platform,sec-ch-ua-platform-version,sec-ch-ua-model,sec-ch-ua-full-version
Accept-CH-Lifetime: 3600 Accept-CH-Lifetime: 3600
HTTP/1.1 200 OK HTTP/1.1 200 OK
Accept-CH: dpr,device-memory,viewport-width,rtt,downlink,ect,lang,ua-arch,ua-platform,ua-platform-version,ua-model,ua-full-version Accept-CH: dpr,device-memory,viewport-width,rtt,downlink,ect,lang,sec-ch-ua-arch,sec-ch-ua-platform,sec-ch-ua-platform-version,sec-ch-ua-model,sec-ch-ua-full-version
Accept-CH-Lifetime: 1 Accept-CH-Lifetime: 1
HTTP/1.1 200 OK HTTP/1.1 200 OK
Accept-CH: dpr,device-memory,viewport-width,rtt,downlink,ect,lang,ua-arch,ua-platform,ua-platform-version,ua-model,ua-full-version Accept-CH: dpr,device-memory,viewport-width,rtt,downlink,ect,lang,sec-ch-ua-arch,sec-ch-ua-platform,sec-ch-ua-platform-version,sec-ch-ua-model,sec-ch-ua-full-version
HTTP/1.1 200 OK HTTP/1.1 200 OK
Accept-CH: dpr,device-memory,viewport-width,rtt,downlink,ect,lang,ua-arch,ua-platform,ua-platform-version,ua-model,ua-full-version Accept-CH: dpr,device-memory,viewport-width,rtt,downlink,ect,lang,sec-ch-ua-arch,sec-ch-ua-platform,sec-ch-ua-platform-version,sec-ch-ua-model,sec-ch-ua-full-version
<html> <html>
<!-- This is split in two since data from header may round trip quickly <!-- This is split in two since data from header may round trip quickly
enough from browser to be used, so this makes sure we actually merge --> enough from browser to be used, so this makes sure we actually merge -->
<meta http-equiv="Accept-CH" content="lang,ua-arch,ua-platform"> <meta http-equiv="Accept-CH" content="lang,sec-ch-ua-arch,sec-ch-ua-platform">
<meta http-equiv="Accept-CH" content="ua-platform-version,ua-model,ua-full-version"> <meta http-equiv="Accept-CH" content="sec-ch-ua-platform-version,sec-ch-ua-model,sec-ch-ua-full-version">
<link rel="icon" href="data:;base64,="> <link rel="icon" href="data:;base64,=">
<!-- A subresource! --> <!-- A subresource! -->
<img src="non-existing-image.jpg"></img> <img src="non-existing-image.jpg"></img>
......
<html> <html>
<meta http-equiv="Accept-CH" content="dpr,device-memory,viewport-width,rtt,downlink,ect,lang,ua-arch,ua-platform,ua-model,ua-full-version"> <meta http-equiv="Accept-CH" content="dpr,device-memory,viewport-width,rtt,downlink,ect,lang,sec-ch-ua-arch,sec-ch-ua-platform,sec-ch-ua-model,sec-ch-ua-full-version">
<meta http-equiv="Accept-CH-Lifetime" content="3600"> <meta http-equiv="Accept-CH-Lifetime" content="3600">
<link rel="icon" href="data:;base64,="> <link rel="icon" href="data:;base64,=">
</html> </html>
<html> <html>
<meta http-equiv="Accept-CH" content="dpr,device-memory,viewport-width,rtt,downlink,ect,lang,ua-arch,ua-platform,ua-model,ua-full-version"> <meta http-equiv="Accept-CH" content="dpr,device-memory,viewport-width,rtt,downlink,ect,lang,sec-ch-ua-arch,sec-ch-ua-platform,sec-ch-ua-model,sec-ch-ua-full-version">
<link rel="icon" href="data:;base64,="> <link rel="icon" href="data:;base64,=">
<head></head> <head></head>
Empty file which uses link-rel to disable favicon fetches. The corresponding Empty file which uses link-rel to disable favicon fetches. The corresponding
......
<html> <html>
<meta http-equiv="Accept-CH" content="dpr,device-memory,viewport-width,rtt,downlink,ect,lang,ua-arch,ua-platform,ua-platform-version,ua-model,ua-full-version"> <meta http-equiv="Accept-CH" content="dpr,device-memory,viewport-width,rtt,downlink,ect,lang,sec-ch-ua-arch,sec-ch-ua-platform,sec-ch-ua-platform-version,sec-ch-ua-model,sec-ch-ua-full-version">
<link rel="icon" href="data:;base64,="> <link rel="icon" href="data:;base64,=">
<head></head> <head></head>
Empty file which uses link-rel to disable favicon fetches. The corresponding Empty file which uses link-rel to disable favicon fetches. The corresponding
......
...@@ -117,8 +117,8 @@ std::unique_ptr<HttpResponse> HandleEchoCriticalHeader( ...@@ -117,8 +117,8 @@ std::unique_ptr<HttpResponse> HandleEchoCriticalHeader(
http_response->set_content_type("text/plain"); http_response->set_content_type("text/plain");
http_response->AddCustomHeader("Access-Control-Allow-Origin", "*"); http_response->AddCustomHeader("Access-Control-Allow-Origin", "*");
http_response->AddCustomHeader("Accept-CH", "UA-Platform"); http_response->AddCustomHeader("Accept-CH", "Sec-CH-UA-Platform");
http_response->AddCustomHeader("Critical-CH", "UA-Platform"); http_response->AddCustomHeader("Critical-CH", "Sec-CH-UA-Platform");
http_response->set_content( http_response->set_content(
request.headers.find("Sec-CH-UA-Mobile")->second + request.headers.find("Sec-CH-UA-Mobile")->second +
......
...@@ -26,13 +26,13 @@ const char* const kClientHintsNameMapping[] = {"device-memory", ...@@ -26,13 +26,13 @@ const char* const kClientHintsNameMapping[] = {"device-memory",
"downlink", "downlink",
"ect", "ect",
"lang", "lang",
"ua", "sec-ch-ua",
"ua-arch", "sec-ch-ua-arch",
"ua-platform", "sec-ch-ua-platform",
"ua-model", "sec-ch-ua-model",
"ua-mobile", "sec-ch-ua-mobile",
"ua-full-version", "sec-ch-ua-full-version",
"ua-platform-version"}; "sec-ch-ua-platform-version"};
const size_t kClientHintsMappingsCount = base::size(kClientHintsNameMapping); const size_t kClientHintsMappingsCount = base::size(kClientHintsNameMapping);
......
...@@ -45,16 +45,18 @@ TEST_F(ClientHintsPreferencesTest, BasicSecure) { ...@@ -45,16 +45,18 @@ TEST_F(ClientHintsPreferencesTest, BasicSecure) {
false, false, false}, false, false, false},
{"DPRW", false, false, false, false, false, false, false, false, false, {"DPRW", false, false, false, false, false, false, false, false, false,
false, false, false}, false, false, false},
{"ua", false, false, false, false, false, false, false, true, false, {"sec-ch-ua", false, false, false, false, false, false, false, true,
false, false, false}, false, false, false, false},
{"ua-arch", false, false, false, false, false, false, false, false, true, {"sec-ch-ua-arch", false, false, false, false, false, false, false, false,
false, false, false}, true, false, false, false},
{"ua-platform", false, false, false, false, false, false, false, false, {"sec-ch-ua-platform", false, false, false, false, false, false, false,
false, true, false, false}, false, false, true, false, false},
{"ua-model", false, false, false, false, false, false, false, false, {"sec-ch-ua-model", false, false, false, false, false, false, false,
false, false, true, false}, false, false, false, true, false},
{"ua, ua-arch, ua-platform, ua-model, ua-full-version", false, false, {"sec-ch-ua, sec-ch-ua-arch, sec-ch-ua-platform, sec-ch-ua-model, "
false, false, false, false, false, true, true, true, true, true}, "sec-ch-ua-full-version",
false, false, false, false, false, false, false, true, true, true, true,
true},
}; };
for (const auto& test_case : cases) { for (const auto& test_case : cases) {
...@@ -254,8 +256,10 @@ TEST_F(ClientHintsPreferencesTest, ParseHeaders) { ...@@ -254,8 +256,10 @@ TEST_F(ClientHintsPreferencesTest, ParseHeaders) {
false, false, false, false, false}, false, false, false, false, false},
{"dpr rtt", false, false, false, false, false, false, false, false, false, {"dpr rtt", false, false, false, false, false, false, false, false, false,
false, false, false, false}, false, false, false, false},
{"ua, ua-arch, ua-platform, ua-model, ua-full-version", false, false, {"sec-ch-ua, sec-ch-ua-arch, sec-ch-ua-platform, sec-ch-ua-model, "
false, false, false, false, false, false, true, true, true, true, true}, "sec-ch-ua-full-version",
false, false, false, false, false, false, false, false, true, true, true,
true, true},
}; };
for (const auto& test : test_cases) { for (const auto& test : test_cases) {
......
Accept-CH: dpr,device-memory,viewport-width,rtt,downlink,ect,lang,ua,ua-arch,ua-platform,ua-platform-version,ua-model Accept-CH: dpr,device-memory,viewport-width,rtt,downlink,ect,lang,sec-ch-ua,sec-ch-ua-arch,sec-ch-ua-platform,sec-ch-ua-platform-version,sec-ch-ua-model
Accept-CH: ua,ua-arch,ua-platform,ua-platform-version,ua-model Accept-CH: sec-ch-ua,sec-ch-ua-arch,sec-ch-ua-platform,sec-ch-ua-platform-version,sec-ch-ua-model
<?php <?php
header("Accept-CH: UA, UA-Full-Version, UA-Platform, UA-Platform-Version, UA-Arch, UA-Model, UA-Mobile"); header("Accept-CH: Sec-CH-UA, Sec-CH-UA-Full-Version, Sec-CH-UA-Platform, Sec-CH-UA-Platform-Version, Sec-CH-UA-Arch, Sec-CH-UA-Model, Sec-CH-UA-Mobile");
?> ?>
Hello, test. Hello, test.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment