Allow fetch/XMLHttpRequest APIs to set a user-agent [chromium/src : main]

3 views
Skip to first unread message

Andrew Brown (Gerrit)

unread,
Jun 26, 2025, 10:54:45 PMJun 26
to Adam Rice, Min Qin, Bo Liu, Hiroki Nakagawa, Takashi Toyoshima, James Maclean, James Su, AyeAye, Chromium LUCI CQ, chromium...@chromium.org, Nate Chapin, devtools-re...@chromium.org, extension...@chromium.org, chromium-a...@chromium.org, mkwst+w...@chromium.org, horo+...@chromium.org, shimazu+se...@chromium.org, kinuko+ser...@chromium.org, servicewor...@chromium.org, antoniosarto...@chromium.org, kenjibah...@chromium.org, jsbell+ser...@chromium.org, arthursonzog...@chromium.org, blink-revie...@chromium.org, alexmo...@chromium.org, yhanad...@chromium.org, tranbaod...@chromium.org, nona+...@chromium.org, creis...@chromium.org, shuche...@chromium.org, jbauma...@chromium.org, navigation...@chromium.org, keithle...@chromium.org, blink-...@chromium.org, blundell+...@chromium.org, gavinp...@chromium.org, kinuko...@chromium.org, loading-re...@chromium.org, loading...@chromium.org, net-r...@chromium.org, network-ser...@chromium.org
Attention needed from Adam Rice, Bo Liu and Min Qin

Andrew Brown added 9 comments

Patchset-level comments
File-level comment, Patchset 14:
Andrew Brown . unresolved

Happy new year everyone! Apologies for dragging this up right as everyone returns from a well-deserved break :)

Figured I could use some of my summer free time to close this out for good. I worked out (some of, hopefully all) the failing devtools tests, which needed changes inside the preflight-summoning code - tagged Min Qin for review. I'm a little wary that I ended up needing to have weird case handling in the preflight code.

I have two outstanding questions:

  • I've commented out the assertion in a test for frame_fetch_context. It's expecting that the User-Agent is set after calling PrepareRequest, but because this CL moves it to its own thing, that's no longer the case. Is this test checking something "deeper" that I should work out, or can it be safely removed? (I suspect this is the root cause of a few other test failures, but I never have been able to accurately run the full suite locally.)
  • Do my cases for User-Agent handling make sense: a fetch-set User-Agent overrides a devtools User-Agent overrides the default? I think we've settled this, but it may be different when you consider which User-Agent should be present on preflight OPTIONS requests. At this point, it follows the same order.
Andrew Brown

Ok, not quite all the failing devtools tests :(

Some remaining failures I've traced back down to `ThrottlingURLLoader::StartNow()`, where it enters IPC/inheritance hell. I am almost willing to bet this will characterise all the remianing failures: issues in the various implementations of `URLLoaderFactory::CreateLoaderAndStart`.

Basically, I have reason to believe there are one or more `URLLoader` implementations that don't combine the `cors_exempt_headers` in with the normal `headers` on a request - similar to the change I've already made in `preflight_controller.cc`. There are different `URLLoader`'s for different things, and I bet the one that deals with extensions will have a problem, and so will the one that deals with non-returning delayed requests for `fetchLater()`.

Do you have any tips for tracking down which one(s) live on the path below the DevTools (and extension) code? The debug docs are fantastic for working bottom-up, where you have a crash and you need to work out where, but not so helpful for working top-down, where I have correct behaviour and I don't know where it stops.

There are ~43 different types of `CreateLoaderAndStart` that could lead to my problem, each with their own very large stack of behaviour, and often calling into each other in hard-to-grasp ways. I can work through them eventually, but it's going to take a long time.

Andrew Brown

I was *almost* correct; I actually had to tell the parallel stack that the inspector protocol uses, that it still needs to go find the UA elsewhere.

This means unfortunately all the work to keep the UA inside the FetchContext is useless, because the inspector protocol has no idea what context the request was made in, so there's just no way that the context-based approach is compatible with the behaviour inspector needs. I've gone back to the *original* way I did it, with a new field on the ResourceRequest.

This lets us keep basically all of the original behaviour (stuff like PrepareRequest being the function call that actually sets the UA onto the blink::ResourceRequest, instead of it happening much later when populating the network::ResourceRequest). So a lot of this CL is now semi-superfluous, as there's still some remnants of the move-to-context (though these remnants are pretty ok, in my estimation. Maybe some string copying behaviour could be optimised, idk.)

If it works as expected, there should (fingers crossed) be only a few failing tests:

  • ExtensionWebRequestApiPrerenderingTest.Load
  • ExtensionWebRequestApiPrerenderingTest.LoadIntoNewTab (next goal/s)
  • OutOfProcessPPAPITest.URLLoader3
  • PPAPINaClNewlibTest.URLLoader3 (ChromeOS only, so I can't test these locally)

It may be time for a chromestatus.com entry? I feel like there's a lot of implementation-defined behaviour here that would be good to get more eyes on, and I'm planning to be able to work on this for the next 4-5 weeks straight.

File-level comment, Patchset 17:
Andrew Brown . resolved

...ah, I'm terribly sorry - I thought that would just avoid pinging you both again, not delete your reviews entirely :(

Andrew Brown

Done

File services/network/cors/preflight_controller.cc
Line 220, Patchset 21 (Latest): net::HttpRequestHeaders::kUserAgent, *user_agent);
Andrew Brown . unresolved

I think this code has a problem, which is that if the user has set a UA, we don't bother setting the context UA onto the cors_exempt_headers (see below comment in `request_conversion.cc`). So if there's a user UA, a preflight will be sent asking whether UA is an OK header, but *using* the custom UA that the user already set. Which is daft.

I don't know if we can fix it nicely, as I think we avoided setting UA onto both sets of headers in order to avoid merging issues with them later (header lists have no guaranteed merging behaviour, I think?). So we might have to add a special UA hiding spot to the `network::ResourceRequest` too, which is not great.

File third_party/blink/renderer/core/inspector/inspector_network_agent.cc
Line 199, Patchset 21 (Latest): }
Andrew Brown . unresolved

There has to be a better way to use `getString()` here, or use another function instead, but I could not for the life of me find documentation for `DictionaryValue`, and the code I found for it was autogenerated and didn't look like it had much of a better approach available.

Line 1015, Patchset 21 (Latest): headers, std::make_optional(request.GetContextUserAgent())))
Andrew Brown . unresolved

I don't think CORS preflights go through this function, as CORS preflights still appear to be UA-less in Devtools (the actual request still has the header, just the inspector's `Network.requestWillBeSent` event is wrong.)

But also, this behaviour isn't tested ATM (I think?) - the existing tests don't appear to be checking the inspector's view of the preflight, just the network's view of it (in `http/tests/inspector-protocol/emulation/user-agent-override-cors-preflight.js`)

So, outstanding questions (the last of which I can answer myself, given time):

  • Should there be a test for this behaviour (sending the right UA on a preflight, and making sure Devtools sees it too)?
  • Where do preflights spawn into the inspector code? Preflights are spawned in the network process, as best I can tell (code lives in services/network, not third_party/blink), so I don't know how that information gets sent back to the render process's inspector stuff.
Line 1121, Patchset 21 (Latest): .setHeaders(BuildObjectForHeaders(headers_map, std::nullopt))
Andrew Brown . unresolved

I'm also not fully convinced that optionals are what we want here, but it feels better than creating a `BuildObjectForRequestHeaders` function. Maybe not. Thoughts welcome.

File third_party/blink/renderer/core/loader/frame_fetch_context_test.cc
Line 1505, Patchset 14: // EXPECT_EQ("hi", request.HttpHeaderField(http_names::kUserAgent));
Andrew Brown . resolved

This test is funny - it's now always going to fail, because there's simply no need for `PrepareRequest` to put the useragent in the headers. The title of this test implies it's testing something more meaningful than just the user-agent-setting behaviour - what sort of backup should I add instead?

Adam Rice

It's verifying that resetting `dummy_page_holder` results in a call to `client->UserAgent()`. It wants to verify that `"hi"` will actually be set as the User-Agent request header on the request, but I don't know how to do that here.

Andrew Brown

Alright, I fiddled with it in patchset 19, but ended up needing to put the UA *back* into the ResourceRequest (unfortunately) due to inspector protocol things, so the new test just checks that the UA is correctly set inside it's new hiding spot.

Line 1554, Patchset 21 (Latest): PrepareRequestWhenWhenDetached) {
Andrew Brown . unresolved

Typo, will fix in next patchset.

File third_party/blink/renderer/platform/loader/fetch/url_loader/request_conversion.cc
Line 310, Patchset 21 (Latest): }
Andrew Brown . unresolved

See above comment in `preflight_controller.cc` - it's both these pieces of code together.

The key thing is at this point, we can't put the context UA onto the cors_exempt_headers without potentially accepting dodgy merge behaviour later when they get combined. So we have a `network::ResourceRequest` that has a user UA on the normal headers and *no* UA on the cors_exempt headers, which then goes to `preflight_controller`, which uses the user UA.

I guess we could work out where the merge happens and make sure we remove the context UA from the `cors_exempt_headers` *if* the user UA is set? But then we need to make sure preflights avoid copying the user UA, too.

Open in Gerrit

Related details

Attention is currently required from:
  • Adam Rice
  • Bo Liu
  • Min Qin
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement is not satisfiedCode-Owners
  • requirement is not satisfiedCode-Review
  • requirement is not satisfiedNo-Unresolved-Comments
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: chromium/src
Gerrit-Branch: main
Gerrit-Change-Id: Icf56620f99f371ea2f128e6a3194d6096b0d62cd
Gerrit-Change-Number: 5273743
Gerrit-PatchSet: 21
Gerrit-Owner: Andrew Brown <m...@ajbrown.au>
Gerrit-Reviewer: Adam Rice <ri...@chromium.org>
Gerrit-Reviewer: Andrew Brown <m...@ajbrown.au>
Gerrit-Reviewer: Bo Liu <bo...@chromium.org>
Gerrit-Reviewer: Min Qin <qin...@chromium.org>
Gerrit-Reviewer: Takashi Toyoshima <toyo...@chromium.org>
Gerrit-CC: Hiroki Nakagawa <nhi...@chromium.org>
Gerrit-CC: James Maclean <wjma...@chromium.org>
Gerrit-CC: James Su <su...@chromium.org>
Gerrit-CC: Nate Chapin <jap...@chromium.org>
Gerrit-Attention: Bo Liu <bo...@chromium.org>
Gerrit-Attention: Adam Rice <ri...@chromium.org>
Gerrit-Attention: Min Qin <qin...@chromium.org>
Gerrit-Comment-Date: Fri, 27 Jun 2025 02:54:14 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Adam Rice <ri...@chromium.org>
Comment-In-Reply-To: Andrew Brown <m...@ajbrown.au>
satisfied_requirement
unsatisfied_requirement
open
diffy

Adam Rice (Gerrit)

unread,
Jun 27, 2025, 12:17:19 PMJun 27
to Andrew Brown, Min Qin, Bo Liu, Hiroki Nakagawa, Takashi Toyoshima, James Maclean, James Su, AyeAye, Chromium LUCI CQ, chromium...@chromium.org, Nate Chapin, devtools-re...@chromium.org, extension...@chromium.org, chromium-a...@chromium.org, mkwst+w...@chromium.org, horo+...@chromium.org, shimazu+se...@chromium.org, kinuko+ser...@chromium.org, servicewor...@chromium.org, antoniosarto...@chromium.org, kenjibah...@chromium.org, jsbell+ser...@chromium.org, arthursonzog...@chromium.org, blink-revie...@chromium.org, alexmo...@chromium.org, yhanad...@chromium.org, tranbaod...@chromium.org, nona+...@chromium.org, creis...@chromium.org, shuche...@chromium.org, jbauma...@chromium.org, navigation...@chromium.org, keithle...@chromium.org, blink-...@chromium.org, blundell+...@chromium.org, gavinp...@chromium.org, kinuko...@chromium.org, loading-re...@chromium.org, loading...@chromium.org, net-r...@chromium.org, network-ser...@chromium.org
Attention needed from Andrew Brown, Bo Liu and Min Qin

Adam Rice added 2 comments

Patchset-level comments
File-level comment, Patchset 21 (Latest):
Adam Rice . resolved

I think you're going to need to add a DevTools expert as a reviewer to be able to answer some of these questions.

File third_party/blink/renderer/core/inspector/inspector_network_agent.cc
Line 196, Patchset 21 (Latest): if (context_ua.has_value() and
Adam Rice . unresolved

Nit: use `&&` not `and` in C++ code.

Open in Gerrit

Related details

Attention is currently required from:
  • Andrew Brown
  • Bo Liu
  • Min Qin
Gerrit-Attention: Min Qin <qin...@chromium.org>
Gerrit-Attention: Andrew Brown <m...@ajbrown.au>
Gerrit-Comment-Date: Fri, 27 Jun 2025 16:16:50 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
satisfied_requirement
unsatisfied_requirement
open
diffy

Andrew Brown (Gerrit)

unread,
Jul 1, 2025, 2:07:48 AMJul 1
to Alex Rudenko, Adam Rice, Min Qin, Bo Liu, Hiroki Nakagawa, Takashi Toyoshima, James Maclean, James Su, AyeAye, Chromium LUCI CQ, chromium...@chromium.org, Nate Chapin, devtools-re...@chromium.org, extension...@chromium.org, chromium-a...@chromium.org, mkwst+w...@chromium.org, horo+...@chromium.org, shimazu+se...@chromium.org, kinuko+ser...@chromium.org, servicewor...@chromium.org, antoniosarto...@chromium.org, kenjibah...@chromium.org, jsbell+ser...@chromium.org, arthursonzog...@chromium.org, blink-revie...@chromium.org, alexmo...@chromium.org, yhanad...@chromium.org, tranbaod...@chromium.org, nona+...@chromium.org, creis...@chromium.org, shuche...@chromium.org, jbauma...@chromium.org, navigation...@chromium.org, keithle...@chromium.org, blink-...@chromium.org, blundell+...@chromium.org, gavinp...@chromium.org, kinuko...@chromium.org, loading-re...@chromium.org, loading...@chromium.org, net-r...@chromium.org, network-ser...@chromium.org
Attention needed from Adam Rice and Alex Rudenko

Andrew Brown added 3 comments

Patchset-level comments
File-level comment, Patchset 22 (Latest):
Andrew Brown . unresolved

Added Alex Rudenko to review for devtools knowledge... first alphabetical owner, sorry, I get it, my name starts with A too - I have a few changes that touch devtools stuff (in `inspector_network_agent.cc`) that feel like they could be done in smarter ways. Thoughts welcome.

Also if someone could put it through a CQ dry run again that would be hugely appreciated - locally it looks like the devtools changes might have ended up fixing the remaining tests, but it would be good to check.

File third_party/blink/renderer/core/inspector/inspector_network_agent.cc
Line 196, Patchset 21: if (context_ua.has_value() and
Adam Rice . resolved

Nit: use `&&` not `and` in C++ code.

Andrew Brown

Done

File third_party/blink/renderer/core/loader/frame_fetch_context_test.cc
Line 1554, Patchset 21: PrepareRequestWhenWhenDetached) {
Andrew Brown . resolved

Typo, will fix in next patchset.

Andrew Brown

Done

Open in Gerrit

Related details

Attention is currently required from:
  • Adam Rice
  • Alex Rudenko
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement is not satisfiedCode-Owners
  • requirement is not satisfiedCode-Review
  • requirement is not satisfiedNo-Unresolved-Comments
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: chromium/src
Gerrit-Branch: main
Gerrit-Change-Id: Icf56620f99f371ea2f128e6a3194d6096b0d62cd
Gerrit-Change-Number: 5273743
Gerrit-PatchSet: 22
Gerrit-Owner: Andrew Brown <m...@ajbrown.au>
Gerrit-Reviewer: Adam Rice <ri...@chromium.org>
Gerrit-Reviewer: Alex Rudenko <alexr...@chromium.org>
Gerrit-Reviewer: Andrew Brown <m...@ajbrown.au>
Gerrit-Reviewer: Bo Liu <bo...@chromium.org>
Gerrit-Reviewer: Min Qin <qin...@chromium.org>
Gerrit-Reviewer: Takashi Toyoshima <toyo...@chromium.org>
Gerrit-CC: Hiroki Nakagawa <nhi...@chromium.org>
Gerrit-CC: James Maclean <wjma...@chromium.org>
Gerrit-CC: James Su <su...@chromium.org>
Gerrit-CC: Nate Chapin <jap...@chromium.org>
Gerrit-Attention: Adam Rice <ri...@chromium.org>
Gerrit-Attention: Alex Rudenko <alexr...@chromium.org>
Gerrit-Comment-Date: Tue, 01 Jul 2025 06:07:19 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
satisfied_requirement
unsatisfied_requirement
open
diffy

Alex Rudenko (Gerrit)

unread,
Jul 1, 2025, 2:12:49 AMJul 1
to Andrew Brown, Maksim Sadym, Adam Rice, Min Qin, Bo Liu, Hiroki Nakagawa, Takashi Toyoshima, James Maclean, James Su, AyeAye, Chromium LUCI CQ, chromium...@chromium.org, Nate Chapin, devtools-re...@chromium.org, extension...@chromium.org, chromium-a...@chromium.org, mkwst+w...@chromium.org, horo+...@chromium.org, shimazu+se...@chromium.org, kinuko+ser...@chromium.org, servicewor...@chromium.org, antoniosarto...@chromium.org, kenjibah...@chromium.org, jsbell+ser...@chromium.org, arthursonzog...@chromium.org, blink-revie...@chromium.org, alexmo...@chromium.org, yhanad...@chromium.org, tranbaod...@chromium.org, nona+...@chromium.org, creis...@chromium.org, shuche...@chromium.org, jbauma...@chromium.org, navigation...@chromium.org, keithle...@chromium.org, blink-...@chromium.org, blundell+...@chromium.org, gavinp...@chromium.org, kinuko...@chromium.org, loading-re...@chromium.org, loading...@chromium.org, net-r...@chromium.org, network-ser...@chromium.org
Attention needed from Adam Rice, Andrew Brown and Maksim Sadym

Alex Rudenko added 1 comment

Patchset-level comments
Alex Rudenko . resolved

@sa...@chromium.org could you please do the initial round of reviews for the devtools code?

Open in Gerrit

Related details

Attention is currently required from:
  • Adam Rice
  • Andrew Brown
  • Maksim Sadym
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement is not satisfiedCode-Owners
  • requirement is not satisfiedCode-Review
  • requirement is not satisfiedNo-Unresolved-Comments
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: chromium/src
Gerrit-Branch: main
Gerrit-Change-Id: Icf56620f99f371ea2f128e6a3194d6096b0d62cd
Gerrit-Change-Number: 5273743
Gerrit-PatchSet: 22
Gerrit-Owner: Andrew Brown <m...@ajbrown.au>
Gerrit-Reviewer: Adam Rice <ri...@chromium.org>
Gerrit-Reviewer: Alex Rudenko <alexr...@chromium.org>
Gerrit-Reviewer: Andrew Brown <m...@ajbrown.au>
Gerrit-Reviewer: Bo Liu <bo...@chromium.org>
Gerrit-Reviewer: Maksim Sadym <sa...@chromium.org>
Gerrit-Reviewer: Min Qin <qin...@chromium.org>
Gerrit-Reviewer: Takashi Toyoshima <toyo...@chromium.org>
Gerrit-CC: Hiroki Nakagawa <nhi...@chromium.org>
Gerrit-CC: James Maclean <wjma...@chromium.org>
Gerrit-CC: James Su <su...@chromium.org>
Gerrit-CC: Nate Chapin <jap...@chromium.org>
Gerrit-Attention: Adam Rice <ri...@chromium.org>
Gerrit-Attention: Andrew Brown <m...@ajbrown.au>
Gerrit-Attention: Maksim Sadym <sa...@chromium.org>
Gerrit-Comment-Date: Tue, 01 Jul 2025 06:12:31 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
satisfied_requirement
unsatisfied_requirement
open
diffy

Maksim Sadym (Gerrit)

unread,
Jul 1, 2025, 7:59:11 AMJul 1
to Andrew Brown, Adam Rice, Alex Rudenko, Min Qin, Bo Liu, Hiroki Nakagawa, Takashi Toyoshima, James Maclean, James Su, AyeAye, Chromium LUCI CQ, chromium...@chromium.org, Nate Chapin, devtools-re...@chromium.org, extension...@chromium.org, chromium-a...@chromium.org, mkwst+w...@chromium.org, horo+...@chromium.org, shimazu+se...@chromium.org, kinuko+ser...@chromium.org, servicewor...@chromium.org, antoniosarto...@chromium.org, kenjibah...@chromium.org, jsbell+ser...@chromium.org, arthursonzog...@chromium.org, blink-revie...@chromium.org, alexmo...@chromium.org, yhanad...@chromium.org, tranbaod...@chromium.org, nona+...@chromium.org, creis...@chromium.org, shuche...@chromium.org, jbauma...@chromium.org, navigation...@chromium.org, keithle...@chromium.org, blink-...@chromium.org, blundell+...@chromium.org, gavinp...@chromium.org, kinuko...@chromium.org, loading-re...@chromium.org, loading...@chromium.org, net-r...@chromium.org, network-ser...@chromium.org
Attention needed from Adam Rice, Alex Rudenko and Andrew Brown

Maksim Sadym added 1 comment

Patchset-level comments
Alex Rudenko . resolved

@sa...@chromium.org could you please do the initial round of reviews for the devtools code?

Maksim Sadym

Looking in. Need a bit more time for this.

Open in Gerrit

Related details

Attention is currently required from:
  • Adam Rice
  • Alex Rudenko
  • Andrew Brown
Gerrit-Attention: Alex Rudenko <alexr...@chromium.org>
Gerrit-Attention: Andrew Brown <m...@ajbrown.au>
Gerrit-Comment-Date: Tue, 01 Jul 2025 11:58:54 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Alex Rudenko <alexr...@chromium.org>
satisfied_requirement
unsatisfied_requirement
open
diffy

Maksim Sadym (Gerrit)

unread,
Jul 1, 2025, 12:44:39 PMJul 1
to Andrew Brown, Adam Rice, Alex Rudenko, Min Qin, Bo Liu, Hiroki Nakagawa, Takashi Toyoshima, James Maclean, James Su, AyeAye, Chromium LUCI CQ, chromium...@chromium.org, Nate Chapin, devtools-re...@chromium.org, extension...@chromium.org, chromium-a...@chromium.org, mkwst+w...@chromium.org, horo+...@chromium.org, shimazu+se...@chromium.org, kinuko+ser...@chromium.org, servicewor...@chromium.org, antoniosarto...@chromium.org, kenjibah...@chromium.org, jsbell+ser...@chromium.org, arthursonzog...@chromium.org, blink-revie...@chromium.org, alexmo...@chromium.org, yhanad...@chromium.org, tranbaod...@chromium.org, nona+...@chromium.org, creis...@chromium.org, shuche...@chromium.org, jbauma...@chromium.org, navigation...@chromium.org, keithle...@chromium.org, blink-...@chromium.org, blundell+...@chromium.org, gavinp...@chromium.org, kinuko...@chromium.org, loading-re...@chromium.org, loading...@chromium.org, net-r...@chromium.org, network-ser...@chromium.org
Attention needed from Adam Rice, Alex Rudenko and Andrew Brown

Maksim Sadym added 3 comments

Patchset-level comments
Maksim Sadym . resolved

I took a look only at the `.../inspector_network_agent.cc`. I will leave the judgement WRT `GetContextUserAgent` method to the fetch owners.

File third_party/blink/renderer/core/inspector/inspector_network_agent.cc
Line 195, Patchset 22 (Latest): // We need to make special care in the case of outgoing ResourceRequests
Maksim Sadym . unresolved

Please move this block to `BuildObjectForResourceRequest`.

Line 1012, Patchset 22 (Latest): headers.Set(http_names::kReferer, AtomicString(request.ReferrerString()));
Maksim Sadym . unresolved

As long as this is the only place the `context_ua` is set, please move the logic for adding the user agent header from `BuildObjectForHeaders` extra parameter here.

Gerrit-Comment-Date: Tue, 01 Jul 2025 16:44:22 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
satisfied_requirement
unsatisfied_requirement
open
diffy

Alex Rudenko (Gerrit)

unread,
Jul 1, 2025, 1:24:18 PMJul 1
to Andrew Brown, Adam Rice, Maksim Sadym, Min Qin, Bo Liu, Hiroki Nakagawa, Takashi Toyoshima, James Maclean, James Su, AyeAye, Chromium LUCI CQ, chromium...@chromium.org, Nate Chapin, devtools-re...@chromium.org, extension...@chromium.org, chromium-a...@chromium.org, mkwst+w...@chromium.org, horo+...@chromium.org, shimazu+se...@chromium.org, kinuko+ser...@chromium.org, servicewor...@chromium.org, antoniosarto...@chromium.org, kenjibah...@chromium.org, jsbell+ser...@chromium.org, arthursonzog...@chromium.org, blink-revie...@chromium.org, alexmo...@chromium.org, yhanad...@chromium.org, tranbaod...@chromium.org, nona+...@chromium.org, creis...@chromium.org, shuche...@chromium.org, jbauma...@chromium.org, navigation...@chromium.org, keithle...@chromium.org, blink-...@chromium.org, blundell+...@chromium.org, gavinp...@chromium.org, kinuko...@chromium.org, loading-re...@chromium.org, loading...@chromium.org, net-r...@chromium.org, network-ser...@chromium.org
Attention needed from Adam Rice and Andrew Brown

Alex Rudenko added 2 comments

Commit Message
Line 9, Patchset 22 (Latest):Per spec, fetch & XMLHttpRequest should be able to set custom
Alex Rudenko . unresolved

could you please link to the parts of the spec that define this behavior?

File third_party/blink/renderer/core/inspector/inspector_network_agent.cc
Line 1015, Patchset 21: headers, std::make_optional(request.GetContextUserAgent())))
Andrew Brown . unresolved

I don't think CORS preflights go through this function, as CORS preflights still appear to be UA-less in Devtools (the actual request still has the header, just the inspector's `Network.requestWillBeSent` event is wrong.)

But also, this behaviour isn't tested ATM (I think?) - the existing tests don't appear to be checking the inspector's view of the preflight, just the network's view of it (in `http/tests/inspector-protocol/emulation/user-agent-override-cors-preflight.js`)

So, outstanding questions (the last of which I can answer myself, given time):

  • Should there be a test for this behaviour (sending the right UA on a preflight, and making sure Devtools sees it too)?
  • Where do preflights spawn into the inspector code? Preflights are spawned in the network process, as best I can tell (code lives in services/network, not third_party/blink), so I don't know how that information gets sent back to the render process's inspector stuff.
Alex Rudenko

I do not think we need to add extra headers in this event. We have requestWillBeSentExtraInfo that should report actual headers set by the network service. Could you please clarify why requestWillBeSentExtraInfo is not sufficient here?

Open in Gerrit

Related details

Attention is currently required from:
  • Adam Rice
  • Andrew Brown
Gerrit-Attention: Andrew Brown <m...@ajbrown.au>
Gerrit-Comment-Date: Tue, 01 Jul 2025 17:24:00 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Andrew Brown <m...@ajbrown.au>
satisfied_requirement
unsatisfied_requirement
open
diffy

Andrew Brown (Gerrit)

unread,
Jul 3, 2025, 12:31:05 AMJul 3
to Adam Rice, Maksim Sadym, Alex Rudenko, Min Qin, Bo Liu, Hiroki Nakagawa, Takashi Toyoshima, James Maclean, James Su, AyeAye, Chromium LUCI CQ, chromium...@chromium.org, Nate Chapin, devtools-re...@chromium.org, extension...@chromium.org, chromium-a...@chromium.org, mkwst+w...@chromium.org, horo+...@chromium.org, shimazu+se...@chromium.org, kinuko+ser...@chromium.org, servicewor...@chromium.org, antoniosarto...@chromium.org, kenjibah...@chromium.org, jsbell+ser...@chromium.org, arthursonzog...@chromium.org, blink-revie...@chromium.org, alexmo...@chromium.org, yhanad...@chromium.org, tranbaod...@chromium.org, nona+...@chromium.org, creis...@chromium.org, shuche...@chromium.org, jbauma...@chromium.org, navigation...@chromium.org, keithle...@chromium.org, blink-...@chromium.org, blundell+...@chromium.org, gavinp...@chromium.org, kinuko...@chromium.org, loading-re...@chromium.org, loading...@chromium.org, net-r...@chromium.org, network-ser...@chromium.org
Attention needed from Adam Rice, Alex Rudenko and Maksim Sadym

Andrew Brown added 7 comments

Patchset-level comments
File-level comment, Patchset 23 (Latest):
Andrew Brown . resolved

I've spent all week compiling and attempting to test and recompiling. I still have no clue if it's actually better, but it will at least not have the stupid failures the last CL run had (the bad optional access stuff) - if someone would be so kind as to hit the tryjob button that would probably save me ~6 more hours running stuff locally...

Commit Message
Line 9, Patchset 22:Per spec, fetch & XMLHttpRequest should be able to set custom
Alex Rudenko . unresolved

could you please link to the parts of the spec that define this behavior?

Andrew Brown

It all derives from https://fetch.spec.whatwg.org/#forbidden-request-header -- this list was updated to remove User-Agent in 2015.

Now User-Agent isn't forbidden, it should be settable by users, and should not be on `net/http/http_util.cc`'s forbidden header list.

Unfortunately, once you remove it from that list, it also starts always generating CORS preflights. Whether it should send preflights is not directly answered by the spec (it's ambiguous), but we are emulating Firefox's behaviour, as it seems unintuitive to send preflights for every single fetch request ever asking for "User-Agent". Plus, it will break large swathes of the web for things that aren't expecting to have to explicitly say that "User-Agent" is OK.

There's other discussion on this CL about this, but to summarise where we're at:

  • user-agent set by user: preflight sent
  • user-agent set by devtools or browser: no preflight sent

So the solution to the CORS issue is that we take the (devtools or browser) UA from the FetchContext, and instead of putting it straight in the headers, we have to hide it around until we get to a state where it won't trigger a CORS preflight.

Unfortunately this means I've had to run around to a heap of random spots and make sure they're looking in the new spot for the UA, but eh. I probably have to update that description to summarise the new behaviour soon, as it seems to change every 2nd patchset.

File third_party/blink/renderer/core/inspector/inspector_network_agent.cc
Line 195, Patchset 22: // We need to make special care in the case of outgoing ResourceRequests
Maksim Sadym . resolved

Please move this block to `BuildObjectForResourceRequest`.

Andrew Brown

Done - your approach looks miles better.

Line 199, Patchset 21: }
Andrew Brown . resolved

There has to be a better way to use `getString()` here, or use another function instead, but I could not for the life of me find documentation for `DictionaryValue`, and the code I found for it was autogenerated and didn't look like it had much of a better approach available.

Andrew Brown

Done

Line 1012, Patchset 22: headers.Set(http_names::kReferer, AtomicString(request.ReferrerString()));
Maksim Sadym . resolved

As long as this is the only place the `context_ua` is set, please move the logic for adding the user agent header from `BuildObjectForHeaders` extra parameter here.

Andrew Brown

Yeah, it is - moved over, done!

Line 1015, Patchset 21: headers, std::make_optional(request.GetContextUserAgent())))
Andrew Brown . unresolved

I don't think CORS preflights go through this function, as CORS preflights still appear to be UA-less in Devtools (the actual request still has the header, just the inspector's `Network.requestWillBeSent` event is wrong.)

But also, this behaviour isn't tested ATM (I think?) - the existing tests don't appear to be checking the inspector's view of the preflight, just the network's view of it (in `http/tests/inspector-protocol/emulation/user-agent-override-cors-preflight.js`)

So, outstanding questions (the last of which I can answer myself, given time):

  • Should there be a test for this behaviour (sending the right UA on a preflight, and making sure Devtools sees it too)?
  • Where do preflights spawn into the inspector code? Preflights are spawned in the network process, as best I can tell (code lives in services/network, not third_party/blink), so I don't know how that information gets sent back to the render process's inspector stuff.
Alex Rudenko

I do not think we need to add extra headers in this event. We have requestWillBeSentExtraInfo that should report actual headers set by the network service. Could you please clarify why requestWillBeSentExtraInfo is not sufficient here?

Andrew Brown

I'll be honest I am completely unfamiliar with DevTools and didn't know that existed; everything that I've done has been prompted by a few failing tests. My impression (and these changes) are to solve the fact that the new, cors-free "hiding" spot for the UA also needs to be given to the inspector.

Looking at requestWillBeSentExtraInfo, that seems like exactly what we want here, but this will require some tests to be updated - there's at least 8 tests failing in `web_tests/http/tests/inspector_protocol` that all are expecting a User-Agent to be present on the original `requestWillBeSent` event (which it won't be, anymore).

I could update those 8 tests to check requestWillBeSentExtraInfo, and then ensure the User-Agent is present there?

Line 1121, Patchset 21: .setHeaders(BuildObjectForHeaders(headers_map, std::nullopt))
Andrew Brown . resolved

I'm also not fully convinced that optionals are what we want here, but it feels better than creating a `BuildObjectForRequestHeaders` function. Maybe not. Thoughts welcome.

Andrew Brown

Done

Open in Gerrit

Related details

Attention is currently required from:
  • Adam Rice
  • Alex Rudenko
  • Maksim Sadym
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement is not satisfiedCode-Owners
  • requirement is not satisfiedCode-Review
  • requirement is not satisfiedNo-Unresolved-Comments
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: chromium/src
Gerrit-Branch: main
Gerrit-Change-Id: Icf56620f99f371ea2f128e6a3194d6096b0d62cd
Gerrit-Change-Number: 5273743
Gerrit-PatchSet: 23
Gerrit-Owner: Andrew Brown <m...@ajbrown.au>
Gerrit-Reviewer: Adam Rice <ri...@chromium.org>
Gerrit-Reviewer: Alex Rudenko <alexr...@chromium.org>
Gerrit-Reviewer: Andrew Brown <m...@ajbrown.au>
Gerrit-Reviewer: Bo Liu <bo...@chromium.org>
Gerrit-Reviewer: Maksim Sadym <sa...@chromium.org>
Gerrit-Reviewer: Min Qin <qin...@chromium.org>
Gerrit-Reviewer: Takashi Toyoshima <toyo...@chromium.org>
Gerrit-CC: Hiroki Nakagawa <nhi...@chromium.org>
Gerrit-CC: James Maclean <wjma...@chromium.org>
Gerrit-CC: James Su <su...@chromium.org>
Gerrit-CC: Nate Chapin <jap...@chromium.org>
Gerrit-Attention: Alex Rudenko <alexr...@chromium.org>
Gerrit-Attention: Adam Rice <ri...@chromium.org>
Gerrit-Attention: Maksim Sadym <sa...@chromium.org>
Gerrit-Comment-Date: Thu, 03 Jul 2025 04:30:35 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Alex Rudenko <alexr...@chromium.org>
Comment-In-Reply-To: Andrew Brown <m...@ajbrown.au>
Comment-In-Reply-To: Maksim Sadym <sa...@chromium.org>
satisfied_requirement
unsatisfied_requirement
open
diffy

Alex Rudenko (Gerrit)

unread,
Jul 3, 2025, 1:24:45 AMJul 3
to Andrew Brown, Adam Rice, Maksim Sadym, Min Qin, Bo Liu, Hiroki Nakagawa, Takashi Toyoshima, James Maclean, James Su, AyeAye, Chromium LUCI CQ, chromium...@chromium.org, Nate Chapin, devtools-re...@chromium.org, extension...@chromium.org, chromium-a...@chromium.org, mkwst+w...@chromium.org, horo+...@chromium.org, shimazu+se...@chromium.org, kinuko+ser...@chromium.org, servicewor...@chromium.org, antoniosarto...@chromium.org, kenjibah...@chromium.org, jsbell+ser...@chromium.org, arthursonzog...@chromium.org, blink-revie...@chromium.org, alexmo...@chromium.org, yhanad...@chromium.org, tranbaod...@chromium.org, nona+...@chromium.org, creis...@chromium.org, shuche...@chromium.org, jbauma...@chromium.org, navigation...@chromium.org, keithle...@chromium.org, blink-...@chromium.org, blundell+...@chromium.org, gavinp...@chromium.org, kinuko...@chromium.org, loading-re...@chromium.org, loading...@chromium.org, net-r...@chromium.org, network-ser...@chromium.org
Attention needed from Adam Rice, Andrew Brown and Maksim Sadym

Alex Rudenko added 1 comment

File third_party/blink/renderer/core/inspector/inspector_network_agent.cc
Line 1015, Patchset 21: headers, std::make_optional(request.GetContextUserAgent())))
Andrew Brown . unresolved

I don't think CORS preflights go through this function, as CORS preflights still appear to be UA-less in Devtools (the actual request still has the header, just the inspector's `Network.requestWillBeSent` event is wrong.)

But also, this behaviour isn't tested ATM (I think?) - the existing tests don't appear to be checking the inspector's view of the preflight, just the network's view of it (in `http/tests/inspector-protocol/emulation/user-agent-override-cors-preflight.js`)

So, outstanding questions (the last of which I can answer myself, given time):

  • Should there be a test for this behaviour (sending the right UA on a preflight, and making sure Devtools sees it too)?
  • Where do preflights spawn into the inspector code? Preflights are spawned in the network process, as best I can tell (code lives in services/network, not third_party/blink), so I don't know how that information gets sent back to the render process's inspector stuff.
Alex Rudenko

I do not think we need to add extra headers in this event. We have requestWillBeSentExtraInfo that should report actual headers set by the network service. Could you please clarify why requestWillBeSentExtraInfo is not sufficient here?

Andrew Brown

I'll be honest I am completely unfamiliar with DevTools and didn't know that existed; everything that I've done has been prompted by a few failing tests. My impression (and these changes) are to solve the fact that the new, cors-free "hiding" spot for the UA also needs to be given to the inspector.

Looking at requestWillBeSentExtraInfo, that seems like exactly what we want here, but this will require some tests to be updated - there's at least 8 tests failing in `web_tests/http/tests/inspector_protocol` that all are expecting a User-Agent to be present on the original `requestWillBeSent` event (which it won't be, anymore).

I could update those 8 tests to check requestWillBeSentExtraInfo, and then ensure the User-Agent is present there?

Alex Rudenko

I think it would be better to not special case the header when reporting from the renderer and update the tests that do not contain the header anymore and make sure that ExtraInfo events from the network service actually contain the correct user agent header via a new test. I would suggest the network reviewers to review the non-DevTools changes first to make sure those are correct.

Open in Gerrit

Related details

Attention is currently required from:
  • Adam Rice
  • Andrew Brown
  • Maksim Sadym
Gerrit-Attention: Adam Rice <ri...@chromium.org>
Gerrit-Attention: Andrew Brown <m...@ajbrown.au>
Gerrit-Attention: Maksim Sadym <sa...@chromium.org>
Gerrit-Comment-Date: Thu, 03 Jul 2025 05:24:31 +0000
satisfied_requirement
unsatisfied_requirement
open
diffy

Alex Rudenko (Gerrit)

unread,
Jul 3, 2025, 8:18:05 AMJul 3
to Andrew Brown, Adam Rice, Maksim Sadym, Min Qin, Bo Liu, Hiroki Nakagawa, Takashi Toyoshima, James Maclean, James Su, AyeAye, Chromium LUCI CQ, chromium...@chromium.org, Nate Chapin, devtools-re...@chromium.org, extension...@chromium.org, chromium-a...@chromium.org, mkwst+w...@chromium.org, horo+...@chromium.org, shimazu+se...@chromium.org, kinuko+ser...@chromium.org, servicewor...@chromium.org, antoniosarto...@chromium.org, kenjibah...@chromium.org, jsbell+ser...@chromium.org, arthursonzog...@chromium.org, blink-revie...@chromium.org, alexmo...@chromium.org, yhanad...@chromium.org, tranbaod...@chromium.org, nona+...@chromium.org, creis...@chromium.org, shuche...@chromium.org, jbauma...@chromium.org, navigation...@chromium.org, keithle...@chromium.org, blink-...@chromium.org, blundell+...@chromium.org, gavinp...@chromium.org, kinuko...@chromium.org, loading-re...@chromium.org, loading...@chromium.org, net-r...@chromium.org, network-ser...@chromium.org
Attention needed from Adam Rice, Andrew Brown and Maksim Sadym

Alex Rudenko added 1 comment

File third_party/blink/renderer/core/inspector/inspector_network_agent.cc
Line 1015, Patchset 21: headers, std::make_optional(request.GetContextUserAgent())))
Andrew Brown . unresolved

I don't think CORS preflights go through this function, as CORS preflights still appear to be UA-less in Devtools (the actual request still has the header, just the inspector's `Network.requestWillBeSent` event is wrong.)

But also, this behaviour isn't tested ATM (I think?) - the existing tests don't appear to be checking the inspector's view of the preflight, just the network's view of it (in `http/tests/inspector-protocol/emulation/user-agent-override-cors-preflight.js`)

So, outstanding questions (the last of which I can answer myself, given time):

  • Should there be a test for this behaviour (sending the right UA on a preflight, and making sure Devtools sees it too)?
  • Where do preflights spawn into the inspector code? Preflights are spawned in the network process, as best I can tell (code lives in services/network, not third_party/blink), so I don't know how that information gets sent back to the render process's inspector stuff.
Alex Rudenko

I do not think we need to add extra headers in this event. We have requestWillBeSentExtraInfo that should report actual headers set by the network service. Could you please clarify why requestWillBeSentExtraInfo is not sufficient here?

Andrew Brown

I'll be honest I am completely unfamiliar with DevTools and didn't know that existed; everything that I've done has been prompted by a few failing tests. My impression (and these changes) are to solve the fact that the new, cors-free "hiding" spot for the UA also needs to be given to the inspector.

Looking at requestWillBeSentExtraInfo, that seems like exactly what we want here, but this will require some tests to be updated - there's at least 8 tests failing in `web_tests/http/tests/inspector_protocol` that all are expecting a User-Agent to be present on the original `requestWillBeSent` event (which it won't be, anymore).

I could update those 8 tests to check requestWillBeSentExtraInfo, and then ensure the User-Agent is present there?

Alex Rudenko

I think it would be better to not special case the header when reporting from the renderer and update the tests that do not contain the header anymore and make sure that ExtraInfo events from the network service actually contain the correct user agent header via a new test. I would suggest the network reviewers to review the non-DevTools changes first to make sure those are correct.

Alex Rudenko

I was reviewing it again and the user agent actually is set by the client code, right? I wonder why is it no present in `request.HttpHeaderFields()`? It does sound like it should contain it if it is provided by the client.

Gerrit-Comment-Date: Thu, 03 Jul 2025 12:17:49 +0000
satisfied_requirement
unsatisfied_requirement
open
diffy

Alex Rudenko (Gerrit)

unread,
Jul 3, 2025, 8:20:16 AMJul 3
to Andrew Brown, Adam Rice, Maksim Sadym, Min Qin, Bo Liu, Hiroki Nakagawa, Takashi Toyoshima, James Maclean, James Su, AyeAye, Chromium LUCI CQ, chromium...@chromium.org, Nate Chapin, devtools-re...@chromium.org, extension...@chromium.org, chromium-a...@chromium.org, mkwst+w...@chromium.org, horo+...@chromium.org, shimazu+se...@chromium.org, kinuko+ser...@chromium.org, servicewor...@chromium.org, antoniosarto...@chromium.org, kenjibah...@chromium.org, jsbell+ser...@chromium.org, arthursonzog...@chromium.org, blink-revie...@chromium.org, alexmo...@chromium.org, yhanad...@chromium.org, tranbaod...@chromium.org, nona+...@chromium.org, creis...@chromium.org, shuche...@chromium.org, jbauma...@chromium.org, navigation...@chromium.org, keithle...@chromium.org, blink-...@chromium.org, blundell+...@chromium.org, gavinp...@chromium.org, kinuko...@chromium.org, loading-re...@chromium.org, loading...@chromium.org, net-r...@chromium.org, network-ser...@chromium.org
Attention needed from Adam Rice, Andrew Brown and Maksim Sadym

Alex Rudenko added 1 comment

File third_party/blink/renderer/platform/loader/fetch/resource_request.h
Line 231, Patchset 23 (Latest): context_user_agent_header_ = user_agent;
Alex Rudenko . unresolved

should this still write to the http header field via SetHttpHeaderField even if we need context_user_agent_header_ for the other logic?

Gerrit-Comment-Date: Thu, 03 Jul 2025 12:20:03 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
satisfied_requirement
unsatisfied_requirement
open
diffy

Andrew Brown (Gerrit)

unread,
Jul 3, 2025, 9:17:47 AMJul 3
to Adam Rice, Maksim Sadym, Alex Rudenko, Min Qin, Bo Liu, Hiroki Nakagawa, Takashi Toyoshima, James Maclean, James Su, AyeAye, Chromium LUCI CQ, chromium...@chromium.org, Nate Chapin, devtools-re...@chromium.org, extension...@chromium.org, chromium-a...@chromium.org, mkwst+w...@chromium.org, horo+...@chromium.org, shimazu+se...@chromium.org, kinuko+ser...@chromium.org, servicewor...@chromium.org, antoniosarto...@chromium.org, kenjibah...@chromium.org, jsbell+ser...@chromium.org, arthursonzog...@chromium.org, blink-revie...@chromium.org, alexmo...@chromium.org, yhanad...@chromium.org, tranbaod...@chromium.org, nona+...@chromium.org, creis...@chromium.org, shuche...@chromium.org, jbauma...@chromium.org, navigation...@chromium.org, keithle...@chromium.org, blink-...@chromium.org, blundell+...@chromium.org, gavinp...@chromium.org, kinuko...@chromium.org, loading-re...@chromium.org, loading...@chromium.org, net-r...@chromium.org, network-ser...@chromium.org
Attention needed from Adam Rice, Alex Rudenko and Maksim Sadym

Andrew Brown added 2 comments

File third_party/blink/renderer/core/inspector/inspector_network_agent.cc
Line 1015, Patchset 21: headers, std::make_optional(request.GetContextUserAgent())))
Andrew Brown . unresolved

I don't think CORS preflights go through this function, as CORS preflights still appear to be UA-less in Devtools (the actual request still has the header, just the inspector's `Network.requestWillBeSent` event is wrong.)

But also, this behaviour isn't tested ATM (I think?) - the existing tests don't appear to be checking the inspector's view of the preflight, just the network's view of it (in `http/tests/inspector-protocol/emulation/user-agent-override-cors-preflight.js`)

So, outstanding questions (the last of which I can answer myself, given time):

  • Should there be a test for this behaviour (sending the right UA on a preflight, and making sure Devtools sees it too)?
  • Where do preflights spawn into the inspector code? Preflights are spawned in the network process, as best I can tell (code lives in services/network, not third_party/blink), so I don't know how that information gets sent back to the render process's inspector stuff.
Alex Rudenko

I do not think we need to add extra headers in this event. We have requestWillBeSentExtraInfo that should report actual headers set by the network service. Could you please clarify why requestWillBeSentExtraInfo is not sufficient here?

Andrew Brown

I'll be honest I am completely unfamiliar with DevTools and didn't know that existed; everything that I've done has been prompted by a few failing tests. My impression (and these changes) are to solve the fact that the new, cors-free "hiding" spot for the UA also needs to be given to the inspector.

Looking at requestWillBeSentExtraInfo, that seems like exactly what we want here, but this will require some tests to be updated - there's at least 8 tests failing in `web_tests/http/tests/inspector_protocol` that all are expecting a User-Agent to be present on the original `requestWillBeSent` event (which it won't be, anymore).

I could update those 8 tests to check requestWillBeSentExtraInfo, and then ensure the User-Agent is present there?

Alex Rudenko

I think it would be better to not special case the header when reporting from the renderer and update the tests that do not contain the header anymore and make sure that ExtraInfo events from the network service actually contain the correct user agent header via a new test. I would suggest the network reviewers to review the non-DevTools changes first to make sure those are correct.

Alex Rudenko

I was reviewing it again and the user agent actually is set by the client code, right? I wonder why is it no present in `request.HttpHeaderFields()`? It does sound like it should contain it if it is provided by the client.

Andrew Brown

I'm not sure if I'm interpreting this right, but I'll attempt to explain; let me know if this helps. (My terminology is crappy, sorry; it's hard to overcome my non-chromium intuition of the definitions of "browser" and "client".)

Firstly, you're right, the user-agent is set javascript code onto the normal `request.HttpHeaderFields()`. But, any User-Agent value that exists in these headers will cause a CORS OPTIONS request. (The reason it doesn't do this in real Chrome right now is because of the list in `/net/http/http_util.cc`, but that's like, the actual spec bug we're fixing.)

If we put our internal value (the one that looks like `Mozilla/5.0 Chrome 140.0` etc etc) onto those headers, we'll end up triggering a CORS preflight request on every single web request we ever make.

So we have to put our internal value somewhere else, so that it can be all combined together later. That somewhere else is (for the moment) the `request.GetContextUserAgent()` (named because the internal value comes from the `FetchContext`).

Unfortunately, anywhere that we can put the UA that hides it from CORS, also hides it from a lot of other things (including DevTools).

The alternative approach was to send the context value straight to the network process later on (patchset 19), but I thought I had to make sure it was accessible through a blink::ResourceRequest somewhere in order for DevTools to see it... *but* now I've learned that it's ok for DevTools to just get it in requestWillBeSentExtraInfo later on. So I think I'm going back to the patchset 19 approach.

File third_party/blink/renderer/platform/loader/fetch/resource_request.h
Line 231, Patchset 23 (Latest): context_user_agent_header_ = user_agent;
Alex Rudenko . unresolved

should this still write to the http header field via SetHttpHeaderField even if we need context_user_agent_header_ for the other logic?

Andrew Brown

I attempted to explain in the other comment. In brief, we have to have a separate ContextUserAgent that isn't just an ordinary http header because if we put the special browser user-agent into the ordinary http headers, we end up making CORS preflights on every single request, which is bad.

Thanks to the suggestion you made about requestWillBeSetExtraInfo, I'm probably going to go back to the approach in patchset 19, where the browser/context/safe User-Agent goes straight onto the `network::ResourceRequest` and doesn't need any special-casing inside resource_request.h.

So the `SetContextUserAgent()` stuff is not long for this world - I'll get to it tomorrow (AEST), and once that's uploaded, I'll re-ping Adam & Takashi to get another do-over/more thoughts from the network/fetch side. The context-based approach was their suggestion to begin with, but it will inevitably need some tweaks for some weirder (& worse) preflight behaviour that the DevTools testing made me spot.

Open in Gerrit

Related details

Attention is currently required from:
  • Adam Rice
  • Alex Rudenko
  • Maksim Sadym
Gerrit-Attention: Alex Rudenko <alexr...@chromium.org>
Gerrit-Attention: Adam Rice <ri...@chromium.org>
Gerrit-Attention: Maksim Sadym <sa...@chromium.org>
Gerrit-Comment-Date: Thu, 03 Jul 2025 13:17:23 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
satisfied_requirement
unsatisfied_requirement
open
diffy

Andrew Brown (Gerrit)

unread,
Jul 4, 2025, 4:30:12 AMJul 4
to Adam Rice, Maksim Sadym, Alex Rudenko, Min Qin, Bo Liu, Hiroki Nakagawa, Takashi Toyoshima, James Maclean, James Su, AyeAye, Chromium LUCI CQ, chromium...@chromium.org, Nate Chapin, devtools-re...@chromium.org, extension...@chromium.org, chromium-a...@chromium.org, mkwst+w...@chromium.org, horo+...@chromium.org, shimazu+se...@chromium.org, kinuko+ser...@chromium.org, servicewor...@chromium.org, antoniosarto...@chromium.org, kenjibah...@chromium.org, jsbell+ser...@chromium.org, arthursonzog...@chromium.org, blink-revie...@chromium.org, alexmo...@chromium.org, yhanad...@chromium.org, tranbaod...@chromium.org, nona+...@chromium.org, creis...@chromium.org, shuche...@chromium.org, jbauma...@chromium.org, navigation...@chromium.org, keithle...@chromium.org, blink-...@chromium.org, blundell+...@chromium.org, gavinp...@chromium.org, kinuko...@chromium.org, loading-re...@chromium.org, loading...@chromium.org, net-r...@chromium.org, network-ser...@chromium.org
Attention needed from Adam Rice, Alex Rudenko and Takashi Toyoshima

Andrew Brown added 8 comments

Patchset-level comments
File-level comment, Patchset 14:
Andrew Brown . resolved

Happy new year everyone! Apologies for dragging this up right as everyone returns from a well-deserved break :)

Figured I could use some of my summer free time to close this out for good. I worked out (some of, hopefully all) the failing devtools tests, which needed changes inside the preflight-summoning code - tagged Min Qin for review. I'm a little wary that I ended up needing to have weird case handling in the preflight code.

I have two outstanding questions:

  • I've commented out the assertion in a test for frame_fetch_context. It's expecting that the User-Agent is set after calling PrepareRequest, but because this CL moves it to its own thing, that's no longer the case. Is this test checking something "deeper" that I should work out, or can it be safely removed? (I suspect this is the root cause of a few other test failures, but I never have been able to accurately run the full suite locally.)
  • Do my cases for User-Agent handling make sense: a fetch-set User-Agent overrides a devtools User-Agent overrides the default? I think we've settled this, but it may be different when you consider which User-Agent should be present on preflight OPTIONS requests. At this point, it follows the same order.
Andrew Brown

Ok, not quite all the failing devtools tests :(

Some remaining failures I've traced back down to `ThrottlingURLLoader::StartNow()`, where it enters IPC/inheritance hell. I am almost willing to bet this will characterise all the remianing failures: issues in the various implementations of `URLLoaderFactory::CreateLoaderAndStart`.

Basically, I have reason to believe there are one or more `URLLoader` implementations that don't combine the `cors_exempt_headers` in with the normal `headers` on a request - similar to the change I've already made in `preflight_controller.cc`. There are different `URLLoader`'s for different things, and I bet the one that deals with extensions will have a problem, and so will the one that deals with non-returning delayed requests for `fetchLater()`.

Do you have any tips for tracking down which one(s) live on the path below the DevTools (and extension) code? The debug docs are fantastic for working bottom-up, where you have a crash and you need to work out where, but not so helpful for working top-down, where I have correct behaviour and I don't know where it stops.

There are ~43 different types of `CreateLoaderAndStart` that could lead to my problem, each with their own very large stack of behaviour, and often calling into each other in hard-to-grasp ways. I can work through them eventually, but it's going to take a long time.

Andrew Brown

I was *almost* correct; I actually had to tell the parallel stack that the inspector protocol uses, that it still needs to go find the UA elsewhere.

This means unfortunately all the work to keep the UA inside the FetchContext is useless, because the inspector protocol has no idea what context the request was made in, so there's just no way that the context-based approach is compatible with the behaviour inspector needs. I've gone back to the *original* way I did it, with a new field on the ResourceRequest.

This lets us keep basically all of the original behaviour (stuff like PrepareRequest being the function call that actually sets the UA onto the blink::ResourceRequest, instead of it happening much later when populating the network::ResourceRequest). So a lot of this CL is now semi-superfluous, as there's still some remnants of the move-to-context (though these remnants are pretty ok, in my estimation. Maybe some string copying behaviour could be optimised, idk.)

If it works as expected, there should (fingers crossed) be only a few failing tests:

  • ExtensionWebRequestApiPrerenderingTest.Load
  • ExtensionWebRequestApiPrerenderingTest.LoadIntoNewTab (next goal/s)
  • OutOfProcessPPAPITest.URLLoader3
  • PPAPINaClNewlibTest.URLLoader3 (ChromeOS only, so I can't test these locally)

It may be time for a chromestatus.com entry? I feel like there's a lot of implementation-defined behaviour here that would be good to get more eyes on, and I'm planning to be able to work on this for the next 4-5 weeks straight.

Andrew Brown

Done

File-level comment, Patchset 22:
Andrew Brown . resolved

Added Alex Rudenko to review for devtools knowledge... first alphabetical owner, sorry, I get it, my name starts with A too - I have a few changes that touch devtools stuff (in `inspector_network_agent.cc`) that feel like they could be done in smarter ways. Thoughts welcome.

Also if someone could put it through a CQ dry run again that would be hugely appreciated - locally it looks like the devtools changes might have ended up fixing the remaining tests, but it would be good to check.

Andrew Brown

Done

File-level comment, Patchset 24:
Andrew Brown . unresolved

Basically everything except a handful of Extension tests (discussed soon) should pass now -- @ Adam, CQ dry run please?

That said, I have a few outstanding questions that may need broader conversations to resolve. I don't know if these are answerable with the reviewers I already have, or whether this is time for a chromestatus.com entry and/or emails to other mailing lists for different areas.

  • comments in `request_conversion.cc` are wondering how best to get the context UA over to the network process for OPTIONS requests to use
  • comments in `framework.js` are wondering what to do about any tests that rely/relied on DevTools for stuff
  • comments in `frame_fetch_context_test.cc` are wondering whether the new version of `PrepareRequestWhenDetached` is even remotely useful or sensible

Importantly, though:

  • lots of tests have changed, especially those that relied on DevTools to see UAs in a `requestWillBeSent` event. How many new tests or modifications to old tests, are needed to make sure the UA is still present on a `requestWillBeSentExtraInfo`?
  • followup, which cases are sufficiently distinct that they're worth different tests for this? I've edited tests that involve redirects, cross-site redirects, etc etc -- can we assume it's all good with one more test for "UA on ExtraInfo" or do we need "UA on ExtraInfo for redirects", "UA on ExtraInfo for preflights", etc?
Commit Message
Line 9, Patchset 22:Per spec, fetch & XMLHttpRequest should be able to set custom
Alex Rudenko . resolved

could you please link to the parts of the spec that define this behavior?

Andrew Brown

It all derives from https://fetch.spec.whatwg.org/#forbidden-request-header -- this list was updated to remove User-Agent in 2015.

Now User-Agent isn't forbidden, it should be settable by users, and should not be on `net/http/http_util.cc`'s forbidden header list.

Unfortunately, once you remove it from that list, it also starts always generating CORS preflights. Whether it should send preflights is not directly answered by the spec (it's ambiguous), but we are emulating Firefox's behaviour, as it seems unintuitive to send preflights for every single fetch request ever asking for "User-Agent". Plus, it will break large swathes of the web for things that aren't expecting to have to explicitly say that "User-Agent" is OK.

There's other discussion on this CL about this, but to summarise where we're at:

  • user-agent set by user: preflight sent
  • user-agent set by devtools or browser: no preflight sent

So the solution to the CORS issue is that we take the (devtools or browser) UA from the FetchContext, and instead of putting it straight in the headers, we have to hide it around until we get to a state where it won't trigger a CORS preflight.

Unfortunately this means I've had to run around to a heap of random spots and make sure they're looking in the new spot for the UA, but eh. I probably have to update that description to summarise the new behaviour soon, as it seems to change every 2nd patchset.

Andrew Brown

Description is back to being accurate now...

File chrome/test/data/extensions/api_test/webrequest/framework.js
Line 296, Patchset 25 (Latest):function checkUserAgent(headers) {
Andrew Brown . unresolved

This is the root cause of a couple remaining failures:

  • ExtensionWebRequestApiPrerenderingTest.Load
  • ExtensionWebRequestApiPrerenderingTest.LoadIntoNewTab

They're using User-Agent as a litmus test for whether the headers on a request are valid, which is fine, but User-Agent is not going to be present on a DevTools "requestWillBeSent" event anymore. So we need a new way to do this.

File third_party/blink/renderer/core/loader/frame_fetch_context_test.cc
Line 1565, Patchset 25 (Latest): EXPECT_EQ("hi", GetFetchContext()->GetDefaultUserAgent());
Andrew Brown . unresolved

I would resurrect my comments from patchset 14, but they don't link through to the new code.

Is this test sensible? I feel like it's not, because the name suggests to me that instead of checking UA the new way, we should instead be looking at whether PrepareRequest does it's job -- just using a different litmus test than User-Agent. Advice welcome.

File third_party/blink/renderer/platform/loader/fetch/resource_request.h
Line 231, Patchset 23: context_user_agent_header_ = user_agent;
Alex Rudenko . resolved

should this still write to the http header field via SetHttpHeaderField even if we need context_user_agent_header_ for the other logic?

Andrew Brown

I attempted to explain in the other comment. In brief, we have to have a separate ContextUserAgent that isn't just an ordinary http header because if we put the special browser user-agent into the ordinary http headers, we end up making CORS preflights on every single request, which is bad.

Thanks to the suggestion you made about requestWillBeSetExtraInfo, I'm probably going to go back to the approach in patchset 19, where the browser/context/safe User-Agent goes straight onto the `network::ResourceRequest` and doesn't need any special-casing inside resource_request.h.

So the `SetContextUserAgent()` stuff is not long for this world - I'll get to it tomorrow (AEST), and once that's uploaded, I'll re-ping Adam & Takashi to get another do-over/more thoughts from the network/fetch side. The context-based approach was their suggestion to begin with, but it will inevitably need some tweaks for some weirder (& worse) preflight behaviour that the DevTools testing made me spot.

Andrew Brown

Now updated and removed.

File third_party/blink/renderer/platform/loader/fetch/url_loader/request_conversion.cc
Andrew Brown . unresolved

See above comment in `preflight_controller.cc` - it's both these pieces of code together.

The key thing is at this point, we can't put the context UA onto the cors_exempt_headers without potentially accepting dodgy merge behaviour later when they get combined. So we have a `network::ResourceRequest` that has a user UA on the normal headers and *no* UA on the cors_exempt headers, which then goes to `preflight_controller`, which uses the user UA.

I guess we could work out where the merge happens and make sure we remove the context UA from the `cors_exempt_headers` *if* the user UA is set? But then we need to make sure preflights avoid copying the user UA, too.

Andrew Brown

So the state of affairs is thus:

  • If the user provides a UA, it sits on the normal headers. In `request_conversion.cc`, we *can't* put the context UA onto the cors_exempt_headers, because that will actually clobber the user-provided one.
  • If the user doesn't provide a UA, then this code does exactly what it says; there are no issues here about different handling of a DevTools-set value vs an intrinsic browser value.

But then, later (in `preflight_controller.cc`):

  • If the user didn't provide a UA, then the context UA is present on the cors_exempt_headers, so we can use that and we're good.
  • But if the user did provide a UA, it's present on the normal headers, and so there is no trace of the context UA. This is a big problem, because it means the only UA we have access to for our OPTIONS request is the user one, resulting in silly behaviour.

I can think of a few ways to resolve this. Thoughts from you as reviewers would be appreciated but also this is getting to be touching stuff outside blink, so if there's another mailing list I should go contact, I'm happy to do that too.

We could:
- induce magic behaviour for a User-Agent at the point of merging the two sets of headers (only take the cors_exempt_headers version if the normal isn't there)
- provide a different place for the context UA to live inside a `network::ResourceRequest` (so that it doesn't get auto-merged from the cors_exempt_headers)
- we could set this all the time, and never use the cors_exempt_headers, or
- we could set this only when the user also sets one, so the special-case to look for the new header only occurs in `preflight_controller.cc`)

I'm going to do a dummy impl of the last option when I next have time, but I'm expecting it will need changes, so hopefully with your thoughts I can get ahead of the curve on a better approach.

Open in Gerrit

Related details

Attention is currently required from:
  • Adam Rice
  • Alex Rudenko
  • Takashi Toyoshima
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement is not satisfiedCode-Owners
  • requirement is not satisfiedCode-Review
  • requirement is not satisfiedNo-Unresolved-Comments
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: chromium/src
Gerrit-Branch: main
Gerrit-Change-Id: Icf56620f99f371ea2f128e6a3194d6096b0d62cd
Gerrit-Change-Number: 5273743
Gerrit-PatchSet: 25
Gerrit-Owner: Andrew Brown <m...@ajbrown.au>
Gerrit-Reviewer: Adam Rice <ri...@chromium.org>
Gerrit-Reviewer: Alex Rudenko <alexr...@chromium.org>
Gerrit-Reviewer: Andrew Brown <m...@ajbrown.au>
Gerrit-Reviewer: Bo Liu <bo...@chromium.org>
Gerrit-Reviewer: Maksim Sadym <sa...@chromium.org>
Gerrit-Reviewer: Min Qin <qin...@chromium.org>
Gerrit-Reviewer: Takashi Toyoshima <toyo...@chromium.org>
Gerrit-CC: Hiroki Nakagawa <nhi...@chromium.org>
Gerrit-CC: James Maclean <wjma...@chromium.org>
Gerrit-CC: James Su <su...@chromium.org>
Gerrit-CC: Nate Chapin <jap...@chromium.org>
Gerrit-Attention: Adam Rice <ri...@chromium.org>
Gerrit-Attention: Alex Rudenko <alexr...@chromium.org>
Gerrit-Attention: Takashi Toyoshima <toyo...@chromium.org>
Gerrit-Comment-Date: Fri, 04 Jul 2025 08:29:50 +0000
satisfied_requirement
unsatisfied_requirement
open
diffy

Takashi Toyoshima (Gerrit)

unread,
Jul 14, 2025, 10:20:43 PMJul 14
to Andrew Brown, Adam Rice, Maksim Sadym, Alex Rudenko, Min Qin, Bo Liu, Hiroki Nakagawa, James Maclean, James Su, AyeAye, Chromium LUCI CQ, chromium...@chromium.org, Nate Chapin, devtools-re...@chromium.org, extension...@chromium.org, chromium-a...@chromium.org, mkwst+w...@chromium.org, horo+...@chromium.org, shimazu+se...@chromium.org, kinuko+ser...@chromium.org, servicewor...@chromium.org, antoniosarto...@chromium.org, kenjibah...@chromium.org, jsbell+ser...@chromium.org, arthursonzog...@chromium.org, blink-revie...@chromium.org, alexmo...@chromium.org, yhanad...@chromium.org, tranbaod...@chromium.org, nona+...@chromium.org, creis...@chromium.org, shuche...@chromium.org, jbauma...@chromium.org, navigation...@chromium.org, keithle...@chromium.org, blink-...@chromium.org, blundell+...@chromium.org, gavinp...@chromium.org, kinuko...@chromium.org, loading-re...@chromium.org, loading...@chromium.org, net-r...@chromium.org, network-ser...@chromium.org
Attention needed from Adam Rice and Andrew Brown

Takashi Toyoshima added 8 comments

Patchset-level comments
File-level comment, Patchset 26 (Latest):
Takashi Toyoshima . resolved

I tried refreshing my memory, but I'm sorry if I forget the previous discussion and say something inconsistent.

Commit Message
Line 15, Patchset 26 (Latest):Fixed: 571722
Takashi Toyoshima . unresolved

I think this is an ID for the old bug trackker, and now 40450316 is the right id for this. Can you check if https://crbug.com/40450316 is the right link for your intended bug, and update this number?

----

Please fix this WARNING reported by Commit Message Validation: Did you intend to reference an old bug id? Please ensure this is a valid Buganizer ID and not an external system such as Monorail.

Analyzer Description: Validates that commit messages conform to a specific format.
Owner: ayeay...@google.com

Did you intend to reference an old bug id? Please ensure this is a valid Buganizer ID and not an external system such as Monorail.

To rerun the analyzer locally, run: `alint -- -c CommitMatch`

For more information, see go/alint.

File chrome/test/data/extensions/api_test/webrequest/framework.js
Line 296, Patchset 25:function checkUserAgent(headers) {
Andrew Brown . unresolved

This is the root cause of a couple remaining failures:

  • ExtensionWebRequestApiPrerenderingTest.Load
  • ExtensionWebRequestApiPrerenderingTest.LoadIntoNewTab

They're using User-Agent as a litmus test for whether the headers on a request are valid, which is fine, but User-Agent is not going to be present on a DevTools "requestWillBeSent" event anymore. So we need a new way to do this.

Takashi Toyoshima

Does this need help from qinmin@ ?
IIUC, this means the webRequest API exposed header is changed, and we need to update the API document, and need an announcement for Extensions developers and enterprise users?

File services/network/cors/preflight_controller.cc
Line 209, Patchset 26 (Latest): if (user_agent) {
preflight_request->cors_exempt_headers.SetHeader(
net::HttpRequestHeaders::kUserAgent, *user_agent);
}
Takashi Toyoshima . unresolved

This is a duplicated operation as we run the same code at line 220 eventually.
Can you remove?

Line 216, Patchset 26 (Latest): // we can't use cors_exempt_headers, so the User-Agent will appear here
Takashi Toyoshima . unresolved

Maybe typo?
I think you means the User-Agent in the normal headers here.
So, s/cors_exempt_headers/it as it is not trustworthy/ ?

Also expected behavior here is:
1. if there is a DevTools provided User-Agent (in cors_exempt_headers), we use it
2. if there is a JavaScript provided User-Agent (in headers), we ignore it, and use the context given User-Agent.

Implementation-wise, this can be done simply by
```
std::optional<std::string> user_agent = request.cors_exempt_headers.GetHeader(
net::HttpRequestHeaders::kUserAgent);
if (user_agent) {
// Set DevTools given User-Agent to the preflight request
preflight_request->headers.SetHeader(
net::HttpRequestHeaders::kUserAgent, *user_agent);
} else {
// Remove JavaScript given User-Agent if it exists, and delegate to //net to set
// a context given User-Agent
preflight_request->headers.RemoveHeader(
net::HttpRequestHeaders::kUserAgent);
}
```
Line 220, Patchset 21: net::HttpRequestHeaders::kUserAgent, *user_agent);
Andrew Brown . unresolved

I think this code has a problem, which is that if the user has set a UA, we don't bother setting the context UA onto the cors_exempt_headers (see below comment in `request_conversion.cc`). So if there's a user UA, a preflight will be sent asking whether UA is an OK header, but *using* the custom UA that the user already set. Which is daft.

I don't know if we can fix it nicely, as I think we avoided setting UA onto both sets of headers in order to avoid merging issues with them later (header lists have no guaranteed merging behaviour, I think?). So we might have to add a special UA hiding spot to the `network::ResourceRequest` too, which is not great.

Takashi Toyoshima

My comment above can be an answer for this problem?

File services/network/prefetch_matches.cc
Line 227, Patchset 26 (Latest):// LINT.ThenChange(//tools/metrics/histograms/metadata/network/enums.xml:PrefetchMatchesResourceRequestField)
Takashi Toyoshima . unresolved

Please fix this ERROR reported by If This Then That: Changes in the preceding block may need to be reflected in these files: /tools/metrics/histograms/metadata/network/enums.xml If this does not apply, add 'NO_IFTTT=some reason...' to your commit message

Analyzer Description: Reminders to change files when other files change
Owner: ayeay...@google.com

Changes in the preceding block may need to be reflected in these files: /tools/metrics/histograms/metadata/network/enums.xml If this does not apply, add 'NO_IFTTT=some reason...' to your commit message

To rerun the analyzer locally, run: `alint -- -c IfThisThenAnalyzer`

For more information, see go/alint.

File services/network/public/cpp/resource_request.h
Line 163, Patchset 26 (Latest): // Browser-intrinsic User-Agent string, to be used for preflight requests
Takashi Toyoshima . unresolved

This might not be needed if my comment on the preflight_controller.cc works.

Open in Gerrit

Related details

Attention is currently required from:
  • Adam Rice
  • Andrew Brown
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement is not satisfiedCode-Owners
  • requirement is not satisfiedCode-Review
  • requirement is not satisfiedNo-Unresolved-Comments
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: chromium/src
Gerrit-Branch: main
Gerrit-Change-Id: Icf56620f99f371ea2f128e6a3194d6096b0d62cd
Gerrit-Change-Number: 5273743
Gerrit-PatchSet: 26
Gerrit-Owner: Andrew Brown <m...@ajbrown.au>
Gerrit-Reviewer: Adam Rice <ri...@chromium.org>
Gerrit-Reviewer: Alex Rudenko <alexr...@chromium.org>
Gerrit-Reviewer: Andrew Brown <m...@ajbrown.au>
Gerrit-Reviewer: Bo Liu <bo...@chromium.org>
Gerrit-Reviewer: Maksim Sadym <sa...@chromium.org>
Gerrit-Reviewer: Min Qin <qin...@chromium.org>
Gerrit-Reviewer: Takashi Toyoshima <toyo...@chromium.org>
Gerrit-CC: Hiroki Nakagawa <nhi...@chromium.org>
Gerrit-CC: James Maclean <wjma...@chromium.org>
Gerrit-CC: James Su <su...@chromium.org>
Gerrit-CC: Nate Chapin <jap...@chromium.org>
Gerrit-Attention: Adam Rice <ri...@chromium.org>
Gerrit-Attention: Andrew Brown <m...@ajbrown.au>
Gerrit-Comment-Date: Tue, 15 Jul 2025 02:20:18 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Andrew Brown <m...@ajbrown.au>
satisfied_requirement
unsatisfied_requirement
open
diffy

Takashi Toyoshima (Gerrit)

unread,
Jul 14, 2025, 10:23:03 PMJul 14
to Andrew Brown, Takashi Nakayama, Adam Rice, Maksim Sadym, Alex Rudenko, Min Qin, Bo Liu, Hiroki Nakagawa, James Maclean, James Su, AyeAye, Chromium LUCI CQ, chromium...@chromium.org, Nate Chapin, devtools-re...@chromium.org, extension...@chromium.org, chromium-a...@chromium.org, mkwst+w...@chromium.org, horo+...@chromium.org, shimazu+se...@chromium.org, kinuko+ser...@chromium.org, servicewor...@chromium.org, antoniosarto...@chromium.org, kenjibah...@chromium.org, jsbell+ser...@chromium.org, arthursonzog...@chromium.org, blink-revie...@chromium.org, alexmo...@chromium.org, yhanad...@chromium.org, tranbaod...@chromium.org, nona+...@chromium.org, creis...@chromium.org, shuche...@chromium.org, jbauma...@chromium.org, navigation...@chromium.org, keithle...@chromium.org, blink-...@chromium.org, blundell+...@chromium.org, gavinp...@chromium.org, kinuko...@chromium.org, loading-re...@chromium.org, loading...@chromium.org, net-r...@chromium.org, network-ser...@chromium.org
Attention needed from Adam Rice, Andrew Brown and Takashi Nakayama

Takashi Toyoshima added 1 comment

Patchset-level comments
Takashi Toyoshima . resolved

cc: tnak as this is a User-Agent related CL.

Open in Gerrit

Related details

Attention is currently required from:
  • Adam Rice
  • Andrew Brown
  • Takashi Nakayama
Gerrit-CC: Takashi Nakayama <tn...@chromium.org>
Gerrit-Attention: Adam Rice <ri...@chromium.org>
Gerrit-Attention: Takashi Nakayama <tn...@chromium.org>
Gerrit-Attention: Andrew Brown <m...@ajbrown.au>
Gerrit-Comment-Date: Tue, 15 Jul 2025 02:22:35 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
satisfied_requirement
unsatisfied_requirement
open
diffy

Andrew Brown (Gerrit)

unread,
Jul 21, 2025, 5:30:32 AMJul 21
to Takashi Nakayama, Adam Rice, Maksim Sadym, Alex Rudenko, Min Qin, Bo Liu, Hiroki Nakagawa, Takashi Toyoshima, James Maclean, James Su, AyeAye, Chromium LUCI CQ, chromium...@chromium.org, Nate Chapin, devtools-re...@chromium.org, extension...@chromium.org, chromium-a...@chromium.org, mkwst+w...@chromium.org, horo+...@chromium.org, shimazu+se...@chromium.org, kinuko+ser...@chromium.org, servicewor...@chromium.org, antoniosarto...@chromium.org, kenjibah...@chromium.org, jsbell+ser...@chromium.org, arthursonzog...@chromium.org, blink-revie...@chromium.org, alexmo...@chromium.org, yhanad...@chromium.org, tranbaod...@chromium.org, nona+...@chromium.org, creis...@chromium.org, shuche...@chromium.org, jbauma...@chromium.org, navigation...@chromium.org, keithle...@chromium.org, blink-...@chromium.org, blundell+...@chromium.org, gavinp...@chromium.org, kinuko...@chromium.org, loading-re...@chromium.org, loading...@chromium.org, net-r...@chromium.org, network-ser...@chromium.org
Attention needed from Adam Rice and Takashi Toyoshima

Andrew Brown added 7 comments

Patchset-level comments
Takashi Toyoshima . resolved

I tried refreshing my memory, but I'm sorry if I forget the previous discussion and say something inconsistent.

Andrew Brown

That's totally ok, this CL is so old & complex now I keep forgetting bits too.

File-level comment, Patchset 27 (Latest):
Andrew Brown . unresolved

Apologies, the next patchset will take some time for me to upload as `git-credential-luci` has logged me out and is now forcing me to update my system to glibc 2.38. I've been meaning to switch distros for a while now so I guess this is as good an excuse as any.

Commit Message
Line 15, Patchset 26:Fixed: 571722
Takashi Toyoshima . resolved

I think this is an ID for the old bug trackker, and now 40450316 is the right id for this. Can you check if https://crbug.com/40450316 is the right link for your intended bug, and update this number?

----

Please fix this WARNING reported by Commit Message Validation: Did you intend to reference an old bug id? Please ensure this is a valid Buganizer ID and not an external system such as Monorail.

Analyzer Description: Validates that commit messages conform to a specific format.
Owner: ayeay...@google.com

Did you intend to reference an old bug id? Please ensure this is a valid Buganizer ID and not an external system such as Monorail.

To rerun the analyzer locally, run: `alint -- -c CommitMatch`

For more information, see go/alint.

Andrew Brown

Done :)

File chrome/test/data/extensions/api_test/webrequest/framework.js
Line 296, Patchset 25:function checkUserAgent(headers) {
Andrew Brown . unresolved

This is the root cause of a couple remaining failures:

  • ExtensionWebRequestApiPrerenderingTest.Load
  • ExtensionWebRequestApiPrerenderingTest.LoadIntoNewTab

They're using User-Agent as a litmus test for whether the headers on a request are valid, which is fine, but User-Agent is not going to be present on a DevTools "requestWillBeSent" event anymore. So we need a new way to do this.

Takashi Toyoshima

Does this need help from qinmin@ ?
IIUC, this means the webRequest API exposed header is changed, and we need to update the API document, and need an announcement for Extensions developers and enterprise users?

Andrew Brown

Hmm. I think at the moment, yes, but that should actually be fixable.

My first idea is to ensure that the extensions stack combines the `cors_exempt_headers` into any headers returned to the user. I don't know if this is acceptable from a duplication-of-code-behaviour standpoint -- is it ok to have a bunch of places scattered around the code that pseudo-implement the network process's header merging behaviour?

The thing is, I'm uncovering a lot of behaviour that's always been "wrong", but has always been "good enough" -- lots of places where the code only considers `network::ResourceRequest`'s |headers| without combining the |cors_exempt_headers|.

Until now, |cors_exempt_headers| were niche, so it didn't matter, but now, User-Agent is on there... and lots of things care about User-Agent.

I'll try to "fix" the tests by reintroducing the User-Agent to the webRequest API first, and then get qinmin@ 's thoughts on implementation detail.

File services/network/cors/preflight_controller.cc
Line 209, Patchset 26: if (user_agent) {

preflight_request->cors_exempt_headers.SetHeader(
net::HttpRequestHeaders::kUserAgent, *user_agent);
}
Takashi Toyoshima . resolved

This is a duplicated operation as we run the same code at line 220 eventually.
Can you remove?

Andrew Brown

Yeah, I can condense that down. Good spot.

Line 216, Patchset 26: // we can't use cors_exempt_headers, so the User-Agent will appear here
Takashi Toyoshima . unresolved

Maybe typo?
I think you means the User-Agent in the normal headers here.
So, s/cors_exempt_headers/it as it is not trustworthy/ ?

Also expected behavior here is:
1. if there is a DevTools provided User-Agent (in cors_exempt_headers), we use it
2. if there is a JavaScript provided User-Agent (in headers), we ignore it, and use the context given User-Agent.

Implementation-wise, this can be done simply by
```
std::optional<std::string> user_agent = request.cors_exempt_headers.GetHeader(
net::HttpRequestHeaders::kUserAgent);
if (user_agent) {
// Set DevTools given User-Agent to the preflight request
preflight_request->headers.SetHeader(
net::HttpRequestHeaders::kUserAgent, *user_agent);
} else {
// Remove JavaScript given User-Agent if it exists, and delegate to //net to set
// a context given User-Agent
preflight_request->headers.RemoveHeader(
net::HttpRequestHeaders::kUserAgent);
}
```
Andrew Brown

I think my comments here aren't quite clear about the obscure boxes that we have to tick. In this case, the problem is when we have *both* a UA from fetch and a UA from DevTools.

There are 4(+2) cases:

  • No UA at all: no preflight / send request with intrinsic UA
  • Fetch UA present: send preflight with intrinsic UA / send request with fetch UA
  • DevTools override & No UA on fetch: no preflight / send request with DevTools UA
  • DevTools override & Fetch UA present: send preflight with DevTools UA / send request with fetch UA
  • Plus,
  • no UA at all, but preflight generated by another header: send preflight and request with intrinsic UA
  • DevTools override & preflight generated by another header: send preflight and request with DevTools UA

(The problem is case 4, and *not* either of the bonus cases - i.e. the problem only happens when a DevTools UA *and* a fetch UA are both present.)
The reason this is an issue is because in `request_conversion.cc`, there's already a fetch UA on the `headers`. We can't put the devtools UA on the `cors_exempt_headers`, because that overrides the fetch UA on the normal `headers`.

If we don't do anything extra (like the code you suggest above) then it's fine, but in case 4, what happens is blink simply doesn't have the ability to send through the DevTools-overridden User-Agent, so the preflight is made with the original, browser-intrinsic string.

My current (local) code correctly handles all of these cases, but needs to use the `context_user_agent_for_preflights` as a bonus field to hold the DevTools UA when a fetch UA is already on the normal |headers|. I think the name is not particularly clear, and will clean up comments & naming in the next patchset.

File services/network/prefetch_matches.cc
Line 227, Patchset 26:// LINT.ThenChange(//tools/metrics/histograms/metadata/network/enums.xml:PrefetchMatchesResourceRequestField)
Takashi Toyoshima . resolved

Please fix this ERROR reported by If This Then That: Changes in the preceding block may need to be reflected in these files: /tools/metrics/histograms/metadata/network/enums.xml If this does not apply, add 'NO_IFTTT=some reason...' to your commit message

Analyzer Description: Reminders to change files when other files change
Owner: ayeay...@google.com

Changes in the preceding block may need to be reflected in these files: /tools/metrics/histograms/metadata/network/enums.xml If this does not apply, add 'NO_IFTTT=some reason...' to your commit message

To rerun the analyzer locally, run: `alint -- -c IfThisThenAnalyzer`

For more information, see go/alint.

Andrew Brown

Done.

Open in Gerrit

Related details

Attention is currently required from:
  • Adam Rice
  • Takashi Toyoshima
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement is not satisfiedCode-Owners
  • requirement is not satisfiedCode-Review
  • requirement is not satisfiedNo-Unresolved-Comments
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: chromium/src
Gerrit-Branch: main
Gerrit-Change-Id: Icf56620f99f371ea2f128e6a3194d6096b0d62cd
Gerrit-Change-Number: 5273743
Gerrit-PatchSet: 27
Gerrit-Owner: Andrew Brown <m...@ajbrown.au>
Gerrit-Reviewer: Adam Rice <ri...@chromium.org>
Gerrit-Reviewer: Alex Rudenko <alexr...@chromium.org>
Gerrit-Reviewer: Andrew Brown <m...@ajbrown.au>
Gerrit-Reviewer: Bo Liu <bo...@chromium.org>
Gerrit-Reviewer: Maksim Sadym <sa...@chromium.org>
Gerrit-Reviewer: Min Qin <qin...@chromium.org>
Gerrit-Reviewer: Takashi Toyoshima <toyo...@chromium.org>
Gerrit-CC: Hiroki Nakagawa <nhi...@chromium.org>
Gerrit-CC: James Maclean <wjma...@chromium.org>
Gerrit-CC: James Su <su...@chromium.org>
Gerrit-CC: Nate Chapin <jap...@chromium.org>
Gerrit-CC: Takashi Nakayama <tn...@chromium.org>
Gerrit-Attention: Adam Rice <ri...@chromium.org>
Gerrit-Attention: Takashi Toyoshima <toyo...@chromium.org>
Gerrit-Comment-Date: Mon, 21 Jul 2025 09:30:06 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Andrew Brown <m...@ajbrown.au>
Comment-In-Reply-To: Takashi Toyoshima <toyo...@chromium.org>
satisfied_requirement
unsatisfied_requirement
open
diffy

Takashi Toyoshima (Gerrit)

unread,
Jul 21, 2025, 11:22:52 PMJul 21
to Andrew Brown, Takashi Nakayama, Adam Rice, Maksim Sadym, Alex Rudenko, Min Qin, Bo Liu, Hiroki Nakagawa, James Maclean, James Su, AyeAye, Chromium LUCI CQ, chromium...@chromium.org, Nate Chapin, devtools-re...@chromium.org, extension...@chromium.org, chromium-a...@chromium.org, mkwst+w...@chromium.org, horo+...@chromium.org, shimazu+se...@chromium.org, kinuko+ser...@chromium.org, servicewor...@chromium.org, antoniosarto...@chromium.org, kenjibah...@chromium.org, jsbell+ser...@chromium.org, arthursonzog...@chromium.org, blink-revie...@chromium.org, alexmo...@chromium.org, yhanad...@chromium.org, tranbaod...@chromium.org, nona+...@chromium.org, creis...@chromium.org, shuche...@chromium.org, jbauma...@chromium.org, navigation...@chromium.org, keithle...@chromium.org, blink-...@chromium.org, blundell+...@chromium.org, gavinp...@chromium.org, kinuko...@chromium.org, loading-re...@chromium.org, loading...@chromium.org, net-r...@chromium.org, network-ser...@chromium.org
Attention needed from Adam Rice and Andrew Brown

Takashi Toyoshima added 6 comments

File services/network/cors/preflight_controller.cc
Takashi Toyoshima

Ah, OK. I think you are saying about the MergeFrom() operations at ConfigureUrRequest in //services/network/url_loader_util.cc or URLLoader::FollowRedirect in //services/network/url_loader.cc where we override `headers` content with `cors_exempt_headers`.

So, in such a case, how about clarifying the User-Agent handling more clearly.

  • headers['User-Agent']: value that was set by JavaScript
  • content_user_agent: default value that is defined by the browser (and can be overridden by DevTools)
  • cors_exempt_headers['User-Agent']: forbidden (remove 'User-Agent' exempt from the cors_exempt_header_list to ensure there is no other use cases)
File services/network/prefetch_matches.cc
Line 227, Patchset 26:// LINT.ThenChange(//tools/metrics/histograms/metadata/network/enums.xml:PrefetchMatchesResourceRequestField)
Takashi Toyoshima . unresolved

Please fix this ERROR reported by If This Then That: Changes in the preceding block may need to be reflected in these files: /tools/metrics/histograms/metadata/network/enums.xml If this does not apply, add 'NO_IFTTT=some reason...' to your commit message

Analyzer Description: Reminders to change files when other files change
Owner: ayeay...@google.com

Changes in the preceding block may need to be reflected in these files: /tools/metrics/histograms/metadata/network/enums.xml If this does not apply, add 'NO_IFTTT=some reason...' to your commit message

To rerun the analyzer locally, run: `alint -- -c IfThisThenAnalyzer`

For more information, see go/alint.

Andrew Brown

Done.

Takashi Toyoshima

Not yet?
We need to make an update also on //tools/metrics/histograms/metadata/network/enums.xml as the LINT error suggested.

File services/network/public/cpp/resource_request.h
Line 165, Patchset 27 (Latest): std::optional<std::string> context_user_agent_for_preflights = std::nullopt;
Takashi Toyoshima . unresolved

I prefer to drop "_for_preflights" suffix here as this information itself doesn't have any restriction for the usage.

Also, I think this is not working over IPC now?
As ResourceRequest is mapped to mojom::URLRequest, we also need to update url_request.mojom, and url_request_mojom_traits.*.
You can check services/network/public/mojom/BUILD.gn to check the typemap for this class.

File third_party/blink/renderer/platform/loader/fetch/fetch_context.h
Line 200, Patchset 27 (Latest): virtual String GetDefaultUserAgent() const { NOTREACHED(); }
Takashi Toyoshima . unresolved

Can you drop the default implementation instead of adding NOTREACHED?
We will prefer the compile time check rather than runtime check for this.

File third_party/blink/renderer/platform/loader/fetch/resource_request.h
Line 789, Patchset 27 (Latest): // The browser-supplied User-Agent string (comes from NetworkContext)
Takashi Toyoshima . unresolved

Do you mean FetchContext?

File third_party/blink/renderer/platform/loader/fetch/url_loader/request_conversion.cc
Line 309, Patchset 27 (Latest): dest->cors_exempt_headers.SetHeader(net::HttpRequestHeaders::kUserAgent,
context_default_user_agent.Utf8());
Takashi Toyoshima . unresolved

So, can we set it always to the context_user_agent_for_preflights?

Open in Gerrit

Related details

Attention is currently required from:
  • Adam Rice
  • Andrew Brown
Gerrit-Attention: Andrew Brown <m...@ajbrown.au>
Gerrit-Comment-Date: Tue, 22 Jul 2025 03:22:29 +0000
satisfied_requirement
unsatisfied_requirement
open
diffy

Andrew Brown (Gerrit)

unread,
Jul 24, 2025, 12:41:12 AMJul 24
to Chromium Metrics Reviews, Takashi Nakayama, Adam Rice, Maksim Sadym, Alex Rudenko, Min Qin, Bo Liu, Hiroki Nakagawa, Takashi Toyoshima, James Maclean, James Su, AyeAye, Chromium LUCI CQ, chromium...@chromium.org, Nate Chapin, asvitkine...@chromium.org, devtools-re...@chromium.org, extension...@chromium.org, chromium-a...@chromium.org, mkwst+w...@chromium.org, horo+...@chromium.org, shimazu+se...@chromium.org, kinuko+ser...@chromium.org, servicewor...@chromium.org, antoniosarto...@chromium.org, kenjibah...@chromium.org, jsbell+ser...@chromium.org, arthursonzog...@chromium.org, blink-revie...@chromium.org, alexmo...@chromium.org, yhanad...@chromium.org, tranbaod...@chromium.org, nona+...@chromium.org, creis...@chromium.org, shuche...@chromium.org, jbauma...@chromium.org, navigation...@chromium.org, keithle...@chromium.org, blink-...@chromium.org, blundell+...@chromium.org, gavinp...@chromium.org, kinuko...@chromium.org, loading-re...@chromium.org, loading...@chromium.org, net-r...@chromium.org, network-ser...@chromium.org
Attention needed from Takashi Toyoshima

Andrew Brown added 12 comments

Patchset-level comments
File-level comment, Patchset 24:
Andrew Brown . resolved

Basically everything except a handful of Extension tests (discussed soon) should pass now -- @ Adam, CQ dry run please?

That said, I have a few outstanding questions that may need broader conversations to resolve. I don't know if these are answerable with the reviewers I already have, or whether this is time for a chromestatus.com entry and/or emails to other mailing lists for different areas.

  • comments in `request_conversion.cc` are wondering how best to get the context UA over to the network process for OPTIONS requests to use
  • comments in `framework.js` are wondering what to do about any tests that rely/relied on DevTools for stuff
  • comments in `frame_fetch_context_test.cc` are wondering whether the new version of `PrepareRequestWhenDetached` is even remotely useful or sensible

Importantly, though:

  • lots of tests have changed, especially those that relied on DevTools to see UAs in a `requestWillBeSent` event. How many new tests or modifications to old tests, are needed to make sure the UA is still present on a `requestWillBeSentExtraInfo`?
  • followup, which cases are sufficiently distinct that they're worth different tests for this? I've edited tests that involve redirects, cross-site redirects, etc etc -- can we assume it's all good with one more test for "UA on ExtraInfo" or do we need "UA on ExtraInfo for redirects", "UA on ExtraInfo for preflights", etc?
Andrew Brown

Done

File services/network/cors/preflight_controller.cc
Andrew Brown

That sounds like a good idea to me -- implemented. A CQ run will probably identify a ton of places I've missed that need the new UA merged, but que sera.

Line 220, Patchset 21: net::HttpRequestHeaders::kUserAgent, *user_agent);
Andrew Brown . resolved

I think this code has a problem, which is that if the user has set a UA, we don't bother setting the context UA onto the cors_exempt_headers (see below comment in `request_conversion.cc`). So if there's a user UA, a preflight will be sent asking whether UA is an OK header, but *using* the custom UA that the user already set. Which is daft.

I don't know if we can fix it nicely, as I think we avoided setting UA onto both sets of headers in order to avoid merging issues with them later (header lists have no guaranteed merging behaviour, I think?). So we might have to add a special UA hiding spot to the `network::ResourceRequest` too, which is not great.

Takashi Toyoshima

My comment above can be an answer for this problem?

Andrew Brown

Done via content_user_agent.

File services/network/prefetch_matches.cc
Line 227, Patchset 26:// LINT.ThenChange(//tools/metrics/histograms/metadata/network/enums.xml:PrefetchMatchesResourceRequestField)
Takashi Toyoshima . resolved

Please fix this ERROR reported by If This Then That: Changes in the preceding block may need to be reflected in these files: /tools/metrics/histograms/metadata/network/enums.xml If this does not apply, add 'NO_IFTTT=some reason...' to your commit message

Analyzer Description: Reminders to change files when other files change
Owner: ayeay...@google.com

Changes in the preceding block may need to be reflected in these files: /tools/metrics/histograms/metadata/network/enums.xml If this does not apply, add 'NO_IFTTT=some reason...' to your commit message

To rerun the analyzer locally, run: `alint -- -c IfThisThenAnalyzer`

For more information, see go/alint.

Andrew Brown

Done.

Takashi Toyoshima

Not yet?
We need to make an update also on //tools/metrics/histograms/metadata/network/enums.xml as the LINT error suggested.

Andrew Brown

Sorry, yes, I had done it locally, but couldn't upload (glibc issues, now resolved).

File services/network/public/cpp/resource_request.h
Line 165, Patchset 27: std::optional<std::string> context_user_agent_for_preflights = std::nullopt;
Takashi Toyoshima . resolved

I prefer to drop "_for_preflights" suffix here as this information itself doesn't have any restriction for the usage.

Also, I think this is not working over IPC now?
As ResourceRequest is mapped to mojom::URLRequest, we also need to update url_request.mojom, and url_request_mojom_traits.*.
You can check services/network/public/mojom/BUILD.gn to check the typemap for this class.

Andrew Brown

Yeah, I discovered that locally too. It should be fully implemented now.

Line 163, Patchset 26: // Browser-intrinsic User-Agent string, to be used for preflight requests
Takashi Toyoshima . resolved

This might not be needed if my comment on the preflight_controller.cc works.

Andrew Brown

Done

File services/network/public/mojom/url_request.mojom
Line 285, Patchset 28: // already set a User-Agent via fetch.
Andrew Brown . unresolved

Is the terminology in this comment sensible?

File third_party/blink/renderer/core/inspector/inspector_network_agent.cc
Line 1015, Patchset 21: headers, std::make_optional(request.GetContextUserAgent())))
Andrew Brown . resolved

I don't think CORS preflights go through this function, as CORS preflights still appear to be UA-less in Devtools (the actual request still has the header, just the inspector's `Network.requestWillBeSent` event is wrong.)

But also, this behaviour isn't tested ATM (I think?) - the existing tests don't appear to be checking the inspector's view of the preflight, just the network's view of it (in `http/tests/inspector-protocol/emulation/user-agent-override-cors-preflight.js`)

So, outstanding questions (the last of which I can answer myself, given time):

  • Should there be a test for this behaviour (sending the right UA on a preflight, and making sure Devtools sees it too)?
  • Where do preflights spawn into the inspector code? Preflights are spawned in the network process, as best I can tell (code lives in services/network, not third_party/blink), so I don't know how that information gets sent back to the render process's inspector stuff.
Alex Rudenko

I do not think we need to add extra headers in this event. We have requestWillBeSentExtraInfo that should report actual headers set by the network service. Could you please clarify why requestWillBeSentExtraInfo is not sufficient here?

Andrew Brown

I'll be honest I am completely unfamiliar with DevTools and didn't know that existed; everything that I've done has been prompted by a few failing tests. My impression (and these changes) are to solve the fact that the new, cors-free "hiding" spot for the UA also needs to be given to the inspector.

Looking at requestWillBeSentExtraInfo, that seems like exactly what we want here, but this will require some tests to be updated - there's at least 8 tests failing in `web_tests/http/tests/inspector_protocol` that all are expecting a User-Agent to be present on the original `requestWillBeSent` event (which it won't be, anymore).

I could update those 8 tests to check requestWillBeSentExtraInfo, and then ensure the User-Agent is present there?

Alex Rudenko

I think it would be better to not special case the header when reporting from the renderer and update the tests that do not contain the header anymore and make sure that ExtraInfo events from the network service actually contain the correct user agent header via a new test. I would suggest the network reviewers to review the non-DevTools changes first to make sure those are correct.

Alex Rudenko

I was reviewing it again and the user agent actually is set by the client code, right? I wonder why is it no present in `request.HttpHeaderFields()`? It does sound like it should contain it if it is provided by the client.

Andrew Brown

I'm not sure if I'm interpreting this right, but I'll attempt to explain; let me know if this helps. (My terminology is crappy, sorry; it's hard to overcome my non-chromium intuition of the definitions of "browser" and "client".)

Firstly, you're right, the user-agent is set javascript code onto the normal `request.HttpHeaderFields()`. But, any User-Agent value that exists in these headers will cause a CORS OPTIONS request. (The reason it doesn't do this in real Chrome right now is because of the list in `/net/http/http_util.cc`, but that's like, the actual spec bug we're fixing.)

If we put our internal value (the one that looks like `Mozilla/5.0 Chrome 140.0` etc etc) onto those headers, we'll end up triggering a CORS preflight request on every single web request we ever make.

So we have to put our internal value somewhere else, so that it can be all combined together later. That somewhere else is (for the moment) the `request.GetContextUserAgent()` (named because the internal value comes from the `FetchContext`).

Unfortunately, anywhere that we can put the UA that hides it from CORS, also hides it from a lot of other things (including DevTools).

The alternative approach was to send the context value straight to the network process later on (patchset 19), but I thought I had to make sure it was accessible through a blink::ResourceRequest somewhere in order for DevTools to see it... *but* now I've learned that it's ok for DevTools to just get it in requestWillBeSentExtraInfo later on. So I think I'm going back to the patchset 19 approach.

Andrew Brown

Done

File third_party/blink/renderer/platform/loader/fetch/fetch_context.h
Line 200, Patchset 27: virtual String GetDefaultUserAgent() const { NOTREACHED(); }
Takashi Toyoshima . unresolved

Can you drop the default implementation instead of adding NOTREACHED?
We will prefer the compile time check rather than runtime check for this.

Andrew Brown

I don't think we can, unfortunately -- e.g. `GetFeatureContext()` or `GetPermissionsPolicy()` just below. I think there has to be a default implementation.

I'm not 100% confident on C++ internals, but I think the issue is that `fetch_context.h/cc` actually gets compiled into some real code at some point, so if you don't have a default implementation, the linker errors out.

File third_party/blink/renderer/platform/loader/fetch/resource_request.h
Line 789, Patchset 27: // The browser-supplied User-Agent string (comes from NetworkContext)
Takashi Toyoshima . resolved

Do you mean FetchContext?

Andrew Brown

Actually, this code isn't needed anymore -- removed entirely.

File third_party/blink/renderer/platform/loader/fetch/url_loader/request_conversion.cc
Line 310, Patchset 21: }
Andrew Brown . resolved

See above comment in `preflight_controller.cc` - it's both these pieces of code together.

The key thing is at this point, we can't put the context UA onto the cors_exempt_headers without potentially accepting dodgy merge behaviour later when they get combined. So we have a `network::ResourceRequest` that has a user UA on the normal headers and *no* UA on the cors_exempt headers, which then goes to `preflight_controller`, which uses the user UA.

I guess we could work out where the merge happens and make sure we remove the context UA from the `cors_exempt_headers` *if* the user UA is set? But then we need to make sure preflights avoid copying the user UA, too.

Andrew Brown

So the state of affairs is thus:

  • If the user provides a UA, it sits on the normal headers. In `request_conversion.cc`, we *can't* put the context UA onto the cors_exempt_headers, because that will actually clobber the user-provided one.
  • If the user doesn't provide a UA, then this code does exactly what it says; there are no issues here about different handling of a DevTools-set value vs an intrinsic browser value.

But then, later (in `preflight_controller.cc`):

  • If the user didn't provide a UA, then the context UA is present on the cors_exempt_headers, so we can use that and we're good.
  • But if the user did provide a UA, it's present on the normal headers, and so there is no trace of the context UA. This is a big problem, because it means the only UA we have access to for our OPTIONS request is the user one, resulting in silly behaviour.

I can think of a few ways to resolve this. Thoughts from you as reviewers would be appreciated but also this is getting to be touching stuff outside blink, so if there's another mailing list I should go contact, I'm happy to do that too.

We could:
- induce magic behaviour for a User-Agent at the point of merging the two sets of headers (only take the cors_exempt_headers version if the normal isn't there)
- provide a different place for the context UA to live inside a `network::ResourceRequest` (so that it doesn't get auto-merged from the cors_exempt_headers)
- we could set this all the time, and never use the cors_exempt_headers, or
- we could set this only when the user also sets one, so the special-case to look for the new header only occurs in `preflight_controller.cc`)

I'm going to do a dummy impl of the last option when I next have time, but I'm expecting it will need changes, so hopefully with your thoughts I can get ahead of the curve on a better approach.

Andrew Brown

Done

Line 309, Patchset 27: dest->cors_exempt_headers.SetHeader(net::HttpRequestHeaders::kUserAgent,
context_default_user_agent.Utf8());
Takashi Toyoshima . resolved

So, can we set it always to the context_user_agent_for_preflights?

Andrew Brown

Yeah, we can now just always put the context version on the content_user_agent; the actual value from the |headers| doesn't matter at this point.

Open in Gerrit

Related details

Attention is currently required from:
  • Takashi Toyoshima
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement is not satisfiedCode-Owners
  • requirement is not satisfiedCode-Review
  • requirement is not satisfiedNo-Unresolved-Comments
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: chromium/src
Gerrit-Branch: main
Gerrit-Change-Id: Icf56620f99f371ea2f128e6a3194d6096b0d62cd
Gerrit-Change-Number: 5273743
Gerrit-PatchSet: 29
Gerrit-Owner: Andrew Brown <m...@ajbrown.au>
Gerrit-Reviewer: Adam Rice <ri...@chromium.org>
Gerrit-Reviewer: Alex Rudenko <alexr...@chromium.org>
Gerrit-Reviewer: Andrew Brown <m...@ajbrown.au>
Gerrit-Reviewer: Bo Liu <bo...@chromium.org>
Gerrit-Reviewer: Maksim Sadym <sa...@chromium.org>
Gerrit-Reviewer: Min Qin <qin...@chromium.org>
Gerrit-Reviewer: Takashi Toyoshima <toyo...@chromium.org>
Gerrit-CC: Chromium Metrics Reviews <chromium-met...@google.com>
Gerrit-CC: Hiroki Nakagawa <nhi...@chromium.org>
Gerrit-CC: James Maclean <wjma...@chromium.org>
Gerrit-CC: James Su <su...@chromium.org>
Gerrit-CC: Nate Chapin <jap...@chromium.org>
Gerrit-CC: Takashi Nakayama <tn...@chromium.org>
Gerrit-Attention: Takashi Toyoshima <toyo...@chromium.org>
Gerrit-Comment-Date: Thu, 24 Jul 2025 04:40:49 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Alex Rudenko <alexr...@chromium.org>
satisfied_requirement
unsatisfied_requirement
open
diffy

Andrew Brown (Gerrit)

unread,
Jul 24, 2025, 12:42:15 AMJul 24
to Chromium Metrics Reviews, Takashi Nakayama, Adam Rice, Maksim Sadym, Alex Rudenko, Min Qin, Bo Liu, Hiroki Nakagawa, Takashi Toyoshima, James Maclean, James Su, AyeAye, Chromium LUCI CQ, chromium...@chromium.org, Nate Chapin, asvitkine...@chromium.org, devtools-re...@chromium.org, extension...@chromium.org, chromium-a...@chromium.org, mkwst+w...@chromium.org, horo+...@chromium.org, shimazu+se...@chromium.org, kinuko+ser...@chromium.org, servicewor...@chromium.org, antoniosarto...@chromium.org, kenjibah...@chromium.org, jsbell+ser...@chromium.org, arthursonzog...@chromium.org, blink-revie...@chromium.org, alexmo...@chromium.org, yhanad...@chromium.org, tranbaod...@chromium.org, nona+...@chromium.org, creis...@chromium.org, shuche...@chromium.org, jbauma...@chromium.org, navigation...@chromium.org, keithle...@chromium.org, blink-...@chromium.org, blundell+...@chromium.org, gavinp...@chromium.org, kinuko...@chromium.org, loading-re...@chromium.org, loading...@chromium.org, net-r...@chromium.org, network-ser...@chromium.org
Attention needed from Takashi Toyoshima

Andrew Brown added 1 comment

Patchset-level comments
File-level comment, Patchset 27:
Andrew Brown . resolved

Apologies, the next patchset will take some time for me to upload as `git-credential-luci` has logged me out and is now forcing me to update my system to glibc 2.38. I've been meaning to switch distros for a while now so I guess this is as good an excuse as any.

Andrew Brown

Done.

Gerrit-Comment-Date: Thu, 24 Jul 2025 04:41:44 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Andrew Brown <m...@ajbrown.au>
satisfied_requirement
unsatisfied_requirement
open
diffy

Takashi Toyoshima (Gerrit)

unread,
Jul 25, 2025, 12:15:38 AMJul 25
to Andrew Brown, Chromium Metrics Reviews, Takashi Nakayama, Adam Rice, Maksim Sadym, Alex Rudenko, Min Qin, Bo Liu, Hiroki Nakagawa, James Maclean, James Su, AyeAye, Chromium LUCI CQ, chromium...@chromium.org, Nate Chapin, asvitkine...@chromium.org, devtools-re...@chromium.org, extension...@chromium.org, chromium-a...@chromium.org, mkwst+w...@chromium.org, horo+...@chromium.org, shimazu+se...@chromium.org, kinuko+ser...@chromium.org, servicewor...@chromium.org, antoniosarto...@chromium.org, kenjibah...@chromium.org, jsbell+ser...@chromium.org, arthursonzog...@chromium.org, blink-revie...@chromium.org, alexmo...@chromium.org, yhanad...@chromium.org, tranbaod...@chromium.org, nona+...@chromium.org, creis...@chromium.org, shuche...@chromium.org, jbauma...@chromium.org, navigation...@chromium.org, keithle...@chromium.org, blink-...@chromium.org, blundell+...@chromium.org, gavinp...@chromium.org, kinuko...@chromium.org, loading-re...@chromium.org, loading...@chromium.org, net-r...@chromium.org, network-ser...@chromium.org
Attention needed from Andrew Brown

Takashi Toyoshima voted and added 1 comment

Votes added by Takashi Toyoshima

Commit-Queue+1

1 comment

File services/network/cors/preflight_controller.cc
Takashi Toyoshima

thanks. let me trigger the CQ+1 to check it.

Open in Gerrit

Related details

Attention is currently required from:
  • Andrew Brown
Gerrit-Attention: Andrew Brown <m...@ajbrown.au>
Gerrit-Comment-Date: Fri, 25 Jul 2025 04:15:01 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
satisfied_requirement
unsatisfied_requirement
open
diffy

Andrew Brown (Gerrit)

unread,
Jul 26, 2025, 10:33:49 PMJul 26
to Takashi Toyoshima, Chromium Metrics Reviews, Takashi Nakayama, Adam Rice, Maksim Sadym, Alex Rudenko, Min Qin, Bo Liu, Hiroki Nakagawa, James Maclean, James Su, AyeAye, Chromium LUCI CQ, chromium...@chromium.org, Nate Chapin, asvitkine...@chromium.org, devtools-re...@chromium.org, extension...@chromium.org, chromium-a...@chromium.org, mkwst+w...@chromium.org, horo+...@chromium.org, shimazu+se...@chromium.org, kinuko+ser...@chromium.org, servicewor...@chromium.org, antoniosarto...@chromium.org, kenjibah...@chromium.org, jsbell+ser...@chromium.org, arthursonzog...@chromium.org, blink-revie...@chromium.org, alexmo...@chromium.org, yhanad...@chromium.org, tranbaod...@chromium.org, nona+...@chromium.org, creis...@chromium.org, shuche...@chromium.org, jbauma...@chromium.org, navigation...@chromium.org, keithle...@chromium.org, blink-...@chromium.org, blundell+...@chromium.org, gavinp...@chromium.org, kinuko...@chromium.org, loading-re...@chromium.org, loading...@chromium.org, net-r...@chromium.org, network-ser...@chromium.org
Attention needed from Takashi Toyoshima

Andrew Brown added 1 comment

File services/network/cors/preflight_controller.cc
Andrew Brown

Quick fixes, should pass everything except `external/wpt/xhr/preserve-ua-header-on-redirect.htm` -- I'll look into that now.

Open in Gerrit

Related details

Attention is currently required from:
  • Takashi Toyoshima
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement is not satisfiedCode-Owners
  • requirement is not satisfiedCode-Review
  • requirement is not satisfiedNo-Unresolved-Comments
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: chromium/src
Gerrit-Branch: main
Gerrit-Change-Id: Icf56620f99f371ea2f128e6a3194d6096b0d62cd
Gerrit-Change-Number: 5273743
Gerrit-PatchSet: 30
Gerrit-Owner: Andrew Brown <m...@ajbrown.au>
Gerrit-Reviewer: Adam Rice <ri...@chromium.org>
Gerrit-Reviewer: Alex Rudenko <alexr...@chromium.org>
Gerrit-Reviewer: Andrew Brown <m...@ajbrown.au>
Gerrit-Reviewer: Bo Liu <bo...@chromium.org>
Gerrit-Reviewer: Maksim Sadym <sa...@chromium.org>
Gerrit-Reviewer: Min Qin <qin...@chromium.org>
Gerrit-Reviewer: Takashi Toyoshima <toyo...@chromium.org>
Gerrit-CC: Chromium Metrics Reviews <chromium-met...@google.com>
Gerrit-CC: Hiroki Nakagawa <nhi...@chromium.org>
Gerrit-CC: James Maclean <wjma...@chromium.org>
Gerrit-CC: James Su <su...@chromium.org>
Gerrit-CC: Nate Chapin <jap...@chromium.org>
Gerrit-CC: Takashi Nakayama <tn...@chromium.org>
Gerrit-Attention: Takashi Toyoshima <toyo...@chromium.org>
Gerrit-Comment-Date: Sun, 27 Jul 2025 02:33:18 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
satisfied_requirement
unsatisfied_requirement
open
diffy

Andrew Brown (Gerrit)

unread,
Jul 27, 2025, 6:49:23 AMJul 27
to Takashi Toyoshima, Chromium Metrics Reviews, Takashi Nakayama, Adam Rice, Maksim Sadym, Alex Rudenko, Min Qin, Bo Liu, Hiroki Nakagawa, James Maclean, James Su, AyeAye, Chromium LUCI CQ, chromium...@chromium.org, Nate Chapin, asvitkine...@chromium.org, devtools-re...@chromium.org, extension...@chromium.org, chromium-a...@chromium.org, mkwst+w...@chromium.org, horo+...@chromium.org, shimazu+se...@chromium.org, kinuko+ser...@chromium.org, servicewor...@chromium.org, antoniosarto...@chromium.org, kenjibah...@chromium.org, jsbell+ser...@chromium.org, arthursonzog...@chromium.org, blink-revie...@chromium.org, alexmo...@chromium.org, yhanad...@chromium.org, tranbaod...@chromium.org, nona+...@chromium.org, creis...@chromium.org, shuche...@chromium.org, jbauma...@chromium.org, navigation...@chromium.org, keithle...@chromium.org, blink-...@chromium.org, blundell+...@chromium.org, gavinp...@chromium.org, kinuko...@chromium.org, loading-re...@chromium.org, loading...@chromium.org, net-r...@chromium.org, network-ser...@chromium.org
File services/network/cors/preflight_controller.cc
Andrew Brown

Not quite, actually -- the extension issues are a bit more formidable than I anticipated (and I've also been suffering through openSUSE build incompatibilities). Still working on it, though I might end up needing to ask for an Extensions expert opinion sooner than I thought.

Gerrit-Comment-Date: Sun, 27 Jul 2025 10:48:48 +0000
satisfied_requirement
unsatisfied_requirement
open
diffy

Andrew Brown (Gerrit)

unread,
Jul 27, 2025, 11:43:17 PMJul 27
to Dave Tapuska, Takashi Toyoshima, Chromium Metrics Reviews, Takashi Nakayama, Adam Rice, Min Qin, Hiroki Nakagawa, James Maclean, James Su, AyeAye, Chromium LUCI CQ, chromium...@chromium.org, Nate Chapin, asvitkine...@chromium.org, devtools-re...@chromium.org, extension...@chromium.org, chromium-a...@chromium.org, mkwst+w...@chromium.org, horo+...@chromium.org, shimazu+se...@chromium.org, kinuko+ser...@chromium.org, servicewor...@chromium.org, antoniosarto...@chromium.org, kenjibah...@chromium.org, jsbell+ser...@chromium.org, arthursonzog...@chromium.org, blink-revie...@chromium.org, alexmo...@chromium.org, yhanad...@chromium.org, tranbaod...@chromium.org, nona+...@chromium.org, creis...@chromium.org, shuche...@chromium.org, jbauma...@chromium.org, navigation...@chromium.org, keithle...@chromium.org, blink-...@chromium.org, blundell+...@chromium.org, gavinp...@chromium.org, kinuko...@chromium.org, loading-re...@chromium.org, loading...@chromium.org, net-r...@chromium.org, network-ser...@chromium.org
Attention needed from Dave Tapuska and Takashi Toyoshima

Andrew Brown added 1 comment

Patchset-level comments
File-level comment, Patchset 31 (Latest):
Andrew Brown . unresolved

Adding dtapuska@ to review for `content/public/test/url_loader_interceptor.cc`

Hopefully ok, but interested to hear thoughts on performing header merges in different locations.

Open in Gerrit

Related details

Attention is currently required from:
  • Dave Tapuska
  • Takashi Toyoshima
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement is not satisfiedCode-Owners
  • requirement is not satisfiedCode-Review
  • requirement is not satisfiedNo-Unresolved-Comments
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: chromium/src
Gerrit-Branch: main
Gerrit-Change-Id: Icf56620f99f371ea2f128e6a3194d6096b0d62cd
Gerrit-Change-Number: 5273743
Gerrit-PatchSet: 31
Gerrit-Owner: Andrew Brown <m...@ajbrown.au>
Gerrit-Reviewer: Adam Rice <ri...@chromium.org>
Gerrit-Reviewer: Andrew Brown <m...@ajbrown.au>
Gerrit-Reviewer: Dave Tapuska <dtap...@chromium.org>
Gerrit-Reviewer: Min Qin <qin...@chromium.org>
Gerrit-Reviewer: Takashi Toyoshima <toyo...@chromium.org>
Gerrit-CC: Chromium Metrics Reviews <chromium-met...@google.com>
Gerrit-CC: Hiroki Nakagawa <nhi...@chromium.org>
Gerrit-CC: James Maclean <wjma...@chromium.org>
Gerrit-CC: James Su <su...@chromium.org>
Gerrit-CC: Nate Chapin <jap...@chromium.org>
Gerrit-CC: Takashi Nakayama <tn...@chromium.org>
Gerrit-Attention: Dave Tapuska <dtap...@chromium.org>
Gerrit-Attention: Takashi Toyoshima <toyo...@chromium.org>
Gerrit-Comment-Date: Mon, 28 Jul 2025 03:42:51 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
satisfied_requirement
unsatisfied_requirement
open
diffy

Dave Tapuska (Gerrit)

unread,
Jul 28, 2025, 10:19:58 AMJul 28
to Andrew Brown, Alex Moshchuk, Takashi Toyoshima, Chromium Metrics Reviews, Takashi Nakayama, Adam Rice, Min Qin, Hiroki Nakagawa, James Maclean, James Su, AyeAye, Chromium LUCI CQ, chromium...@chromium.org, Nate Chapin, asvitkine...@chromium.org, devtools-re...@chromium.org, extension...@chromium.org, chromium-a...@chromium.org, mkwst+w...@chromium.org, horo+...@chromium.org, shimazu+se...@chromium.org, kinuko+ser...@chromium.org, servicewor...@chromium.org, antoniosarto...@chromium.org, kenjibah...@chromium.org, jsbell+ser...@chromium.org, arthursonzog...@chromium.org, blink-revie...@chromium.org, alexmo...@chromium.org, yhanad...@chromium.org, tranbaod...@chromium.org, nona+...@chromium.org, creis...@chromium.org, shuche...@chromium.org, jbauma...@chromium.org, navigation...@chromium.org, keithle...@chromium.org, blink-...@chromium.org, blundell+...@chromium.org, gavinp...@chromium.org, kinuko...@chromium.org, loading-re...@chromium.org, loading...@chromium.org, net-r...@chromium.org, network-ser...@chromium.org
Attention needed from Alex Moshchuk, Andrew Brown and Takashi Toyoshima

Dave Tapuska added 1 comment

Patchset-level comments
File-level comment, Patchset 33 (Latest):
Dave Tapuska . resolved

Going to defer to Alex here, since it something related to CORS.

Open in Gerrit

Related details

Attention is currently required from:
  • Alex Moshchuk
  • Andrew Brown
  • Takashi Toyoshima
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement is not satisfiedCode-Owners
  • requirement is not satisfiedCode-Review
  • requirement is not satisfiedNo-Unresolved-Comments
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: chromium/src
Gerrit-Branch: main
Gerrit-Change-Id: Icf56620f99f371ea2f128e6a3194d6096b0d62cd
Gerrit-Change-Number: 5273743
Gerrit-PatchSet: 33
Gerrit-Owner: Andrew Brown <m...@ajbrown.au>
Gerrit-Reviewer: Adam Rice <ri...@chromium.org>
Gerrit-Reviewer: Alex Moshchuk <ale...@chromium.org>
Gerrit-Reviewer: Andrew Brown <m...@ajbrown.au>
Gerrit-Reviewer: Min Qin <qin...@chromium.org>
Gerrit-Reviewer: Takashi Toyoshima <toyo...@chromium.org>
Gerrit-CC: Chromium Metrics Reviews <chromium-met...@google.com>
Gerrit-CC: Hiroki Nakagawa <nhi...@chromium.org>
Gerrit-CC: James Maclean <wjma...@chromium.org>
Gerrit-CC: James Su <su...@chromium.org>
Gerrit-CC: Nate Chapin <jap...@chromium.org>
Gerrit-CC: Takashi Nakayama <tn...@chromium.org>
Gerrit-Attention: Andrew Brown <m...@ajbrown.au>
Gerrit-Attention: Alex Moshchuk <ale...@chromium.org>
Gerrit-Attention: Takashi Toyoshima <toyo...@chromium.org>
Gerrit-Comment-Date: Mon, 28 Jul 2025 14:19:51 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
satisfied_requirement
unsatisfied_requirement
open
diffy

Oliver Dunk (Gerrit)

unread,
Jul 29, 2025, 8:54:46 AMJul 29
to Andrew Brown, Devlin Cronin, Alex Moshchuk, Takashi Toyoshima, Chromium Metrics Reviews, Takashi Nakayama, Adam Rice, Min Qin, Hiroki Nakagawa, James Maclean, James Su, AyeAye, Chromium LUCI CQ, chromium...@chromium.org, Nate Chapin, asvitkine...@chromium.org, devtools-re...@chromium.org, extension...@chromium.org, chromium-a...@chromium.org, mkwst+w...@chromium.org, horo+...@chromium.org, shimazu+se...@chromium.org, kinuko+ser...@chromium.org, servicewor...@chromium.org, antoniosarto...@chromium.org, kenjibah...@chromium.org, jsbell+ser...@chromium.org, arthursonzog...@chromium.org, blink-revie...@chromium.org, alexmo...@chromium.org, yhanad...@chromium.org, tranbaod...@chromium.org, nona+...@chromium.org, creis...@chromium.org, shuche...@chromium.org, jbauma...@chromium.org, navigation...@chromium.org, keithle...@chromium.org, blink-...@chromium.org, blundell+...@chromium.org, gavinp...@chromium.org, kinuko...@chromium.org, loading-re...@chromium.org, loading...@chromium.org, net-r...@chromium.org, network-ser...@chromium.org
Attention needed from Alex Moshchuk, Andrew Brown, Devlin Cronin and Takashi Toyoshima

Oliver Dunk added 1 comment

Patchset-level comments
Oliver Dunk . unresolved

Hi @rdevlin...@chromium.org, could you take a look at this one? As described in [1], it sounds like this could impact if the `User-Agent` header is exposed in the webRequest API.

[1] https://groups.google.com/a/chromium.org/d/msgid/chromium-extensions/14e9bbde-433c-4e64-ad3d-d79b36f93bdfn%40chromium.org?utm_medium=email&utm_source=footer

Open in Gerrit

Related details

Attention is currently required from:
  • Alex Moshchuk
  • Andrew Brown
  • Devlin Cronin
  • Takashi Toyoshima
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement is not satisfiedCode-Owners
  • requirement is not satisfiedCode-Review
  • requirement is not satisfiedNo-Unresolved-Comments
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: chromium/src
Gerrit-Branch: main
Gerrit-Change-Id: Icf56620f99f371ea2f128e6a3194d6096b0d62cd
Gerrit-Change-Number: 5273743
Gerrit-PatchSet: 33
Gerrit-Owner: Andrew Brown <m...@ajbrown.au>
Gerrit-Reviewer: Adam Rice <ri...@chromium.org>
Gerrit-Reviewer: Alex Moshchuk <ale...@chromium.org>
Gerrit-Reviewer: Andrew Brown <m...@ajbrown.au>
Gerrit-Reviewer: Devlin Cronin <rdevlin...@chromium.org>
Gerrit-Reviewer: Min Qin <qin...@chromium.org>
Gerrit-Reviewer: Takashi Toyoshima <toyo...@chromium.org>
Gerrit-CC: Chromium Metrics Reviews <chromium-met...@google.com>
Gerrit-CC: Hiroki Nakagawa <nhi...@chromium.org>
Gerrit-CC: James Maclean <wjma...@chromium.org>
Gerrit-CC: James Su <su...@chromium.org>
Gerrit-CC: Nate Chapin <jap...@chromium.org>
Gerrit-CC: Oliver Dunk <olive...@chromium.org>
Gerrit-CC: Takashi Nakayama <tn...@chromium.org>
Gerrit-Attention: Andrew Brown <m...@ajbrown.au>
Gerrit-Attention: Devlin Cronin <rdevlin...@chromium.org>
Gerrit-Attention: Alex Moshchuk <ale...@chromium.org>
Gerrit-Attention: Takashi Toyoshima <toyo...@chromium.org>
Gerrit-Comment-Date: Tue, 29 Jul 2025 12:54:27 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
satisfied_requirement
unsatisfied_requirement
open
diffy

Devlin Cronin (Gerrit)

unread,
Jul 29, 2025, 10:49:40 AMJul 29
to Andrew Brown, Devlin Cronin, Oliver Dunk, Alex Moshchuk, Takashi Toyoshima, Chromium Metrics Reviews, Takashi Nakayama, Adam Rice, Min Qin, Hiroki Nakagawa, James Maclean, James Su, AyeAye, Chromium LUCI CQ, chromium...@chromium.org, Nate Chapin, asvitkine...@chromium.org, devtools-re...@chromium.org, extension...@chromium.org, chromium-a...@chromium.org, mkwst+w...@chromium.org, horo+...@chromium.org, shimazu+se...@chromium.org, kinuko+ser...@chromium.org, servicewor...@chromium.org, antoniosarto...@chromium.org, kenjibah...@chromium.org, jsbell+ser...@chromium.org, arthursonzog...@chromium.org, blink-revie...@chromium.org, alexmo...@chromium.org, yhanad...@chromium.org, tranbaod...@chromium.org, nona+...@chromium.org, creis...@chromium.org, shuche...@chromium.org, jbauma...@chromium.org, navigation...@chromium.org, keithle...@chromium.org, blink-...@chromium.org, blundell+...@chromium.org, gavinp...@chromium.org, kinuko...@chromium.org, loading-re...@chromium.org, loading...@chromium.org, net-r...@chromium.org, network-ser...@chromium.org
Attention needed from Alex Moshchuk, Andrew Brown and Takashi Toyoshima

Devlin Cronin added 1 comment

Patchset-level comments
Oliver Dunk . unresolved

Hi @rdevlin...@chromium.org, could you take a look at this one? As described in [1], it sounds like this could impact if the `User-Agent` header is exposed in the webRequest API.

[1] https://groups.google.com/a/chromium.org/d/msgid/chromium-extensions/14e9bbde-433c-4e64-ad3d-d79b36f93bdfn%40chromium.org?utm_medium=email&utm_source=footer

Devlin Cronin

Thanks for tagging me in, Oliver! I agree that this is concerning for extensions, since it's a potentially large behavior change.

Would it be possible to preserve the existing behavior? The comment [here](https://chromium-review.googlesource.com/c/chromium/src/+/5273743/33/chrome/test/data/extensions/api_test/webrequest/framework.js) implies it is, with a bit of refactoring?

Open in Gerrit

Related details

Attention is currently required from:
  • Alex Moshchuk
  • Andrew Brown
  • Takashi Toyoshima
Gerrit-Attention: Alex Moshchuk <ale...@chromium.org>
Gerrit-Attention: Takashi Toyoshima <toyo...@chromium.org>
Gerrit-Comment-Date: Tue, 29 Jul 2025 14:49:32 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Oliver Dunk <olive...@chromium.org>
satisfied_requirement
unsatisfied_requirement
open
diffy

Andrew Brown (Gerrit)

unread,
Jul 30, 2025, 5:32:23 AMJul 30
to Devlin Cronin, Oliver Dunk, Alex Moshchuk, Takashi Toyoshima, Chromium Metrics Reviews, Takashi Nakayama, Adam Rice, Min Qin, Hiroki Nakagawa, James Maclean, James Su, AyeAye, Chromium LUCI CQ, chromium...@chromium.org, Nate Chapin, asvitkine...@chromium.org, devtools-re...@chromium.org, extension...@chromium.org, chromium-a...@chromium.org, mkwst+w...@chromium.org, horo+...@chromium.org, shimazu+se...@chromium.org, kinuko+ser...@chromium.org, servicewor...@chromium.org, antoniosarto...@chromium.org, kenjibah...@chromium.org, jsbell+ser...@chromium.org, arthursonzog...@chromium.org, blink-revie...@chromium.org, alexmo...@chromium.org, yhanad...@chromium.org, tranbaod...@chromium.org, nona+...@chromium.org, creis...@chromium.org, shuche...@chromium.org, jbauma...@chromium.org, navigation...@chromium.org, keithle...@chromium.org, blink-...@chromium.org, blundell+...@chromium.org, gavinp...@chromium.org, kinuko...@chromium.org, loading-re...@chromium.org, loading...@chromium.org, net-r...@chromium.org, network-ser...@chromium.org
Attention needed from Alex Moshchuk, Devlin Cronin and Takashi Toyoshima

Andrew Brown added 2 comments

Patchset-level comments
Oliver Dunk . unresolved

Hi @rdevlin...@chromium.org, could you take a look at this one? As described in [1], it sounds like this could impact if the `User-Agent` header is exposed in the webRequest API.

[1] https://groups.google.com/a/chromium.org/d/msgid/chromium-extensions/14e9bbde-433c-4e64-ad3d-d79b36f93bdfn%40chromium.org?utm_medium=email&utm_source=footer

Devlin Cronin

Thanks for tagging me in, Oliver! I agree that this is concerning for extensions, since it's a potentially large behavior change.

Would it be possible to preserve the existing behavior? The comment [here](https://chromium-review.googlesource.com/c/chromium/src/+/5273743/33/chrome/test/data/extensions/api_test/webrequest/framework.js) implies it is, with a bit of refactoring?

Andrew Brown

I wasn't sure when I posted to that mailing list, as the standard pattern for header merging isn't compatible with `OnBeforeChangeHeaders` taking a pointer to the headers, but upon further look, it appears possible to preserve the existing behaviour by just merging the new `content_user_agent` in the lead up to extensions triggering the `OnBeforeSendHeaders` event.

This feels suspect, as it appears the headers sent to the event get re-placed back onto the `network::ResourceRequest`, so I don't know if there are other implications of merging the UA back in at this point, but I'm unsure -- thoughts welcome.

File-level comment, Patchset 34 (Latest):
Andrew Brown . unresolved

Something in one of the rebase(s) is now causing a dangling ref when the browser closes :( so the tests are all failing. (Technically I can still run them and see if they pass the "test" section of the test, but they all error out immediately afterwards.) Got my weekend plans cut out for me.

Open in Gerrit

Related details

Attention is currently required from:
  • Alex Moshchuk
  • Devlin Cronin
  • Takashi Toyoshima
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement is not satisfiedCode-Owners
  • requirement is not satisfiedCode-Review
  • requirement is not satisfiedNo-Unresolved-Comments
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: chromium/src
Gerrit-Branch: main
Gerrit-Change-Id: Icf56620f99f371ea2f128e6a3194d6096b0d62cd
Gerrit-Change-Number: 5273743
Gerrit-PatchSet: 34
Gerrit-Owner: Andrew Brown <m...@ajbrown.au>
Gerrit-Reviewer: Adam Rice <ri...@chromium.org>
Gerrit-Reviewer: Alex Moshchuk <ale...@chromium.org>
Gerrit-Reviewer: Andrew Brown <m...@ajbrown.au>
Gerrit-Reviewer: Devlin Cronin <rdevlin...@chromium.org>
Gerrit-Reviewer: Min Qin <qin...@chromium.org>
Gerrit-Reviewer: Takashi Toyoshima <toyo...@chromium.org>
Gerrit-CC: Chromium Metrics Reviews <chromium-met...@google.com>
Gerrit-CC: Hiroki Nakagawa <nhi...@chromium.org>
Gerrit-CC: James Maclean <wjma...@chromium.org>
Gerrit-CC: James Su <su...@chromium.org>
Gerrit-CC: Nate Chapin <jap...@chromium.org>
Gerrit-CC: Oliver Dunk <olive...@chromium.org>
Gerrit-CC: Takashi Nakayama <tn...@chromium.org>
Gerrit-Attention: Devlin Cronin <rdevlin...@chromium.org>
Gerrit-Attention: Alex Moshchuk <ale...@chromium.org>
Gerrit-Attention: Takashi Toyoshima <toyo...@chromium.org>
Gerrit-Comment-Date: Wed, 30 Jul 2025 09:31:53 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Oliver Dunk <olive...@chromium.org>
Comment-In-Reply-To: Devlin Cronin <rdevlin...@chromium.org>
satisfied_requirement
unsatisfied_requirement
open
diffy

Alex Moshchuk (Gerrit)

unread,
Jul 30, 2025, 5:24:46 PMJul 30
to Andrew Brown, Devlin Cronin, Oliver Dunk, Takashi Toyoshima, Chromium Metrics Reviews, Takashi Nakayama, Adam Rice, Min Qin, Hiroki Nakagawa, James Maclean, James Su, AyeAye, Chromium LUCI CQ, chromium...@chromium.org, Nate Chapin, asvitkine...@chromium.org, devtools-re...@chromium.org, extension...@chromium.org, chromium-a...@chromium.org, mkwst+w...@chromium.org, horo+...@chromium.org, shimazu+se...@chromium.org, kinuko+ser...@chromium.org, servicewor...@chromium.org, antoniosarto...@chromium.org, kenjibah...@chromium.org, jsbell+ser...@chromium.org, arthursonzog...@chromium.org, blink-revie...@chromium.org, alexmo...@chromium.org, yhanad...@chromium.org, tranbaod...@chromium.org, nona+...@chromium.org, creis...@chromium.org, shuche...@chromium.org, jbauma...@chromium.org, navigation...@chromium.org, keithle...@chromium.org, blink-...@chromium.org, blundell+...@chromium.org, gavinp...@chromium.org, kinuko...@chromium.org, loading-re...@chromium.org, loading...@chromium.org, net-r...@chromium.org, network-ser...@chromium.org
Attention needed from Andrew Brown, Devlin Cronin and Takashi Toyoshima

Alex Moshchuk added 1 comment

Patchset-level comments
Andrew Brown . unresolved

Adding dtapuska@ to review for `content/public/test/url_loader_interceptor.cc`

Hopefully ok, but interested to hear thoughts on performing header merges in different locations.

Alex Moshchuk

I think this is a better question for network service and loading experts (some of whom are already reviewing this CL). That change looks good mechanically (I did wonder if it's beneficial at all to do the merging in a shared helper, so that this doesn't get out of sync if other headers are added in the future, but not sure how many other places actually end up doing this), but I don't really know much about the code involved here to review this deeper, so I'll have to defer to other reviewers. Happy to approve content/ once everybody's happy with the CL and outstanding questions are resolved.

Open in Gerrit

Related details

Attention is currently required from:
  • Andrew Brown
  • Devlin Cronin
  • Takashi Toyoshima
Gerrit-Attention: Andrew Brown <m...@ajbrown.au>
Gerrit-Attention: Devlin Cronin <rdevlin...@chromium.org>
Gerrit-Attention: Takashi Toyoshima <toyo...@chromium.org>
Gerrit-Comment-Date: Wed, 30 Jul 2025 21:24:40 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Andrew Brown <m...@ajbrown.au>
satisfied_requirement
unsatisfied_requirement
open
diffy

Devlin Cronin (Gerrit)

unread,
Aug 4, 2025, 7:39:16 PMAug 4
to Andrew Brown, Devlin Cronin, Oliver Dunk, Alex Moshchuk, Takashi Toyoshima, Chromium Metrics Reviews, Takashi Nakayama, Adam Rice, Min Qin, Hiroki Nakagawa, James Maclean, James Su, AyeAye, Chromium LUCI CQ, chromium...@chromium.org, Nate Chapin, asvitkine...@chromium.org, devtools-re...@chromium.org, extension...@chromium.org, chromium-a...@chromium.org, mkwst+w...@chromium.org, horo+...@chromium.org, shimazu+se...@chromium.org, kinuko+ser...@chromium.org, servicewor...@chromium.org, antoniosarto...@chromium.org, kenjibah...@chromium.org, jsbell+ser...@chromium.org, arthursonzog...@chromium.org, blink-revie...@chromium.org, alexmo...@chromium.org, yhanad...@chromium.org, tranbaod...@chromium.org, nona+...@chromium.org, creis...@chromium.org, shuche...@chromium.org, jbauma...@chromium.org, navigation...@chromium.org, keithle...@chromium.org, blink-...@chromium.org, blundell+...@chromium.org, gavinp...@chromium.org, kinuko...@chromium.org, loading-re...@chromium.org, loading...@chromium.org, net-r...@chromium.org, network-ser...@chromium.org
Attention needed from Andrew Brown and Takashi Toyoshima

Devlin Cronin added 1 comment

Patchset-level comments
Oliver Dunk . unresolved

Hi @rdevlin...@chromium.org, could you take a look at this one? As described in [1], it sounds like this could impact if the `User-Agent` header is exposed in the webRequest API.

[1] https://groups.google.com/a/chromium.org/d/msgid/chromium-extensions/14e9bbde-433c-4e64-ad3d-d79b36f93bdfn%40chromium.org?utm_medium=email&utm_source=footer

Devlin Cronin

Thanks for tagging me in, Oliver! I agree that this is concerning for extensions, since it's a potentially large behavior change.

Would it be possible to preserve the existing behavior? The comment [here](https://chromium-review.googlesource.com/c/chromium/src/+/5273743/33/chrome/test/data/extensions/api_test/webrequest/framework.js) implies it is, with a bit of refactoring?

Andrew Brown

I wasn't sure when I posted to that mailing list, as the standard pattern for header merging isn't compatible with `OnBeforeChangeHeaders` taking a pointer to the headers, but upon further look, it appears possible to preserve the existing behaviour by just merging the new `content_user_agent` in the lead up to extensions triggering the `OnBeforeSendHeaders` event.

This feels suspect, as it appears the headers sent to the event get re-placed back onto the `network::ResourceRequest`, so I don't know if there are other implications of merging the UA back in at this point, but I'm unsure -- thoughts welcome.

Devlin Cronin

I think that's probably mostly a question for net experts -- maybe @ri...@chromium.org has thoughts?

Open in Gerrit

Related details

Attention is currently required from:
  • Andrew Brown
  • Takashi Toyoshima
Gerrit-Attention: Takashi Toyoshima <toyo...@chromium.org>
Gerrit-Comment-Date: Mon, 04 Aug 2025 23:39:05 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Oliver Dunk <olive...@chromium.org>
Comment-In-Reply-To: Andrew Brown <m...@ajbrown.au>
Comment-In-Reply-To: Devlin Cronin <rdevlin...@chromium.org>
satisfied_requirement
unsatisfied_requirement
open
diffy

Adam Rice (Gerrit)

unread,
Aug 4, 2025, 8:36:38 PMAug 4
to Andrew Brown, Devlin Cronin, Oliver Dunk, Alex Moshchuk, Takashi Toyoshima, Chromium Metrics Reviews, Takashi Nakayama, Min Qin, Hiroki Nakagawa, James Maclean, James Su, AyeAye, Chromium LUCI CQ, chromium...@chromium.org, Nate Chapin, asvitkine...@chromium.org, devtools-re...@chromium.org, extension...@chromium.org, chromium-a...@chromium.org, mkwst+w...@chromium.org, horo+...@chromium.org, shimazu+se...@chromium.org, kinuko+ser...@chromium.org, servicewor...@chromium.org, antoniosarto...@chromium.org, kenjibah...@chromium.org, jsbell+ser...@chromium.org, arthursonzog...@chromium.org, blink-revie...@chromium.org, alexmo...@chromium.org, yhanad...@chromium.org, tranbaod...@chromium.org, nona+...@chromium.org, creis...@chromium.org, shuche...@chromium.org, jbauma...@chromium.org, navigation...@chromium.org, keithle...@chromium.org, blink-...@chromium.org, blundell+...@chromium.org, gavinp...@chromium.org, kinuko...@chromium.org, loading-re...@chromium.org, loading...@chromium.org, net-r...@chromium.org, network-ser...@chromium.org
Attention needed from Andrew Brown and Takashi Toyoshima

Adam Rice added 1 comment

Patchset-level comments
Oliver Dunk . unresolved

Hi @rdevlin...@chromium.org, could you take a look at this one? As described in [1], it sounds like this could impact if the `User-Agent` header is exposed in the webRequest API.

[1] https://groups.google.com/a/chromium.org/d/msgid/chromium-extensions/14e9bbde-433c-4e64-ad3d-d79b36f93bdfn%40chromium.org?utm_medium=email&utm_source=footer

Devlin Cronin

Thanks for tagging me in, Oliver! I agree that this is concerning for extensions, since it's a potentially large behavior change.

Would it be possible to preserve the existing behavior? The comment [here](https://chromium-review.googlesource.com/c/chromium/src/+/5273743/33/chrome/test/data/extensions/api_test/webrequest/framework.js) implies it is, with a bit of refactoring?

Andrew Brown

I wasn't sure when I posted to that mailing list, as the standard pattern for header merging isn't compatible with `OnBeforeChangeHeaders` taking a pointer to the headers, but upon further look, it appears possible to preserve the existing behaviour by just merging the new `content_user_agent` in the lead up to extensions triggering the `OnBeforeSendHeaders` event.

This feels suspect, as it appears the headers sent to the event get re-placed back onto the `network::ResourceRequest`, so I don't know if there are other implications of merging the UA back in at this point, but I'm unsure -- thoughts welcome.

Devlin Cronin

I think that's probably mostly a question for net experts -- maybe @ri...@chromium.org has thoughts?

Adam Rice

As far as I can tell from reading the code, the `request_` only changes the view of the world that extensions have and isn't passed back to the network stack, so changing it should be safe.

Gerrit-Comment-Date: Tue, 05 Aug 2025 00:36:03 +0000
satisfied_requirement
unsatisfied_requirement
open
diffy

Andrew Brown (Gerrit)

unread,
Aug 7, 2025, 9:11:39 PMAug 7
to Devlin Cronin, Oliver Dunk, Alex Moshchuk, Takashi Toyoshima, Chromium Metrics Reviews, Takashi Nakayama, Adam Rice, Min Qin, Hiroki Nakagawa, James Maclean, James Su, AyeAye, Chromium LUCI CQ, chromium...@chromium.org, Nate Chapin, asvitkine...@chromium.org, devtools-re...@chromium.org, extension...@chromium.org, chromium-a...@chromium.org, mkwst+w...@chromium.org, horo+...@chromium.org, shimazu+se...@chromium.org, kinuko+ser...@chromium.org, servicewor...@chromium.org, antoniosarto...@chromium.org, kenjibah...@chromium.org, jsbell+ser...@chromium.org, arthursonzog...@chromium.org, blink-revie...@chromium.org, alexmo...@chromium.org, yhanad...@chromium.org, tranbaod...@chromium.org, nona+...@chromium.org, creis...@chromium.org, shuche...@chromium.org, jbauma...@chromium.org, navigation...@chromium.org, keithle...@chromium.org, blink-...@chromium.org, blundell+...@chromium.org, gavinp...@chromium.org, kinuko...@chromium.org, loading-re...@chromium.org, loading...@chromium.org, net-r...@chromium.org, network-ser...@chromium.org
Attention needed from Takashi Toyoshima

Andrew Brown added 4 comments

Patchset-level comments
File-level comment, Patchset 31:
Andrew Brown . resolved

Adding dtapuska@ to review for `content/public/test/url_loader_interceptor.cc`

Hopefully ok, but interested to hear thoughts on performing header merges in different locations.

Alex Moshchuk

I think this is a better question for network service and loading experts (some of whom are already reviewing this CL). That change looks good mechanically (I did wonder if it's beneficial at all to do the merging in a shared helper, so that this doesn't get out of sync if other headers are added in the future, but not sure how many other places actually end up doing this), but I don't really know much about the code involved here to review this deeper, so I'll have to defer to other reviewers. Happy to approve content/ once everybody's happy with the CL and outstanding questions are resolved.

Andrew Brown

Excellent -- thanks for the assist.

File-level comment, Patchset 33:
Oliver Dunk . resolved

Hi @rdevlin...@chromium.org, could you take a look at this one? As described in [1], it sounds like this could impact if the `User-Agent` header is exposed in the webRequest API.

[1] https://groups.google.com/a/chromium.org/d/msgid/chromium-extensions/14e9bbde-433c-4e64-ad3d-d79b36f93bdfn%40chromium.org?utm_medium=email&utm_source=footer

Devlin Cronin

Thanks for tagging me in, Oliver! I agree that this is concerning for extensions, since it's a potentially large behavior change.

Would it be possible to preserve the existing behavior? The comment [here](https://chromium-review.googlesource.com/c/chromium/src/+/5273743/33/chrome/test/data/extensions/api_test/webrequest/framework.js) implies it is, with a bit of refactoring?

Andrew Brown

I wasn't sure when I posted to that mailing list, as the standard pattern for header merging isn't compatible with `OnBeforeChangeHeaders` taking a pointer to the headers, but upon further look, it appears possible to preserve the existing behaviour by just merging the new `content_user_agent` in the lead up to extensions triggering the `OnBeforeSendHeaders` event.

This feels suspect, as it appears the headers sent to the event get re-placed back onto the `network::ResourceRequest`, so I don't know if there are other implications of merging the UA back in at this point, but I'm unsure -- thoughts welcome.

Devlin Cronin

I think that's probably mostly a question for net experts -- maybe @ri...@chromium.org has thoughts?

Adam Rice

As far as I can tell from reading the code, the `request_` only changes the view of the world that extensions have and isn't passed back to the network stack, so changing it should be safe.

Andrew Brown

Huh, that's excellent. I don't think I would have gotten that aspect, thanks for working that out!

Andrew Brown . unresolved

Something in one of the rebase(s) is now causing a dangling ref when the browser closes :( so the tests are all failing. (Technically I can still run them and see if they pass the "test" section of the test, but they all error out immediately afterwards.) Got my weekend plans cut out for me.

Andrew Brown

@toyo...@chromium.org Could you put this through the bots/dry run again?

I'm still unable to test after a painful week of git tree corruption & completely impenetrable dangling pointer issues. Basically all I managed was to confirm that the dangling pointer occurs on `main` for me too, so it's clearly an issue with my build environment, not the actual contents of the CL.

If my understanding is correct, the only remaining fail should be `external/wpt/xhr/preserve-ua-header-on-redirect.htm`.

File chrome/test/data/extensions/api_test/webrequest/framework.js
Line 296, Patchset 25:function checkUserAgent(headers) {
Andrew Brown . resolved

This is the root cause of a couple remaining failures:

  • ExtensionWebRequestApiPrerenderingTest.Load
  • ExtensionWebRequestApiPrerenderingTest.LoadIntoNewTab

They're using User-Agent as a litmus test for whether the headers on a request are valid, which is fine, but User-Agent is not going to be present on a DevTools "requestWillBeSent" event anymore. So we need a new way to do this.

Takashi Toyoshima

Does this need help from qinmin@ ?
IIUC, this means the webRequest API exposed header is changed, and we need to update the API document, and need an announcement for Extensions developers and enterprise users?

Andrew Brown

Hmm. I think at the moment, yes, but that should actually be fixable.

My first idea is to ensure that the extensions stack combines the `cors_exempt_headers` into any headers returned to the user. I don't know if this is acceptable from a duplication-of-code-behaviour standpoint -- is it ok to have a bunch of places scattered around the code that pseudo-implement the network process's header merging behaviour?

The thing is, I'm uncovering a lot of behaviour that's always been "wrong", but has always been "good enough" -- lots of places where the code only considers `network::ResourceRequest`'s |headers| without combining the |cors_exempt_headers|.

Until now, |cors_exempt_headers| were niche, so it didn't matter, but now, User-Agent is on there... and lots of things care about User-Agent.

I'll try to "fix" the tests by reintroducing the User-Agent to the webRequest API first, and then get qinmin@ 's thoughts on implementation detail.

Andrew Brown

Extensions should see the new UA now.

Open in Gerrit

Related details

Attention is currently required from:
  • Takashi Toyoshima
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement is not satisfiedCode-Owners
  • requirement is not satisfiedCode-Review
  • requirement is not satisfiedNo-Unresolved-Comments
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: chromium/src
Gerrit-Branch: main
Gerrit-Change-Id: Icf56620f99f371ea2f128e6a3194d6096b0d62cd
Gerrit-Change-Number: 5273743
Gerrit-PatchSet: 35
Gerrit-Owner: Andrew Brown <m...@ajbrown.au>
Gerrit-Reviewer: Adam Rice <ri...@chromium.org>
Gerrit-Reviewer: Alex Moshchuk <ale...@chromium.org>
Gerrit-Reviewer: Andrew Brown <m...@ajbrown.au>
Gerrit-Reviewer: Devlin Cronin <rdevlin...@chromium.org>
Gerrit-Reviewer: Min Qin <qin...@chromium.org>
Gerrit-Reviewer: Takashi Toyoshima <toyo...@chromium.org>
Gerrit-CC: Chromium Metrics Reviews <chromium-met...@google.com>
Gerrit-CC: Hiroki Nakagawa <nhi...@chromium.org>
Gerrit-CC: James Maclean <wjma...@chromium.org>
Gerrit-CC: James Su <su...@chromium.org>
Gerrit-CC: Nate Chapin <jap...@chromium.org>
Gerrit-CC: Oliver Dunk <olive...@chromium.org>
Gerrit-CC: Takashi Nakayama <tn...@chromium.org>
Gerrit-Attention: Takashi Toyoshima <toyo...@chromium.org>
Gerrit-Comment-Date: Fri, 08 Aug 2025 01:11:14 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Oliver Dunk <olive...@chromium.org>
Comment-In-Reply-To: Adam Rice <ri...@chromium.org>
Comment-In-Reply-To: Andrew Brown <m...@ajbrown.au>
Comment-In-Reply-To: Alex Moshchuk <ale...@chromium.org>
Comment-In-Reply-To: Devlin Cronin <rdevlin...@chromium.org>
Comment-In-Reply-To: Takashi Toyoshima <toyo...@chromium.org>
satisfied_requirement
unsatisfied_requirement
open
diffy

Devlin Cronin (Gerrit)

unread,
Aug 8, 2025, 4:52:23 PMAug 8
to Andrew Brown, Devlin Cronin, Giovanni Ortuno Urquidi, Oliver Dunk, Alex Moshchuk, Takashi Toyoshima, Chromium Metrics Reviews, Takashi Nakayama, Adam Rice, Min Qin, Hiroki Nakagawa, James Maclean, James Su, AyeAye, Chromium LUCI CQ, chromium...@chromium.org, Nate Chapin, asvitkine...@chromium.org, devtools-re...@chromium.org, extension...@chromium.org, chromium-a...@chromium.org, mkwst+w...@chromium.org, horo+...@chromium.org, shimazu+se...@chromium.org, kinuko+ser...@chromium.org, servicewor...@chromium.org, antoniosarto...@chromium.org, kenjibah...@chromium.org, jsbell+ser...@chromium.org, arthursonzog...@chromium.org, blink-revie...@chromium.org, alexmo...@chromium.org, yhanad...@chromium.org, tranbaod...@chromium.org, nona+...@chromium.org, creis...@chromium.org, shuche...@chromium.org, jbauma...@chromium.org, navigation...@chromium.org, keithle...@chromium.org, blink-...@chromium.org, blundell+...@chromium.org, gavinp...@chromium.org, kinuko...@chromium.org, loading-re...@chromium.org, loading...@chromium.org, net-r...@chromium.org, network-ser...@chromium.org
Attention needed from Andrew Brown and Takashi Toyoshima

Devlin Cronin voted and added 2 comments

Votes added by Devlin Cronin

Code-Review+1

2 comments

Patchset-level comments
File-level comment, Patchset 35 (Latest):
Devlin Cronin . resolved

Thanks, Andrew! Extensions LGTM % nit, since there's now no behavior change.

File extensions/browser/api/web_request/web_request_proxying_url_loader_factory.cc
Line 760, Patchset 35 (Latest): request_.headers.MergeAndAddUA(request_.cors_exempt_headers,
Devlin Cronin . unresolved

nit: maybe add a brief comment about why we need to do this, since there's been a good amount of exploration / discussion?

Open in Gerrit

Related details

Attention is currently required from:
  • Andrew Brown
  • Takashi Toyoshima
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement is not satisfiedCode-Owners
  • requirement is not satisfiedCode-Review
  • requirement is not satisfiedNo-Unresolved-Comments
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: chromium/src
Gerrit-Branch: main
Gerrit-Change-Id: Icf56620f99f371ea2f128e6a3194d6096b0d62cd
Gerrit-Change-Number: 5273743
Gerrit-PatchSet: 35
Gerrit-Owner: Andrew Brown <m...@ajbrown.au>
Gerrit-Reviewer: Adam Rice <ri...@chromium.org>
Gerrit-Reviewer: Alex Moshchuk <ale...@chromium.org>
Gerrit-Reviewer: Andrew Brown <m...@ajbrown.au>
Gerrit-Reviewer: Devlin Cronin <rdevlin...@chromium.org>
Gerrit-Reviewer: Min Qin <qin...@chromium.org>
Gerrit-Reviewer: Takashi Toyoshima <toyo...@chromium.org>
Gerrit-CC: Chromium Metrics Reviews <chromium-met...@google.com>
Gerrit-CC: Giovanni Ortuno Urquidi <ort...@chromium.org>
Gerrit-CC: Hiroki Nakagawa <nhi...@chromium.org>
Gerrit-CC: James Maclean <wjma...@chromium.org>
Gerrit-CC: James Su <su...@chromium.org>
Gerrit-CC: Nate Chapin <jap...@chromium.org>
Gerrit-CC: Oliver Dunk <olive...@chromium.org>
Gerrit-CC: Takashi Nakayama <tn...@chromium.org>
Gerrit-Attention: Andrew Brown <m...@ajbrown.au>
Gerrit-Attention: Takashi Toyoshima <toyo...@chromium.org>
Gerrit-Comment-Date: Fri, 08 Aug 2025 20:52:12 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
satisfied_requirement
unsatisfied_requirement
open
diffy

Andrew Brown (Gerrit)

unread,
Aug 9, 2025, 1:57:34 AMAug 9
to Devlin Cronin, Giovanni Ortuno Urquidi, Oliver Dunk, Alex Moshchuk, Takashi Toyoshima, Chromium Metrics Reviews, Takashi Nakayama, Adam Rice, Min Qin, Hiroki Nakagawa, James Maclean, James Su, AyeAye, Chromium LUCI CQ, chromium...@chromium.org, Nate Chapin, asvitkine...@chromium.org, devtools-re...@chromium.org, extension...@chromium.org, chromium-a...@chromium.org, mkwst+w...@chromium.org, horo+...@chromium.org, shimazu+se...@chromium.org, kinuko+ser...@chromium.org, servicewor...@chromium.org, antoniosarto...@chromium.org, kenjibah...@chromium.org, jsbell+ser...@chromium.org, arthursonzog...@chromium.org, blink-revie...@chromium.org, alexmo...@chromium.org, yhanad...@chromium.org, tranbaod...@chromium.org, nona+...@chromium.org, creis...@chromium.org, shuche...@chromium.org, jbauma...@chromium.org, navigation...@chromium.org, keithle...@chromium.org, blink-...@chromium.org, blundell+...@chromium.org, gavinp...@chromium.org, kinuko...@chromium.org, loading-re...@chromium.org, loading...@chromium.org, net-r...@chromium.org, network-ser...@chromium.org
Attention needed from Devlin Cronin

Andrew Brown added 2 comments

Patchset-level comments
Devlin Cronin . unresolved

Thanks, Andrew! Extensions LGTM % nit, since there's now no behavior change.

Andrew Brown

Unfortunately the current test results do make this seem like it's not yet fixed.

The few failures I've actually drilled into are *all* requests that have gone through the extensions stack, now needing a specific `User-Agent` CORS preflight response.

This means the User-Agent getting added onto the headers in the `OnBeforeSendHeaders` event is actually affecting the real network request somehow, causing it to spot a non-CORS-exempt header on the headers and send a preflight (which the tests don't correctly respond to).

So all requests that go through the Extensions stack are generating a CORS preflight for the User-Agent header, which most things won't expect and respond to. We need to find an alternative approach; merging here isn't suitable.

My first guess is that the associated callback function might be our solution, if it lets me pass the `content_user_agent` back up to the front-end consumer for merging outside of all of this business? I don't know if that's feasible/reasonable at all though, considering that goes back into the black hole of mojom; it looks like it would need a lot of modifications all over the place in unrelated contexts.

Other than that... I'm not sure.

File extensions/browser/api/web_request/web_request_proxying_url_loader_factory.cc
Line 760, Patchset 35 (Latest): request_.headers.MergeAndAddUA(request_.cors_exempt_headers,
Devlin Cronin . unresolved

nit: maybe add a brief comment about why we need to do this, since there's been a good amount of exploration / discussion?

Andrew Brown

Can do, but TBD.

Open in Gerrit

Related details

Attention is currently required from:
  • Devlin Cronin
Gerrit-Attention: Devlin Cronin <rdevlin...@chromium.org>
Gerrit-Comment-Date: Sat, 09 Aug 2025 05:57:01 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Devlin Cronin <rdevlin...@chromium.org>
satisfied_requirement
unsatisfied_requirement
open
diffy

Takashi Toyoshima (Gerrit)

unread,
Aug 12, 2025, 7:07:54 AMAug 12
to Andrew Brown, Devlin Cronin, Giovanni Ortuno Urquidi, Oliver Dunk, Alex Moshchuk, Chromium Metrics Reviews, Takashi Nakayama, Adam Rice, Min Qin, Hiroki Nakagawa, James Maclean, James Su, AyeAye, Chromium LUCI CQ, chromium...@chromium.org, Nate Chapin, asvitkine...@chromium.org, devtools-re...@chromium.org, extension...@chromium.org, chromium-a...@chromium.org, mkwst+w...@chromium.org, horo+...@chromium.org, shimazu+se...@chromium.org, kinuko+ser...@chromium.org, servicewor...@chromium.org, antoniosarto...@chromium.org, kenjibah...@chromium.org, jsbell+ser...@chromium.org, arthursonzog...@chromium.org, blink-revie...@chromium.org, alexmo...@chromium.org, yhanad...@chromium.org, tranbaod...@chromium.org, nona+...@chromium.org, creis...@chromium.org, shuche...@chromium.org, jbauma...@chromium.org, navigation...@chromium.org, keithle...@chromium.org, blink-...@chromium.org, blundell+...@chromium.org, gavinp...@chromium.org, kinuko...@chromium.org, loading-re...@chromium.org, loading...@chromium.org, net-r...@chromium.org, network-ser...@chromium.org
Attention needed from Andrew Brown and Devlin Cronin

Takashi Toyoshima added 2 comments

Patchset-level comments
Takashi Toyoshima . resolved

Sorry, I missed this reply.

File third_party/blink/renderer/platform/loader/fetch/fetch_context.h
Line 200, Patchset 27: virtual String GetDefaultUserAgent() const { NOTREACHED(); }
Takashi Toyoshima . resolved

Can you drop the default implementation instead of adding NOTREACHED?
We will prefer the compile time check rather than runtime check for this.

Andrew Brown

I don't think we can, unfortunately -- e.g. `GetFeatureContext()` or `GetPermissionsPolicy()` just below. I think there has to be a default implementation.

I'm not 100% confident on C++ internals, but I think the issue is that `fetch_context.h/cc` actually gets compiled into some real code at some point, so if you don't have a default implementation, the linker errors out.

Takashi Toyoshima

Ah, you are right. Sorry, I forgot the fact that this class could be directly used too.

Open in Gerrit

Related details

Attention is currently required from:
  • Andrew Brown
  • Devlin Cronin
Gerrit-Attention: Andrew Brown <m...@ajbrown.au>
Gerrit-Attention: Devlin Cronin <rdevlin...@chromium.org>
Gerrit-Comment-Date: Tue, 12 Aug 2025 11:07:19 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
satisfied_requirement
unsatisfied_requirement
open
diffy

Devlin Cronin (Gerrit)

unread,
Aug 13, 2025, 6:54:22 PMAug 13
to Andrew Brown, Devlin Cronin, Giovanni Ortuno Urquidi, Oliver Dunk, Alex Moshchuk, Takashi Toyoshima, Chromium Metrics Reviews, Takashi Nakayama, Adam Rice, Min Qin, Hiroki Nakagawa, James Maclean, James Su, AyeAye, Chromium LUCI CQ, chromium...@chromium.org, Nate Chapin, asvitkine...@chromium.org, devtools-re...@chromium.org, extension...@chromium.org, chromium-a...@chromium.org, mkwst+w...@chromium.org, horo+...@chromium.org, shimazu+se...@chromium.org, kinuko+ser...@chromium.org, servicewor...@chromium.org, antoniosarto...@chromium.org, kenjibah...@chromium.org, jsbell+ser...@chromium.org, arthursonzog...@chromium.org, blink-revie...@chromium.org, alexmo...@chromium.org, yhanad...@chromium.org, tranbaod...@chromium.org, nona+...@chromium.org, creis...@chromium.org, shuche...@chromium.org, jbauma...@chromium.org, navigation...@chromium.org, keithle...@chromium.org, blink-...@chromium.org, blundell+...@chromium.org, gavinp...@chromium.org, kinuko...@chromium.org, loading-re...@chromium.org, loading...@chromium.org, net-r...@chromium.org, network-ser...@chromium.org
Attention needed from Andrew Brown

Devlin Cronin added 1 comment

Patchset-level comments
Devlin Cronin . unresolved

Thanks, Andrew! Extensions LGTM % nit, since there's now no behavior change.

Andrew Brown

Unfortunately the current test results do make this seem like it's not yet fixed.

The few failures I've actually drilled into are *all* requests that have gone through the extensions stack, now needing a specific `User-Agent` CORS preflight response.

This means the User-Agent getting added onto the headers in the `OnBeforeSendHeaders` event is actually affecting the real network request somehow, causing it to spot a non-CORS-exempt header on the headers and send a preflight (which the tests don't correctly respond to).

So all requests that go through the Extensions stack are generating a CORS preflight for the User-Agent header, which most things won't expect and respond to. We need to find an alternative approach; merging here isn't suitable.

My first guess is that the associated callback function might be our solution, if it lets me pass the `content_user_agent` back up to the front-end consumer for merging outside of all of this business? I don't know if that's feasible/reasonable at all though, considering that goes back into the black hole of mojom; it looks like it would need a lot of modifications all over the place in unrelated contexts.

Other than that... I'm not sure.

Devlin Cronin

Thanks for the continued investigation!

Unfortunately, I'm not sure of what the right solution here is, either. Since this is mostly touching the net stack, I'd defer to one of those owners. @ri...@chromium.org?

Open in Gerrit

Related details

Attention is currently required from:
  • Andrew Brown
Submit Requirements:
    • requirement satisfiedCode-Coverage
    • requirement is not satisfiedCode-Owners
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    • requirement satisfiedRecitation-Check
    Gerrit-Comment-Date: Wed, 13 Aug 2025 22:54:08 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    Comment-In-Reply-To: Andrew Brown <m...@ajbrown.au>
    Comment-In-Reply-To: Devlin Cronin <rdevlin...@chromium.org>
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Devlin Cronin (Gerrit)

    unread,
    Aug 13, 2025, 6:54:25 PMAug 13
    to Andrew Brown, Devlin Cronin, Giovanni Ortuno Urquidi, Oliver Dunk, Alex Moshchuk, Takashi Toyoshima, Chromium Metrics Reviews, Takashi Nakayama, Adam Rice, Min Qin, Hiroki Nakagawa, James Maclean, James Su, AyeAye, Chromium LUCI CQ, chromium...@chromium.org, Nate Chapin, asvitkine...@chromium.org, devtools-re...@chromium.org, extension...@chromium.org, chromium-a...@chromium.org, mkwst+w...@chromium.org, horo+...@chromium.org, shimazu+se...@chromium.org, kinuko+ser...@chromium.org, servicewor...@chromium.org, antoniosarto...@chromium.org, kenjibah...@chromium.org, jsbell+ser...@chromium.org, arthursonzog...@chromium.org, blink-revie...@chromium.org, alexmo...@chromium.org, yhanad...@chromium.org, tranbaod...@chromium.org, nona+...@chromium.org, creis...@chromium.org, shuche...@chromium.org, jbauma...@chromium.org, navigation...@chromium.org, keithle...@chromium.org, blink-...@chromium.org, blundell+...@chromium.org, gavinp...@chromium.org, kinuko...@chromium.org, loading-re...@chromium.org, loading...@chromium.org, net-r...@chromium.org, network-ser...@chromium.org
    Attention needed from Andrew Brown

    Devlin Cronin voted Code-Review+0

    Code-Review+0
    Gerrit-Comment-Date: Wed, 13 Aug 2025 22:54:16 +0000
    Gerrit-HasComments: No
    Gerrit-Has-Labels: Yes
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Andrew Brown (Gerrit)

    unread,
    Aug 14, 2025, 5:21:32 AMAug 14
    to Clark DuVall, Devlin Cronin, Giovanni Ortuno Urquidi, Oliver Dunk, Alex Moshchuk, Takashi Toyoshima, Chromium Metrics Reviews, Takashi Nakayama, Adam Rice, Min Qin, Hiroki Nakagawa, James Maclean, James Su, AyeAye, Chromium LUCI CQ, chromium...@chromium.org, Nate Chapin, asvitkine...@chromium.org, devtools-re...@chromium.org, extension...@chromium.org, chromium-a...@chromium.org, mkwst+w...@chromium.org, horo+...@chromium.org, shimazu+se...@chromium.org, kinuko+ser...@chromium.org, servicewor...@chromium.org, antoniosarto...@chromium.org, kenjibah...@chromium.org, jsbell+ser...@chromium.org, arthursonzog...@chromium.org, blink-revie...@chromium.org, alexmo...@chromium.org, yhanad...@chromium.org, tranbaod...@chromium.org, nona+...@chromium.org, creis...@chromium.org, shuche...@chromium.org, jbauma...@chromium.org, navigation...@chromium.org, keithle...@chromium.org, blink-...@chromium.org, blundell+...@chromium.org, gavinp...@chromium.org, kinuko...@chromium.org, loading-re...@chromium.org, loading...@chromium.org, net-r...@chromium.org, network-ser...@chromium.org
    Attention needed from Adam Rice and Clark DuVall

    Andrew Brown added 5 comments

    Patchset-level comments
    File-level comment, Patchset 34:
    Andrew Brown . resolved

    Something in one of the rebase(s) is now causing a dangling ref when the browser closes :( so the tests are all failing. (Technically I can still run them and see if they pass the "test" section of the test, but they all error out immediately afterwards.) Got my weekend plans cut out for me.

    Andrew Brown

    @toyo...@chromium.org Could you put this through the bots/dry run again?

    I'm still unable to test after a painful week of git tree corruption & completely impenetrable dangling pointer issues. Basically all I managed was to confirm that the dangling pointer occurs on `main` for me too, so it's clearly an issue with my build environment, not the actual contents of the CL.

    If my understanding is correct, the only remaining fail should be `external/wpt/xhr/preserve-ua-header-on-redirect.htm`.

    Devlin Cronin . unresolved

    Thanks, Andrew! Extensions LGTM % nit, since there's now no behavior change.

    Andrew Brown

    Unfortunately the current test results do make this seem like it's not yet fixed.

    The few failures I've actually drilled into are *all* requests that have gone through the extensions stack, now needing a specific `User-Agent` CORS preflight response.

    This means the User-Agent getting added onto the headers in the `OnBeforeSendHeaders` event is actually affecting the real network request somehow, causing it to spot a non-CORS-exempt header on the headers and send a preflight (which the tests don't correctly respond to).

    So all requests that go through the Extensions stack are generating a CORS preflight for the User-Agent header, which most things won't expect and respond to. We need to find an alternative approach; merging here isn't suitable.

    My first guess is that the associated callback function might be our solution, if it lets me pass the `content_user_agent` back up to the front-end consumer for merging outside of all of this business? I don't know if that's feasible/reasonable at all though, considering that goes back into the black hole of mojom; it looks like it would need a lot of modifications all over the place in unrelated contexts.

    Other than that... I'm not sure.

    Devlin Cronin

    Thanks for the continued investigation!

    Unfortunately, I'm not sure of what the right solution here is, either. Since this is mostly touching the net stack, I'd defer to one of those owners. @ri...@chromium.org?

    Andrew Brown

    I don't know if this is taboo to ping a second person for the same stuff, but I'll also add @cdu...@chromium.org for thoughts -- I was snooping the `OWNERS` of nearby code and he sounds like he might have expertise in this area (specifically the overlap between extensions & networking).

    (Relevant file is `extensions/browser/api/web_request/web_request_proxying_url_loader_factory.cc` w/r/t "How do we get the `content_user_agent` into Extensions before `OnBeforeSendHeaders` fires, without merging it into the request's normal headers?")

    File-level comment, Patchset 37 (Latest):
    Andrew Brown . unresolved

    I've temporarily commented out the mystery-tbd-Extensions-merging stuff that we're still working out -- could someone put this CL through a dryrun so I can check the redirect implementation is all working? I've made changes that fixed the last dubious test locally; just want to check it hasn't broken anything else in the process.

    It should pass everything *but* the two Extensions tests.

    File extensions/browser/api/web_request/web_request_proxying_url_loader_factory.cc
    Line 760, Patchset 35: request_.headers.MergeAndAddUA(request_.cors_exempt_headers,
    Devlin Cronin . resolved

    nit: maybe add a brief comment about why we need to do this, since there's been a good amount of exploration / discussion?

    Andrew Brown

    Can do, but TBD.

    Andrew Brown

    I'll resolve this comment for now, but I'll make sure there's a good few comments around whatever the final implementation ends up being.

    File services/network/cors/preflight_controller.cc
    Andrew Brown

    I'll just leave this one unresolved because it has the nicest summary of the whole setup we've got going here.

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Adam Rice
    • Clark DuVall
    Submit Requirements:
    • requirement satisfiedCode-Coverage
    • requirement is not satisfiedCode-Owners
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: chromium/src
    Gerrit-Branch: main
    Gerrit-Change-Id: Icf56620f99f371ea2f128e6a3194d6096b0d62cd
    Gerrit-Change-Number: 5273743
    Gerrit-PatchSet: 37
    Gerrit-Owner: Andrew Brown <m...@ajbrown.au>
    Gerrit-Reviewer: Adam Rice <ri...@chromium.org>
    Gerrit-Reviewer: Alex Moshchuk <ale...@chromium.org>
    Gerrit-Reviewer: Andrew Brown <m...@ajbrown.au>
    Gerrit-Reviewer: Devlin Cronin <rdevlin...@chromium.org>
    Gerrit-Reviewer: Min Qin <qin...@chromium.org>
    Gerrit-Reviewer: Takashi Toyoshima <toyo...@chromium.org>
    Gerrit-CC: Chromium Metrics Reviews <chromium-met...@google.com>
    Gerrit-CC: Clark DuVall <cdu...@chromium.org>
    Gerrit-CC: Giovanni Ortuno Urquidi <ort...@chromium.org>
    Gerrit-CC: Hiroki Nakagawa <nhi...@chromium.org>
    Gerrit-CC: James Maclean <wjma...@chromium.org>
    Gerrit-CC: James Su <su...@chromium.org>
    Gerrit-CC: Nate Chapin <jap...@chromium.org>
    Gerrit-CC: Oliver Dunk <olive...@chromium.org>
    Gerrit-CC: Takashi Nakayama <tn...@chromium.org>
    Gerrit-Attention: Clark DuVall <cdu...@chromium.org>
    Gerrit-Attention: Adam Rice <ri...@chromium.org>
    Gerrit-Comment-Date: Thu, 14 Aug 2025 09:21:05 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    Comment-In-Reply-To: Andrew Brown <m...@ajbrown.au>
    Comment-In-Reply-To: Devlin Cronin <rdevlin...@chromium.org>
    Comment-In-Reply-To: Takashi Toyoshima <toyo...@chromium.org>
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Adam Rice (Gerrit)

    unread,
    Aug 14, 2025, 5:39:53 AMAug 14
    to Andrew Brown, Clark DuVall, Devlin Cronin, Giovanni Ortuno Urquidi, Oliver Dunk, Alex Moshchuk, Takashi Toyoshima, Chromium Metrics Reviews, Takashi Nakayama, Min Qin, Hiroki Nakagawa, James Maclean, James Su, AyeAye, Chromium LUCI CQ, chromium...@chromium.org, Nate Chapin, asvitkine...@chromium.org, devtools-re...@chromium.org, extension...@chromium.org, chromium-a...@chromium.org, mkwst+w...@chromium.org, horo+...@chromium.org, shimazu+se...@chromium.org, kinuko+ser...@chromium.org, servicewor...@chromium.org, antoniosarto...@chromium.org, kenjibah...@chromium.org, jsbell+ser...@chromium.org, arthursonzog...@chromium.org, blink-revie...@chromium.org, alexmo...@chromium.org, yhanad...@chromium.org, tranbaod...@chromium.org, nona+...@chromium.org, creis...@chromium.org, shuche...@chromium.org, jbauma...@chromium.org, navigation...@chromium.org, keithle...@chromium.org, blink-...@chromium.org, blundell+...@chromium.org, gavinp...@chromium.org, kinuko...@chromium.org, loading-re...@chromium.org, loading...@chromium.org, net-r...@chromium.org, network-ser...@chromium.org
    Attention needed from Adam Rice and Clark DuVall

    Adam Rice added 3 comments

    Patchset-level comments
    Devlin Cronin . unresolved

    Thanks, Andrew! Extensions LGTM % nit, since there's now no behavior change.

    Andrew Brown

    Unfortunately the current test results do make this seem like it's not yet fixed.

    The few failures I've actually drilled into are *all* requests that have gone through the extensions stack, now needing a specific `User-Agent` CORS preflight response.

    This means the User-Agent getting added onto the headers in the `OnBeforeSendHeaders` event is actually affecting the real network request somehow, causing it to spot a non-CORS-exempt header on the headers and send a preflight (which the tests don't correctly respond to).

    So all requests that go through the Extensions stack are generating a CORS preflight for the User-Agent header, which most things won't expect and respond to. We need to find an alternative approach; merging here isn't suitable.

    My first guess is that the associated callback function might be our solution, if it lets me pass the `content_user_agent` back up to the front-end consumer for merging outside of all of this business? I don't know if that's feasible/reasonable at all though, considering that goes back into the black hole of mojom; it looks like it would need a lot of modifications all over the place in unrelated contexts.

    Other than that... I'm not sure.

    Devlin Cronin

    Thanks for the continued investigation!

    Unfortunately, I'm not sure of what the right solution here is, either. Since this is mostly touching the net stack, I'd defer to one of those owners. @ri...@chromium.org?

    Adam Rice

    I misunderstood the code when I looked at it before. This is happening before we call `CreateLoaderAndStart()`, so any modifications to `request_` will affect the real request. So we can't modify `request_` here.

    What I propose instead is to create a new `headers_with_user_agent_` member variable in the `InProgressRequest` class, which is a copy of `request_.headers` but with the User-Agent header added. Then anywhere we are currently calling a WebRequestEventRouter with a pointer to `request_.headers`, pass a pointer to `headers_with_user_agent_` instead.

    Any code which modifies `request_.headers`, for example WebRequestProxyingURLLoaderFactory::InProgressRequest::FollowRedirect(), must recreate `headers_with_user_agent_` to make sure it remains correct. Possibly it will be sufficient to put that code in the UpdateRequestInfo() method?

    The extra cost of copying the headers on the request fast path bothers me, but I can't see any way around it.

    File net/http/http_request_headers.h
    Line 184, Patchset 35: void MergeAndAddUA(const HttpRequestHeaders& other,
    Adam Rice . unresolved
    Since this method is rather specialised and doesn't require access to HttpRequestHeaders internals, I would prefer if it was not a method on the class. A static function in `net::HttpUtil`  would be preferable. Something like
    ```
    static HttpRequestHeaders MergeHeadersAndAddUserAgent(
    net::HttpRequestHeaders info,
    const net::HttpRequestHeaders& from,
    std::optional<std::string> user_agent);
    ```
    The asymmetry between the passing convention for the parameters is so you can do
    ```
    existing =
    net::HttpUtil::MergeHeadersAndAddUserAgent(std::move(existing), extra_headers, user_agent);
    ```
    and it will efficiently move the `existing` object to the output, or
    ```
    net::HttpRequestHeaders merged =
    net::HttpUtil::MargeHeadersAndAddUserAgent(base, extra_headers, user_agent);
    ```
    when you need a new object.
    File services/network/public/mojom/url_request.mojom
    Line 285, Patchset 28: // already set a User-Agent via fetch.
    Andrew Brown . unresolved

    Is the terminology in this comment sensible?

    Adam Rice

    How about something like:
    ```
    The correct value for the "User-Agent" header from the point-of-view of the
    caller, after DevTools and other overrides have been applied. If this is not set, the "User-Agent" value configured on the NetworkContext will be used instead.
    This can be overridden by setting a "User-Agent" in `headers`, but that will
    require a CORS preflight for an untrusted client.

    The `User-Agent` header cannot be set both in `cors_exempt_headers` as it will
    not be merged correctly if it was also set in `headers`.
    ```

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Adam Rice
    • Clark DuVall
    Submit Requirements:
    • requirement satisfiedCode-Coverage
    • requirement is not satisfiedCode-Owners
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: chromium/src
    Gerrit-Branch: main
    Gerrit-Change-Id: Icf56620f99f371ea2f128e6a3194d6096b0d62cd
    Gerrit-Change-Number: 5273743
    Gerrit-PatchSet: 35
    Gerrit-Owner: Andrew Brown <m...@ajbrown.au>
    Gerrit-Reviewer: Adam Rice <ri...@chromium.org>
    Gerrit-Reviewer: Alex Moshchuk <ale...@chromium.org>
    Gerrit-Reviewer: Andrew Brown <m...@ajbrown.au>
    Gerrit-Reviewer: Devlin Cronin <rdevlin...@chromium.org>
    Gerrit-Reviewer: Min Qin <qin...@chromium.org>
    Gerrit-Reviewer: Takashi Toyoshima <toyo...@chromium.org>
    Gerrit-CC: Chromium Metrics Reviews <chromium-met...@google.com>
    Gerrit-CC: Clark DuVall <cdu...@chromium.org>
    Gerrit-CC: Giovanni Ortuno Urquidi <ort...@chromium.org>
    Gerrit-CC: Hiroki Nakagawa <nhi...@chromium.org>
    Gerrit-CC: James Maclean <wjma...@chromium.org>
    Gerrit-CC: James Su <su...@chromium.org>
    Gerrit-CC: Nate Chapin <jap...@chromium.org>
    Gerrit-CC: Oliver Dunk <olive...@chromium.org>
    Gerrit-CC: Takashi Nakayama <tn...@chromium.org>
    Gerrit-Attention: Clark DuVall <cdu...@chromium.org>
    Gerrit-Attention: Adam Rice <ri...@chromium.org>
    Gerrit-Comment-Date: Thu, 14 Aug 2025 09:39:22 +0000
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Adam Rice (Gerrit)

    unread,
    Aug 17, 2025, 12:53:06 PMAug 17
    to Andrew Brown, Clark DuVall, Devlin Cronin, Giovanni Ortuno Urquidi, Oliver Dunk, Alex Moshchuk, Takashi Toyoshima, Chromium Metrics Reviews, Takashi Nakayama, Min Qin, Hiroki Nakagawa, James Maclean, James Su, AyeAye, Chromium LUCI CQ, chromium...@chromium.org, Nate Chapin, asvitkine...@chromium.org, devtools-re...@chromium.org, extension...@chromium.org, chromium-a...@chromium.org, mkwst+w...@chromium.org, horo+...@chromium.org, shimazu+se...@chromium.org, kinuko+ser...@chromium.org, servicewor...@chromium.org, antoniosarto...@chromium.org, kenjibah...@chromium.org, jsbell+ser...@chromium.org, arthursonzog...@chromium.org, blink-revie...@chromium.org, alexmo...@chromium.org, yhanad...@chromium.org, tranbaod...@chromium.org, nona+...@chromium.org, creis...@chromium.org, shuche...@chromium.org, jbauma...@chromium.org, navigation...@chromium.org, keithle...@chromium.org, blink-...@chromium.org, blundell+...@chromium.org, gavinp...@chromium.org, kinuko...@chromium.org, loading-re...@chromium.org, loading...@chromium.org, net-r...@chromium.org, network-ser...@chromium.org
    Attention needed from Andrew Brown and Clark DuVall

    Adam Rice added 1 comment

    File third_party/blink/renderer/core/loader/frame_fetch_context_test.cc
    Line 1565, Patchset 25: EXPECT_EQ("hi", GetFetchContext()->GetDefaultUserAgent());
    Andrew Brown . unresolved

    I would resurrect my comments from patchset 14, but they don't link through to the new code.

    Is this test sensible? I feel like it's not, because the name suggests to me that instead of checking UA the new way, we should instead be looking at whether PrepareRequest does it's job -- just using a different litmus test than User-Agent. Advice welcome.

    Adam Rice

    Looking at the original CL, there does seem to be a point to this:
    https://chromium-review.googlesource.com/c/chromium/src/+/518743

    Detaching the page causes the user agent string to be cached, and so the test is verifying that the code is doing this correctly.

    Maybe add some comments, but keep it the same? Or add another test that does actually call `PrepareRequest()` and verifies something else it is supposed to be doing?

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Andrew Brown
    • Clark DuVall
    Submit Requirements:
    • requirement satisfiedCode-Coverage
    • requirement is not satisfiedCode-Owners
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: chromium/src
    Gerrit-Branch: main
    Gerrit-Change-Id: Icf56620f99f371ea2f128e6a3194d6096b0d62cd
    Gerrit-Change-Number: 5273743
    Gerrit-PatchSet: 37
    Gerrit-Owner: Andrew Brown <m...@ajbrown.au>
    Gerrit-Reviewer: Adam Rice <ri...@chromium.org>
    Gerrit-Reviewer: Alex Moshchuk <ale...@chromium.org>
    Gerrit-Reviewer: Andrew Brown <m...@ajbrown.au>
    Gerrit-Reviewer: Devlin Cronin <rdevlin...@chromium.org>
    Gerrit-Reviewer: Min Qin <qin...@chromium.org>
    Gerrit-Reviewer: Takashi Toyoshima <toyo...@chromium.org>
    Gerrit-CC: Chromium Metrics Reviews <chromium-met...@google.com>
    Gerrit-CC: Clark DuVall <cdu...@chromium.org>
    Gerrit-CC: Giovanni Ortuno Urquidi <ort...@chromium.org>
    Gerrit-CC: Hiroki Nakagawa <nhi...@chromium.org>
    Gerrit-CC: James Maclean <wjma...@chromium.org>
    Gerrit-CC: James Su <su...@chromium.org>
    Gerrit-CC: Nate Chapin <jap...@chromium.org>
    Gerrit-CC: Oliver Dunk <olive...@chromium.org>
    Gerrit-CC: Takashi Nakayama <tn...@chromium.org>
    Gerrit-Attention: Clark DuVall <cdu...@chromium.org>
    Gerrit-Attention: Andrew Brown <m...@ajbrown.au>
    Gerrit-Comment-Date: Sun, 17 Aug 2025 16:52:49 +0000
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Andrew Brown (Gerrit)

    unread,
    Aug 17, 2025, 11:33:39 PMAug 17
    to Adam Rice, Clark DuVall, Devlin Cronin, Giovanni Ortuno Urquidi, Oliver Dunk, Alex Moshchuk, Takashi Toyoshima, Chromium Metrics Reviews, Takashi Nakayama, Min Qin, Hiroki Nakagawa, James Maclean, James Su, AyeAye, Chromium LUCI CQ, chromium...@chromium.org, Nate Chapin, asvitkine...@chromium.org, devtools-re...@chromium.org, extension...@chromium.org, chromium-a...@chromium.org, mkwst+w...@chromium.org, horo+...@chromium.org, shimazu+se...@chromium.org, kinuko+ser...@chromium.org, servicewor...@chromium.org, antoniosarto...@chromium.org, kenjibah...@chromium.org, jsbell+ser...@chromium.org, arthursonzog...@chromium.org, blink-revie...@chromium.org, alexmo...@chromium.org, yhanad...@chromium.org, tranbaod...@chromium.org, nona+...@chromium.org, creis...@chromium.org, shuche...@chromium.org, jbauma...@chromium.org, navigation...@chromium.org, keithle...@chromium.org, blink-...@chromium.org, blundell+...@chromium.org, gavinp...@chromium.org, kinuko...@chromium.org, loading-re...@chromium.org, loading...@chromium.org, net-r...@chromium.org, network-ser...@chromium.org
    Attention needed from Adam Rice and Clark DuVall

    Andrew Brown added 5 comments

    Patchset-level comments
    Devlin Cronin . unresolved

    Thanks, Andrew! Extensions LGTM % nit, since there's now no behavior change.

    Andrew Brown

    Unfortunately the current test results do make this seem like it's not yet fixed.

    The few failures I've actually drilled into are *all* requests that have gone through the extensions stack, now needing a specific `User-Agent` CORS preflight response.

    This means the User-Agent getting added onto the headers in the `OnBeforeSendHeaders` event is actually affecting the real network request somehow, causing it to spot a non-CORS-exempt header on the headers and send a preflight (which the tests don't correctly respond to).

    So all requests that go through the Extensions stack are generating a CORS preflight for the User-Agent header, which most things won't expect and respond to. We need to find an alternative approach; merging here isn't suitable.

    My first guess is that the associated callback function might be our solution, if it lets me pass the `content_user_agent` back up to the front-end consumer for merging outside of all of this business? I don't know if that's feasible/reasonable at all though, considering that goes back into the black hole of mojom; it looks like it would need a lot of modifications all over the place in unrelated contexts.

    Other than that... I'm not sure.

    Devlin Cronin

    Thanks for the continued investigation!

    Unfortunately, I'm not sure of what the right solution here is, either. Since this is mostly touching the net stack, I'd defer to one of those owners. @ri...@chromium.org?

    Adam Rice

    I misunderstood the code when I looked at it before. This is happening before we call `CreateLoaderAndStart()`, so any modifications to `request_` will affect the real request. So we can't modify `request_` here.

    What I propose instead is to create a new `headers_with_user_agent_` member variable in the `InProgressRequest` class, which is a copy of `request_.headers` but with the User-Agent header added. Then anywhere we are currently calling a WebRequestEventRouter with a pointer to `request_.headers`, pass a pointer to `headers_with_user_agent_` instead.

    Any code which modifies `request_.headers`, for example WebRequestProxyingURLLoaderFactory::InProgressRequest::FollowRedirect(), must recreate `headers_with_user_agent_` to make sure it remains correct. Possibly it will be sufficient to put that code in the UpdateRequestInfo() method?

    The extra cost of copying the headers on the request fast path bothers me, but I can't see any way around it.

    Andrew Brown

    I've implemented this (I think?) -- dryrun please.

    I've called it `user_visible_headers_` with the logic that they're the headers that get sent back up to the "user" (i.e. extensions). Terminology check would be appreciated.

    My first attempt (which is now uploaded) seemed to pass the tests that I ran locally, which scares me a little, but if it works it works.

    Having now written it, I definitely can see where you're not keen on the extra copy... it feels bad to be making the `user_visible_headers_` in the constructor and then completely remaking them again in `ContinueToBeforeSendHeaders`. There might be a way around it if we try to ensure that `user_visible_headers_` are updated wherever the `headers` change? But that seems like a lot of code complexity, so eh.

    File-level comment, Patchset 37:
    Andrew Brown . resolved

    I've temporarily commented out the mystery-tbd-Extensions-merging stuff that we're still working out -- could someone put this CL through a dryrun so I can check the redirect implementation is all working? I've made changes that fixed the last dubious test locally; just want to check it hasn't broken anything else in the process.

    It should pass everything *but* the two Extensions tests.

    Andrew Brown

    Done

    File net/http/http_request_headers.h
    Line 184, Patchset 35: void MergeAndAddUA(const HttpRequestHeaders& other,
    Adam Rice . resolved
    Since this method is rather specialised and doesn't require access to HttpRequestHeaders internals, I would prefer if it was not a method on the class. A static function in `net::HttpUtil`  would be preferable. Something like
    ```
    static HttpRequestHeaders MergeHeadersAndAddUserAgent(
    net::HttpRequestHeaders info,
    const net::HttpRequestHeaders& from,
    std::optional<std::string> user_agent);
    ```
    The asymmetry between the passing convention for the parameters is so you can do
    ```
    existing =
    net::HttpUtil::MergeHeadersAndAddUserAgent(std::move(existing), extra_headers, user_agent);
    ```
    and it will efficiently move the `existing` object to the output, or
    ```
    net::HttpRequestHeaders merged =
    net::HttpUtil::MargeHeadersAndAddUserAgent(base, extra_headers, user_agent);
    ```
    when you need a new object.
    Andrew Brown

    Huh, nifty. Done!

    File services/network/public/mojom/url_request.mojom
    Line 285, Patchset 28: // already set a User-Agent via fetch.
    Andrew Brown . resolved

    Is the terminology in this comment sensible?

    Adam Rice

    How about something like:
    ```
    The correct value for the "User-Agent" header from the point-of-view of the
    caller, after DevTools and other overrides have been applied. If this is not set, the "User-Agent" value configured on the NetworkContext will be used instead.
    This can be overridden by setting a "User-Agent" in `headers`, but that will
    require a CORS preflight for an untrusted client.

    The `User-Agent` header cannot be set both in `cors_exempt_headers` as it will
    not be merged correctly if it was also set in `headers`.
    ```

    Andrew Brown

    Added with a few slight changes.

    File third_party/blink/renderer/core/loader/frame_fetch_context_test.cc
    Line 1565, Patchset 25: EXPECT_EQ("hi", GetFetchContext()->GetDefaultUserAgent());
    Andrew Brown . unresolved

    I would resurrect my comments from patchset 14, but they don't link through to the new code.

    Is this test sensible? I feel like it's not, because the name suggests to me that instead of checking UA the new way, we should instead be looking at whether PrepareRequest does it's job -- just using a different litmus test than User-Agent. Advice welcome.

    Adam Rice

    Looking at the original CL, there does seem to be a point to this:
    https://chromium-review.googlesource.com/c/chromium/src/+/518743

    Detaching the page causes the user agent string to be cached, and so the test is verifying that the code is doing this correctly.

    Maybe add some comments, but keep it the same? Or add another test that does actually call `PrepareRequest()` and verifies something else it is supposed to be doing?

    Andrew Brown

    I've added a new `PrepareRequestWhenDetached` that checks the UkmSourceID.

    I think that should be equivalent(?), as far as the old test was checking that you could call PrepareRequest while detached and it would still do some sort of stuff.

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Adam Rice
    • Clark DuVall
    Submit Requirements:
    • requirement satisfiedCode-Coverage
    • requirement is not satisfiedCode-Owners
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: chromium/src
    Gerrit-Branch: main
    Gerrit-Change-Id: Icf56620f99f371ea2f128e6a3194d6096b0d62cd
    Gerrit-Change-Number: 5273743
    Gerrit-PatchSet: 38
    Gerrit-Owner: Andrew Brown <m...@ajbrown.au>
    Gerrit-Reviewer: Adam Rice <ri...@chromium.org>
    Gerrit-Reviewer: Alex Moshchuk <ale...@chromium.org>
    Gerrit-Reviewer: Andrew Brown <m...@ajbrown.au>
    Gerrit-Reviewer: Devlin Cronin <rdevlin...@chromium.org>
    Gerrit-Reviewer: Min Qin <qin...@chromium.org>
    Gerrit-Reviewer: Takashi Toyoshima <toyo...@chromium.org>
    Gerrit-CC: Chromium Metrics Reviews <chromium-met...@google.com>
    Gerrit-CC: Clark DuVall <cdu...@chromium.org>
    Gerrit-CC: Giovanni Ortuno Urquidi <ort...@chromium.org>
    Gerrit-CC: Hiroki Nakagawa <nhi...@chromium.org>
    Gerrit-CC: James Maclean <wjma...@chromium.org>
    Gerrit-CC: James Su <su...@chromium.org>
    Gerrit-CC: Nate Chapin <jap...@chromium.org>
    Gerrit-CC: Oliver Dunk <olive...@chromium.org>
    Gerrit-CC: Takashi Nakayama <tn...@chromium.org>
    Gerrit-Attention: Clark DuVall <cdu...@chromium.org>
    Gerrit-Attention: Adam Rice <ri...@chromium.org>
    Gerrit-Comment-Date: Mon, 18 Aug 2025 03:33:08 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    Comment-In-Reply-To: Adam Rice <ri...@chromium.org>
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Adam Rice (Gerrit)

    unread,
    Aug 18, 2025, 4:49:15 PMAug 18
    to Andrew Brown, Clark DuVall, Devlin Cronin, Giovanni Ortuno Urquidi, Oliver Dunk, Alex Moshchuk, Takashi Toyoshima, Chromium Metrics Reviews, Takashi Nakayama, Min Qin, Hiroki Nakagawa, James Maclean, James Su, AyeAye, Chromium LUCI CQ, chromium...@chromium.org, Nate Chapin, asvitkine...@chromium.org, devtools-re...@chromium.org, extension...@chromium.org, chromium-a...@chromium.org, mkwst+w...@chromium.org, horo+...@chromium.org, shimazu+se...@chromium.org, kinuko+ser...@chromium.org, servicewor...@chromium.org, antoniosarto...@chromium.org, kenjibah...@chromium.org, jsbell+ser...@chromium.org, arthursonzog...@chromium.org, blink-revie...@chromium.org, alexmo...@chromium.org, yhanad...@chromium.org, tranbaod...@chromium.org, nona+...@chromium.org, creis...@chromium.org, shuche...@chromium.org, jbauma...@chromium.org, navigation...@chromium.org, keithle...@chromium.org, blink-...@chromium.org, blundell+...@chromium.org, gavinp...@chromium.org, kinuko...@chromium.org, loading-re...@chromium.org, loading...@chromium.org, net-r...@chromium.org, network-ser...@chromium.org
    Attention needed from Adam Rice, Andrew Brown and Clark DuVall

    Adam Rice voted and added 6 comments

    Votes added by Adam Rice

    Commit-Queue+1

    6 comments

    File extensions/browser/api/web_request/web_request_proxying_url_loader_factory.h
    Line 218, Patchset 40 (Latest): net::HttpRequestHeaders user_visible_headers_;
    Adam Rice . unresolved

    How about `script_exposed_headers_` as an alternative name?

    Line 217, Patchset 40 (Latest): // that has to happen further down (after CORS checks).
    Adam Rice . unresolved

    I suggest "has to happen in the network service" would be clearer.

    File extensions/browser/api/web_request/web_request_proxying_url_loader_factory.cc
    Line 189, Patchset 40 (Latest): user_visible_headers_ = net::HttpUtil::MergeHeadersAndAddUserAgent(
    Adam Rice . unresolved

    I think this should go in the member initialiser section above. Also in the other constructor below.

    File net/http/http_util.cc
    Line 433, Patchset 40 (Latest): *(user_agent));
    Adam Rice . unresolved

    Nit: `()` around `user_agent` are not needed.

    File services/network/url_loader.cc
    Line 830, Patchset 40 (Latest): net::HttpRequestHeaders::kUserAgent, *(content_user_agent_));
    Adam Rice . unresolved

    Nit: `()` not needed around `content_user_agent_`.

    File third_party/blink/renderer/core/loader/frame_fetch_context_test.cc
    Line 1582, Patchset 40 (Latest): EXPECT_EQ(ukm::kInvalidSourceId, request.GetUkmSourceId());
    Adam Rice . unresolved

    Unfortunately `ukm::kInvalidSourceId` is the default value for this field, so it doesn't really prove that `PrepareRequest()` did anything.

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Adam Rice
    • Andrew Brown
    • Clark DuVall
    Submit Requirements:
    • requirement satisfiedCode-Coverage
    • requirement is not satisfiedCode-Owners
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: chromium/src
    Gerrit-Branch: main
    Gerrit-Change-Id: Icf56620f99f371ea2f128e6a3194d6096b0d62cd
    Gerrit-Change-Number: 5273743
    Gerrit-PatchSet: 40
    Gerrit-Owner: Andrew Brown <m...@ajbrown.au>
    Gerrit-Reviewer: Adam Rice <ri...@chromium.org>
    Gerrit-Reviewer: Alex Moshchuk <ale...@chromium.org>
    Gerrit-Reviewer: Andrew Brown <m...@ajbrown.au>
    Gerrit-Reviewer: Devlin Cronin <rdevlin...@chromium.org>
    Gerrit-Reviewer: Min Qin <qin...@chromium.org>
    Gerrit-Reviewer: Takashi Toyoshima <toyo...@chromium.org>
    Gerrit-CC: Chromium Metrics Reviews <chromium-met...@google.com>
    Gerrit-CC: Clark DuVall <cdu...@chromium.org>
    Gerrit-CC: Giovanni Ortuno Urquidi <ort...@chromium.org>
    Gerrit-CC: Hiroki Nakagawa <nhi...@chromium.org>
    Gerrit-CC: James Maclean <wjma...@chromium.org>
    Gerrit-CC: James Su <su...@chromium.org>
    Gerrit-CC: Nate Chapin <jap...@chromium.org>
    Gerrit-CC: Oliver Dunk <olive...@chromium.org>
    Gerrit-CC: Takashi Nakayama <tn...@chromium.org>
    Gerrit-Attention: Clark DuVall <cdu...@chromium.org>
    Gerrit-Attention: Adam Rice <ri...@chromium.org>
    Gerrit-Attention: Andrew Brown <m...@ajbrown.au>
    Gerrit-Comment-Date: Mon, 18 Aug 2025 20:48:57 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: Yes
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Andrew Brown (Gerrit)

    unread,
    Aug 21, 2025, 7:01:32 AMAug 21
    to Adam Rice, Clark DuVall, Devlin Cronin, Giovanni Ortuno Urquidi, Oliver Dunk, Alex Moshchuk, Takashi Toyoshima, Chromium Metrics Reviews, Takashi Nakayama, Min Qin, Hiroki Nakagawa, James Maclean, James Su, AyeAye, Chromium LUCI CQ, chromium...@chromium.org, Nate Chapin, asvitkine...@chromium.org, devtools-re...@chromium.org, extension...@chromium.org, chromium-a...@chromium.org, mkwst+w...@chromium.org, horo+...@chromium.org, shimazu+se...@chromium.org, kinuko+ser...@chromium.org, servicewor...@chromium.org, antoniosarto...@chromium.org, kenjibah...@chromium.org, jsbell+ser...@chromium.org, arthursonzog...@chromium.org, blink-revie...@chromium.org, alexmo...@chromium.org, yhanad...@chromium.org, tranbaod...@chromium.org, nona+...@chromium.org, creis...@chromium.org, shuche...@chromium.org, jbauma...@chromium.org, navigation...@chromium.org, keithle...@chromium.org, blink-...@chromium.org, blundell+...@chromium.org, gavinp...@chromium.org, kinuko...@chromium.org, loading-re...@chromium.org, loading...@chromium.org, net-r...@chromium.org, network-ser...@chromium.org
    Attention needed from Adam Rice and Clark DuVall

    Andrew Brown added 1 comment

    File third_party/blink/renderer/core/loader/frame_fetch_context_test.cc
    Line 1582, Patchset 40 (Latest): EXPECT_EQ(ukm::kInvalidSourceId, request.GetUkmSourceId());
    Adam Rice . unresolved

    Unfortunately `ukm::kInvalidSourceId` is the default value for this field, so it doesn't really prove that `PrepareRequest()` did anything.

    Andrew Brown

    Ah, so it is. I spotted in `t/b/r/core/testing/dummy_page_holder.cc:134` that the document source ID for these tests was initialised specifically as `kInvalidSourceId`, so I figured it would be a decent test example, but didn't check the ResourceRequest default.

    Would it be possible to add a quick constant to ukm, call it `ukm::kTestingSourceID`, that could be set at `dummy_page_holder.cc:134` and used for this test? I'm a little surprised there's not one already, but I guess it would be a bit niche.

    Otherwise the next option would be looking into `request.SetStorageApiAccess` in `FrameFetchContext::PrepareRequest` to see if it sets a value we can test.

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Adam Rice
    • Clark DuVall
    Gerrit-Comment-Date: Thu, 21 Aug 2025 11:00:57 +0000
    Gerrit-HasComments: Yes
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Adam Rice (Gerrit)

    unread,
    Aug 22, 2025, 5:04:30 PMAug 22
    to Andrew Brown, Clark DuVall, Devlin Cronin, Giovanni Ortuno Urquidi, Oliver Dunk, Alex Moshchuk, Takashi Toyoshima, Chromium Metrics Reviews, Takashi Nakayama, Min Qin, Hiroki Nakagawa, James Maclean, James Su, AyeAye, Chromium LUCI CQ, chromium...@chromium.org, Nate Chapin, asvitkine...@chromium.org, devtools-re...@chromium.org, extension...@chromium.org, chromium-a...@chromium.org, mkwst+w...@chromium.org, horo+...@chromium.org, shimazu+se...@chromium.org, kinuko+ser...@chromium.org, servicewor...@chromium.org, antoniosarto...@chromium.org, kenjibah...@chromium.org, jsbell+ser...@chromium.org, arthursonzog...@chromium.org, blink-revie...@chromium.org, alexmo...@chromium.org, yhanad...@chromium.org, tranbaod...@chromium.org, nona+...@chromium.org, creis...@chromium.org, shuche...@chromium.org, jbauma...@chromium.org, navigation...@chromium.org, keithle...@chromium.org, blink-...@chromium.org, blundell+...@chromium.org, gavinp...@chromium.org, kinuko...@chromium.org, loading-re...@chromium.org, loading...@chromium.org, net-r...@chromium.org, network-ser...@chromium.org
    Attention needed from Andrew Brown and Clark DuVall

    Adam Rice added 1 comment

    File third_party/blink/renderer/core/loader/frame_fetch_context_test.cc
    Line 1582, Patchset 40 (Latest): EXPECT_EQ(ukm::kInvalidSourceId, request.GetUkmSourceId());
    Adam Rice . unresolved

    Unfortunately `ukm::kInvalidSourceId` is the default value for this field, so it doesn't really prove that `PrepareRequest()` did anything.

    Andrew Brown

    Ah, so it is. I spotted in `t/b/r/core/testing/dummy_page_holder.cc:134` that the document source ID for these tests was initialised specifically as `kInvalidSourceId`, so I figured it would be a decent test example, but didn't check the ResourceRequest default.

    Would it be possible to add a quick constant to ukm, call it `ukm::kTestingSourceID`, that could be set at `dummy_page_holder.cc:134` and used for this test? I'm a little surprised there's not one already, but I guess it would be a bit niche.

    Otherwise the next option would be looking into `request.SetStorageApiAccess` in `FrameFetchContext::PrepareRequest` to see if it sets a value we can test.

    Adam Rice

    On further inspection, PrepareRequest() only does two things when detached, and the only one that has a side effect is setting the user agent. So there's nothing here we can test. I think we should just delete this "PrepareRequestWhenDetached" test because it isn't adding any value.

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Andrew Brown
    • Clark DuVall
    Gerrit-Attention: Andrew Brown <m...@ajbrown.au>
    Gerrit-Comment-Date: Fri, 22 Aug 2025 21:04:15 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    Comment-In-Reply-To: Adam Rice <ri...@chromium.org>
    Comment-In-Reply-To: Andrew Brown <m...@ajbrown.au>
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Andrew Brown (Gerrit)

    unread,
    Aug 22, 2025, 8:07:02 PMAug 22
    to Adam Rice, Clark DuVall, Devlin Cronin, Giovanni Ortuno Urquidi, Oliver Dunk, Alex Moshchuk, Takashi Toyoshima, Chromium Metrics Reviews, Takashi Nakayama, Min Qin, Hiroki Nakagawa, James Maclean, James Su, AyeAye, Chromium LUCI CQ, chromium...@chromium.org, Nate Chapin, asvitkine...@chromium.org, devtools-re...@chromium.org, extension...@chromium.org, chromium-a...@chromium.org, mkwst+w...@chromium.org, horo+...@chromium.org, shimazu+se...@chromium.org, kinuko+ser...@chromium.org, servicewor...@chromium.org, antoniosarto...@chromium.org, kenjibah...@chromium.org, jsbell+ser...@chromium.org, arthursonzog...@chromium.org, blink-revie...@chromium.org, alexmo...@chromium.org, yhanad...@chromium.org, tranbaod...@chromium.org, nona+...@chromium.org, creis...@chromium.org, shuche...@chromium.org, jbauma...@chromium.org, navigation...@chromium.org, keithle...@chromium.org, blink-...@chromium.org, blundell+...@chromium.org, gavinp...@chromium.org, kinuko...@chromium.org, loading-re...@chromium.org, loading...@chromium.org, net-r...@chromium.org, network-ser...@chromium.org
    Attention needed from Adam Rice and Clark DuVall

    Andrew Brown added 8 comments

    Patchset-level comments
    Devlin Cronin . unresolved

    Thanks, Andrew! Extensions LGTM % nit, since there's now no behavior change.

    Andrew Brown

    Unfortunately the current test results do make this seem like it's not yet fixed.

    The few failures I've actually drilled into are *all* requests that have gone through the extensions stack, now needing a specific `User-Agent` CORS preflight response.

    This means the User-Agent getting added onto the headers in the `OnBeforeSendHeaders` event is actually affecting the real network request somehow, causing it to spot a non-CORS-exempt header on the headers and send a preflight (which the tests don't correctly respond to).

    So all requests that go through the Extensions stack are generating a CORS preflight for the User-Agent header, which most things won't expect and respond to. We need to find an alternative approach; merging here isn't suitable.

    My first guess is that the associated callback function might be our solution, if it lets me pass the `content_user_agent` back up to the front-end consumer for merging outside of all of this business? I don't know if that's feasible/reasonable at all though, considering that goes back into the black hole of mojom; it looks like it would need a lot of modifications all over the place in unrelated contexts.

    Other than that... I'm not sure.

    Devlin Cronin

    Thanks for the continued investigation!

    Unfortunately, I'm not sure of what the right solution here is, either. Since this is mostly touching the net stack, I'd defer to one of those owners. @ri...@chromium.org?

    Adam Rice

    I misunderstood the code when I looked at it before. This is happening before we call `CreateLoaderAndStart()`, so any modifications to `request_` will affect the real request. So we can't modify `request_` here.

    What I propose instead is to create a new `headers_with_user_agent_` member variable in the `InProgressRequest` class, which is a copy of `request_.headers` but with the User-Agent header added. Then anywhere we are currently calling a WebRequestEventRouter with a pointer to `request_.headers`, pass a pointer to `headers_with_user_agent_` instead.

    Any code which modifies `request_.headers`, for example WebRequestProxyingURLLoaderFactory::InProgressRequest::FollowRedirect(), must recreate `headers_with_user_agent_` to make sure it remains correct. Possibly it will be sufficient to put that code in the UpdateRequestInfo() method?

    The extra cost of copying the headers on the request fast path bothers me, but I can't see any way around it.

    Andrew Brown

    I've implemented this (I think?) -- dryrun please.

    I've called it `user_visible_headers_` with the logic that they're the headers that get sent back up to the "user" (i.e. extensions). Terminology check would be appreciated.

    My first attempt (which is now uploaded) seemed to pass the tests that I ran locally, which scares me a little, but if it works it works.

    Having now written it, I definitely can see where you're not keen on the extra copy... it feels bad to be making the `user_visible_headers_` in the constructor and then completely remaking them again in `ContinueToBeforeSendHeaders`. There might be a way around it if we try to ensure that `user_visible_headers_` are updated wherever the `headers` change? But that seems like a lot of code complexity, so eh.

    Andrew Brown

    Continuing this discussion, I think we have further problems.

    The entire extensions stack seems to pass around the one headers object for all modifications, including the actual modifications that extensions could make (e.g. by DeclarativeNetRequest). So we have to somehow get these modifications back to the real request somehow (*without* passing the content_user_agent and triggering CORS).

    I can think of two ways forwards to try to maintain the existing behaviour:
    - Literally just check the value of the User-Agent header when the `proxying_url_loader` gets the headers back, and if it's an exact match for the `content_user_agent`, remove it.
    Problems: 1. we would actually have to check string equality for the header value, which has a bit of of a bad code smell, and 2. What happens in the pathological case where an extension manually sets the header to the same value?
    - Somehow special-case the User-Agent *inside* net::HttpRequestHeaders. Basically, store some sort of flag for "has the UA been modified," and only remove the UA if the headers object reports it as unchanged. (I attempted to originally do this by making an actual subclass of `net::HttpRequestHeaders` inside the `InProgressRequest` that had special user-agent-tracking behaviour. I was probably messing up the inheritance somehow but it didn't seem like a good solution.)
    Problems: modifying the actual `net::HttpRequestHeaders` for this seems like a bad idea.
    File extensions/browser/api/web_request/web_request_proxying_url_loader_factory.h
    Line 218, Patchset 40: net::HttpRequestHeaders user_visible_headers_;
    Adam Rice . resolved

    How about `script_exposed_headers_` as an alternative name?

    Andrew Brown

    Done

    Line 217, Patchset 40: // that has to happen further down (after CORS checks).
    Adam Rice . resolved

    I suggest "has to happen in the network service" would be clearer.

    Andrew Brown

    Done

    File extensions/browser/api/web_request/web_request_proxying_url_loader_factory.cc
    Line 189, Patchset 40: user_visible_headers_ = net::HttpUtil::MergeHeadersAndAddUserAgent(
    Adam Rice . resolved

    I think this should go in the member initialiser section above. Also in the other constructor below.

    Andrew Brown

    Done

    File net/http/http_util.cc
    Line 433, Patchset 40: *(user_agent));
    Adam Rice . resolved

    Nit: `()` around `user_agent` are not needed.

    Andrew Brown

    Done

    File services/network/url_loader.cc
    Line 830, Patchset 40: net::HttpRequestHeaders::kUserAgent, *(content_user_agent_));
    Adam Rice . resolved

    Nit: `()` not needed around `content_user_agent_`.

    Andrew Brown

    Done

    File third_party/blink/renderer/core/loader/frame_fetch_context_test.cc
    Line 1565, Patchset 25: EXPECT_EQ("hi", GetFetchContext()->GetDefaultUserAgent());
    Andrew Brown . resolved

    I would resurrect my comments from patchset 14, but they don't link through to the new code.

    Is this test sensible? I feel like it's not, because the name suggests to me that instead of checking UA the new way, we should instead be looking at whether PrepareRequest does it's job -- just using a different litmus test than User-Agent. Advice welcome.

    Adam Rice

    Looking at the original CL, there does seem to be a point to this:
    https://chromium-review.googlesource.com/c/chromium/src/+/518743

    Detaching the page causes the user agent string to be cached, and so the test is verifying that the code is doing this correctly.

    Maybe add some comments, but keep it the same? Or add another test that does actually call `PrepareRequest()` and verifies something else it is supposed to be doing?

    Andrew Brown

    I've added a new `PrepareRequestWhenDetached` that checks the UkmSourceID.

    I think that should be equivalent(?), as far as the old test was checking that you could call PrepareRequest while detached and it would still do some sort of stuff.

    Andrew Brown

    Done

    Line 1582, Patchset 40: EXPECT_EQ(ukm::kInvalidSourceId, request.GetUkmSourceId());
    Adam Rice . resolved

    Unfortunately `ukm::kInvalidSourceId` is the default value for this field, so it doesn't really prove that `PrepareRequest()` did anything.

    Andrew Brown

    Ah, so it is. I spotted in `t/b/r/core/testing/dummy_page_holder.cc:134` that the document source ID for these tests was initialised specifically as `kInvalidSourceId`, so I figured it would be a decent test example, but didn't check the ResourceRequest default.

    Would it be possible to add a quick constant to ukm, call it `ukm::kTestingSourceID`, that could be set at `dummy_page_holder.cc:134` and used for this test? I'm a little surprised there's not one already, but I guess it would be a bit niche.

    Otherwise the next option would be looking into `request.SetStorageApiAccess` in `FrameFetchContext::PrepareRequest` to see if it sets a value we can test.

    Adam Rice

    On further inspection, PrepareRequest() only does two things when detached, and the only one that has a side effect is setting the user agent. So there's nothing here we can test. I think we should just delete this "PrepareRequestWhenDetached" test because it isn't adding any value.

    Andrew Brown

    Alright, sweet.

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Adam Rice
    • Clark DuVall
    Submit Requirements:
    • requirement satisfiedCode-Coverage
    • requirement is not satisfiedCode-Owners
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: chromium/src
    Gerrit-Branch: main
    Gerrit-Change-Id: Icf56620f99f371ea2f128e6a3194d6096b0d62cd
    Gerrit-Change-Number: 5273743
    Gerrit-PatchSet: 41
    Gerrit-Owner: Andrew Brown <m...@ajbrown.au>
    Gerrit-Reviewer: Adam Rice <ri...@chromium.org>
    Gerrit-Reviewer: Alex Moshchuk <ale...@chromium.org>
    Gerrit-Reviewer: Andrew Brown <m...@ajbrown.au>
    Gerrit-Reviewer: Devlin Cronin <rdevlin...@chromium.org>
    Gerrit-Reviewer: Min Qin <qin...@chromium.org>
    Gerrit-Reviewer: Takashi Toyoshima <toyo...@chromium.org>
    Gerrit-CC: Chromium Metrics Reviews <chromium-met...@google.com>
    Gerrit-CC: Clark DuVall <cdu...@chromium.org>
    Gerrit-CC: Giovanni Ortuno Urquidi <ort...@chromium.org>
    Gerrit-CC: Hiroki Nakagawa <nhi...@chromium.org>
    Gerrit-CC: James Maclean <wjma...@chromium.org>
    Gerrit-CC: James Su <su...@chromium.org>
    Gerrit-CC: Nate Chapin <jap...@chromium.org>
    Gerrit-CC: Oliver Dunk <olive...@chromium.org>
    Gerrit-CC: Takashi Nakayama <tn...@chromium.org>
    Gerrit-Attention: Clark DuVall <cdu...@chromium.org>
    Gerrit-Attention: Adam Rice <ri...@chromium.org>
    Gerrit-Comment-Date: Sat, 23 Aug 2025 00:06:26 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    Comment-In-Reply-To: Adam Rice <ri...@chromium.org>
    Comment-In-Reply-To: Andrew Brown <m...@ajbrown.au>
    Comment-In-Reply-To: Devlin Cronin <rdevlin...@chromium.org>
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Adam Rice (Gerrit)

    unread,
    Aug 26, 2025, 4:36:39 AMAug 26
    to Andrew Brown, Giovanni Ortuno Urquidi, Clark DuVall, Devlin Cronin, Oliver Dunk, Alex Moshchuk, Takashi Toyoshima, Chromium Metrics Reviews, Takashi Nakayama, Min Qin, Hiroki Nakagawa, James Maclean, James Su, AyeAye, Chromium LUCI CQ, chromium...@chromium.org, Nate Chapin, asvitkine...@chromium.org, devtools-re...@chromium.org, extension...@chromium.org, chromium-a...@chromium.org, mkwst+w...@chromium.org, horo+...@chromium.org, shimazu+se...@chromium.org, kinuko+ser...@chromium.org, servicewor...@chromium.org, antoniosarto...@chromium.org, kenjibah...@chromium.org, jsbell+ser...@chromium.org, arthursonzog...@chromium.org, blink-revie...@chromium.org, alexmo...@chromium.org, yhanad...@chromium.org, tranbaod...@chromium.org, nona+...@chromium.org, creis...@chromium.org, shuche...@chromium.org, jbauma...@chromium.org, navigation...@chromium.org, keithle...@chromium.org, blink-...@chromium.org, blundell+...@chromium.org, gavinp...@chromium.org, kinuko...@chromium.org, loading-re...@chromium.org, loading...@chromium.org, net-r...@chromium.org, network-ser...@chromium.org
    Attention needed from Andrew Brown, Clark DuVall and Giovanni Ortuno Urquidi

    Adam Rice added 1 comment

    Patchset-level comments
    Adam Rice

    You are right, I hadn't thought it through properly.

    I think we should take your first option. We don't really have an accurate way to detect "has been set by extension JavaScript" anyway, so however we do it we end up relying on a string comparison.

    There's actually already a horrible function called CalculateOnBeforeSendHeadersDelta() that does pretty much what we need, and MergeOnBeforeSendHeadersResponses() to merge back the results. I think instead of MergeOnBeforeSendHeadersResponses() taking one pointer to a `net::HttpRequestHeaders` object, it will have to take two, one for the real request headers that don't include `User-Agent`, and one for the internal version that does. Then it should just apply exactly the same changes to both. This means the cost when nothing is actually modified will be small.

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Andrew Brown
    • Clark DuVall
    • Giovanni Ortuno Urquidi
    Gerrit-Attention: Giovanni Ortuno Urquidi <ort...@chromium.org>
    Gerrit-Attention: Andrew Brown <m...@ajbrown.au>
    Gerrit-Comment-Date: Tue, 26 Aug 2025 08:36:13 +0000
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Andrew Brown (Gerrit)

    unread,
    Sep 5, 2025, 10:26:26 PMSep 5
    to Giovanni Ortuno Urquidi, Adam Rice, Clark DuVall, Devlin Cronin, Oliver Dunk, Alex Moshchuk, Takashi Toyoshima, Chromium Metrics Reviews, Takashi Nakayama, Min Qin, Hiroki Nakagawa, James Maclean, James Su, AyeAye, Chromium LUCI CQ, chromium...@chromium.org, Nate Chapin, asvitkine...@chromium.org, devtools-re...@chromium.org, extension...@chromium.org, chromium-a...@chromium.org, mkwst+w...@chromium.org, horo+...@chromium.org, shimazu+se...@chromium.org, kinuko+ser...@chromium.org, servicewor...@chromium.org, antoniosarto...@chromium.org, kenjibah...@chromium.org, jsbell+ser...@chromium.org, arthursonzog...@chromium.org, blink-revie...@chromium.org, alexmo...@chromium.org, yhanad...@chromium.org, tranbaod...@chromium.org, nona+...@chromium.org, creis...@chromium.org, shuche...@chromium.org, jbauma...@chromium.org, navigation...@chromium.org, keithle...@chromium.org, blink-...@chromium.org, blundell+...@chromium.org, gavinp...@chromium.org, kinuko...@chromium.org, loading-re...@chromium.org, loading...@chromium.org, net-r...@chromium.org, network-ser...@chromium.org
    Attention needed from Adam Rice and Clark DuVall

    Andrew Brown added 1 comment

    Patchset-level comments
    Andrew Brown

    Ok, sort of "option 1.5" -- actually passing *both* headers objects through everywhere, but then whenever we display to the user, take the `script_exposed_headers`, and whenever we modify, modify both. That sounds like it should definitely work.

    I'm not confident this is fully implemented yet; I'm almost certain there will be more to it, but I've been losing momentum in trying to understand the weeds of the extensions code, so in the interest of keeping things moving, here's a new patchset for dry-running. Thanks :)

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Adam Rice
    • Clark DuVall
    Submit Requirements:
    • requirement satisfiedCode-Coverage
    • requirement is not satisfiedCode-Owners
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: chromium/src
    Gerrit-Branch: main
    Gerrit-Change-Id: Icf56620f99f371ea2f128e6a3194d6096b0d62cd
    Gerrit-Change-Number: 5273743
    Gerrit-PatchSet: 42
    Gerrit-Owner: Andrew Brown <m...@ajbrown.au>
    Gerrit-Reviewer: Adam Rice <ri...@chromium.org>
    Gerrit-Reviewer: Alex Moshchuk <ale...@chromium.org>
    Gerrit-Reviewer: Andrew Brown <m...@ajbrown.au>
    Gerrit-Reviewer: Devlin Cronin <rdevlin...@chromium.org>
    Gerrit-Reviewer: Min Qin <qin...@chromium.org>
    Gerrit-Reviewer: Takashi Toyoshima <toyo...@chromium.org>
    Gerrit-CC: Chromium Metrics Reviews <chromium-met...@google.com>
    Gerrit-CC: Clark DuVall <cdu...@chromium.org>
    Gerrit-CC: Giovanni Ortuno Urquidi <ort...@chromium.org>
    Gerrit-CC: Hiroki Nakagawa <nhi...@chromium.org>
    Gerrit-CC: James Maclean <wjma...@chromium.org>
    Gerrit-CC: James Su <su...@chromium.org>
    Gerrit-CC: Nate Chapin <jap...@chromium.org>
    Gerrit-CC: Oliver Dunk <olive...@chromium.org>
    Gerrit-CC: Takashi Nakayama <tn...@chromium.org>
    Gerrit-Attention: Clark DuVall <cdu...@chromium.org>
    Gerrit-Attention: Adam Rice <ri...@chromium.org>
    Gerrit-Comment-Date: Sat, 06 Sep 2025 02:26:13 +0000
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Andrew Brown (Gerrit)

    unread,
    Sep 17, 2025, 1:57:26 AMSep 17
    to Adam Rice, Giovanni Ortuno Urquidi, Clark DuVall, Devlin Cronin, Oliver Dunk, Alex Moshchuk, Takashi Toyoshima, Chromium Metrics Reviews, Takashi Nakayama, Min Qin, Hiroki Nakagawa, James Maclean, James Su, AyeAye, Chromium LUCI CQ, chromium...@chromium.org, Nate Chapin, asvitkine...@chromium.org, devtools-re...@chromium.org, extension...@chromium.org, chromium-a...@chromium.org, mkwst+w...@chromium.org, horo+...@chromium.org, shimazu+se...@chromium.org, kinuko+ser...@chromium.org, servicewor...@chromium.org, antoniosarto...@chromium.org, kenjibah...@chromium.org, jsbell+ser...@chromium.org, arthursonzog...@chromium.org, blink-revie...@chromium.org, alexmo...@chromium.org, yhanad...@chromium.org, tranbaod...@chromium.org, nona+...@chromium.org, creis...@chromium.org, shuche...@chromium.org, jbauma...@chromium.org, navigation...@chromium.org, keithle...@chromium.org, blink-...@chromium.org, blundell+...@chromium.org, gavinp...@chromium.org, kinuko...@chromium.org, loading-re...@chromium.org, loading...@chromium.org, net-r...@chromium.org, network-ser...@chromium.org
    Patchset-level comments
    Andrew Brown

    Another dry-run please :)

    I think I sort of understand what's happening now between the factory and the router; I've undone the changes I made around the `WebRequestInfo.extra_request_headers` and I think I'm now passing everything around correctly. There might be some exceptional behaviour around the handling of `nullptr` in a few of the functions that's worth commenting? Thoughts welcome.

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Adam Rice
    • Clark DuVall
    Submit Requirements:
    • requirement satisfiedCode-Coverage
    • requirement is not satisfiedCode-Owners
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: chromium/src
    Gerrit-Branch: main
    Gerrit-Change-Id: Icf56620f99f371ea2f128e6a3194d6096b0d62cd
    Gerrit-Change-Number: 5273743
    Gerrit-PatchSet: 44
    Gerrit-Owner: Andrew Brown <m...@ajbrown.au>
    Gerrit-Reviewer: Adam Rice <ri...@chromium.org>
    Gerrit-Reviewer: Alex Moshchuk <ale...@chromium.org>
    Gerrit-Reviewer: Andrew Brown <m...@ajbrown.au>
    Gerrit-Reviewer: Devlin Cronin <rdevlin...@chromium.org>
    Gerrit-Reviewer: Min Qin <qin...@chromium.org>
    Gerrit-Reviewer: Takashi Toyoshima <toyo...@chromium.org>
    Gerrit-CC: Chromium Metrics Reviews <chromium-met...@google.com>
    Gerrit-CC: Clark DuVall <cdu...@chromium.org>
    Gerrit-CC: Giovanni Ortuno Urquidi <ort...@chromium.org>
    Gerrit-CC: Hiroki Nakagawa <nhi...@chromium.org>
    Gerrit-CC: James Maclean <wjma...@chromium.org>
    Gerrit-CC: James Su <su...@chromium.org>
    Gerrit-CC: Nate Chapin <jap...@chromium.org>
    Gerrit-CC: Oliver Dunk <olive...@chromium.org>
    Gerrit-CC: Takashi Nakayama <tn...@chromium.org>
    Gerrit-Attention: Clark DuVall <cdu...@chromium.org>
    Gerrit-Attention: Adam Rice <ri...@chromium.org>
    Gerrit-Comment-Date: Wed, 17 Sep 2025 05:56:54 +0000
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Andrew Brown (Gerrit)

    unread,
    Sep 17, 2025, 6:26:53 PMSep 17
    to Giovanni Ortuno Urquidi, Adam Rice, Clark DuVall, Devlin Cronin, Oliver Dunk, Alex Moshchuk, Takashi Toyoshima, Chromium Metrics Reviews, Takashi Nakayama, Min Qin, Hiroki Nakagawa, James Maclean, James Su, AyeAye, Chromium LUCI CQ, chromium...@chromium.org, Nate Chapin, asvitkine...@chromium.org, devtools-re...@chromium.org, extension...@chromium.org, chromium-a...@chromium.org, mkwst+w...@chromium.org, horo+...@chromium.org, shimazu+se...@chromium.org, kinuko+ser...@chromium.org, servicewor...@chromium.org, antoniosarto...@chromium.org, kenjibah...@chromium.org, jsbell+ser...@chromium.org, arthursonzog...@chromium.org, blink-revie...@chromium.org, alexmo...@chromium.org, yhanad...@chromium.org, tranbaod...@chromium.org, nona+...@chromium.org, creis...@chromium.org, shuche...@chromium.org, jbauma...@chromium.org, navigation...@chromium.org, keithle...@chromium.org, blink-...@chromium.org, blundell+...@chromium.org, gavinp...@chromium.org, kinuko...@chromium.org, loading-re...@chromium.org, loading...@chromium.org, net-r...@chromium.org, network-ser...@chromium.org
    Attention needed from Adam Rice and Takashi Toyoshima

    Andrew Brown added 2 comments

    Patchset-level comments
    File-level comment, Patchset 35:
    Devlin Cronin . resolved
    Andrew Brown

    Done!

    File-level comment, Patchset 44 (Latest):
    Andrew Brown . unresolved

    Well, I guess now I need +1's from all the different owners -- re-pinged Takashi, as I feel like yourself and Adam should be the first eyes over it, given this is a primarily network-focused change.

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Adam Rice
    • Takashi Toyoshima
    Gerrit-Attention: Takashi Toyoshima <toyo...@chromium.org>
    Gerrit-Attention: Adam Rice <ri...@chromium.org>
    Gerrit-Comment-Date: Wed, 17 Sep 2025 22:26:17 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    Comment-In-Reply-To: Devlin Cronin <rdevlin...@chromium.org>
    Comment-In-Reply-To: Andrew Brown <m...@ajbrown.au>
    Comment-In-Reply-To: Adam Rice <ri...@chromium.org>
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Andrew Brown (Gerrit)

    unread,
    Sep 25, 2025, 1:18:25 AMSep 25
    to Giovanni Ortuno Urquidi, Adam Rice, Clark DuVall, Devlin Cronin, Oliver Dunk, Alex Moshchuk, Takashi Toyoshima, Chromium Metrics Reviews, Takashi Nakayama, Min Qin, Hiroki Nakagawa, James Maclean, James Su, AyeAye, Chromium LUCI CQ, chromium...@chromium.org, Nate Chapin, asvitkine...@chromium.org, devtools-re...@chromium.org, extension...@chromium.org, chromium-a...@chromium.org, mkwst+w...@chromium.org, horo+...@chromium.org, shimazu+se...@chromium.org, kinuko+ser...@chromium.org, servicewor...@chromium.org, antoniosarto...@chromium.org, kenjibah...@chromium.org, jsbell+ser...@chromium.org, arthursonzog...@chromium.org, blink-revie...@chromium.org, alexmo...@chromium.org, yhanad...@chromium.org, tranbaod...@chromium.org, nona+...@chromium.org, creis...@chromium.org, shuche...@chromium.org, jbauma...@chromium.org, navigation...@chromium.org, keithle...@chromium.org, blink-...@chromium.org, blundell+...@chromium.org, gavinp...@chromium.org, kinuko...@chromium.org, loading-re...@chromium.org, loading...@chromium.org, net-r...@chromium.org, network-ser...@chromium.org
    Attention needed from Adam Rice and Takashi Toyoshima

    Andrew Brown added 1 comment

    Patchset-level comments
    Andrew Brown . unresolved

    Well, I guess now I need +1's from all the different owners -- re-pinged Takashi, as I feel like yourself and Adam should be the first eyes over it, given this is a primarily network-focused change.

    Andrew Brown

    Sorry to be a pest, but re-pinging, as it's been a week.

    I will need reviews from both of you as Network People, eventually, in order to cover all the files (plus this is a complex & large change that can't hurt to have more eyes) so please dw about duplicate reviews. (quoting the "contributing to chromium" guide)

    Gerrit-Comment-Date: Thu, 25 Sep 2025 05:18:13 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    Comment-In-Reply-To: Andrew Brown <m...@ajbrown.au>
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Adam Rice (Gerrit)

    unread,
    Sep 25, 2025, 7:05:32 AMSep 25
    to Andrew Brown, Giovanni Ortuno Urquidi, Clark DuVall, Devlin Cronin, Oliver Dunk, Alex Moshchuk, Takashi Toyoshima, Chromium Metrics Reviews, Takashi Nakayama, Min Qin, Hiroki Nakagawa, James Maclean, James Su, AyeAye, Chromium LUCI CQ, chromium...@chromium.org, Nate Chapin, asvitkine...@chromium.org, devtools-re...@chromium.org, extension...@chromium.org, chromium-a...@chromium.org, mkwst+w...@chromium.org, horo+...@chromium.org, shimazu+se...@chromium.org, kinuko+ser...@chromium.org, servicewor...@chromium.org, antoniosarto...@chromium.org, kenjibah...@chromium.org, jsbell+ser...@chromium.org, arthursonzog...@chromium.org, blink-revie...@chromium.org, alexmo...@chromium.org, yhanad...@chromium.org, tranbaod...@chromium.org, nona+...@chromium.org, creis...@chromium.org, shuche...@chromium.org, jbauma...@chromium.org, navigation...@chromium.org, keithle...@chromium.org, blink-...@chromium.org, blundell+...@chromium.org, gavinp...@chromium.org, kinuko...@chromium.org, loading-re...@chromium.org, loading...@chromium.org, net-r...@chromium.org, network-ser...@chromium.org
    Attention needed from Andrew Brown and Takashi Toyoshima

    Adam Rice voted and added 4 comments

    Votes added by Adam Rice

    Code-Review+1

    4 comments

    Patchset-level comments
    Adam Rice . resolved

    lgtm, thank you for all your hard work on this.

    File net/http/http_util.h
    Line 130, Patchset 44 (Latest): net::HttpRequestHeaders original,
    Adam Rice . unresolved

    Nit: `net::` prefix should not be used inside the `net` namespace.

    Line 23, Patchset 44 (Latest):#include "net/http/http_request_headers.h"
    Adam Rice . unresolved

    Nit: you could just predeclare `class HttpRequestHeaders;` as with `HttpResponseHeaders` below, as the compiler doesn't need to know the size of `HttpRequestHeaders` to compile this file. Only worth fixing if you're doing another upload anyway.

    File net/http/http_util.cc
    Line 425, Patchset 44 (Latest):net::HttpRequestHeaders HttpUtil::MergeHeadersAndAddUserAgent(
    Adam Rice . unresolved

    As in the header file, `net::` not needed.

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Andrew Brown
    • Takashi Toyoshima
    Gerrit-Attention: Andrew Brown <m...@ajbrown.au>
    Gerrit-Comment-Date: Thu, 25 Sep 2025 11:05:21 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: Yes
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Andrew Brown (Gerrit)

    unread,
    Sep 26, 2025, 1:52:54 AMSep 26
    to Adam Rice, Giovanni Ortuno Urquidi, Clark DuVall, Devlin Cronin, Oliver Dunk, Alex Moshchuk, Takashi Toyoshima, Chromium Metrics Reviews, Takashi Nakayama, Min Qin, Hiroki Nakagawa, James Maclean, James Su, AyeAye, Chromium LUCI CQ, chromium...@chromium.org, Nate Chapin, asvitkine...@chromium.org, devtools-re...@chromium.org, extension...@chromium.org, chromium-a...@chromium.org, mkwst+w...@chromium.org, horo+...@chromium.org, shimazu+se...@chromium.org, kinuko+ser...@chromium.org, servicewor...@chromium.org, antoniosarto...@chromium.org, kenjibah...@chromium.org, jsbell+ser...@chromium.org, arthursonzog...@chromium.org, blink-revie...@chromium.org, alexmo...@chromium.org, yhanad...@chromium.org, tranbaod...@chromium.org, nona+...@chromium.org, creis...@chromium.org, shuche...@chromium.org, jbauma...@chromium.org, navigation...@chromium.org, keithle...@chromium.org, blink-...@chromium.org, blundell+...@chromium.org, gavinp...@chromium.org, kinuko...@chromium.org, loading-re...@chromium.org, loading...@chromium.org, net-r...@chromium.org, network-ser...@chromium.org
    Attention needed from Adam Rice and Takashi Toyoshima

    Andrew Brown added 5 comments

    Patchset-level comments
    Adam Rice . resolved

    lgtm, thank you for all your hard work on this.

    Andrew Brown

    Thanks in return to you too -- I couldn't have done it without your support.

    File net/http/http_util.h
    Line 130, Patchset 44: net::HttpRequestHeaders original,
    Adam Rice . resolved

    Nit: `net::` prefix should not be used inside the `net` namespace.

    Andrew Brown

    Done

    Line 23, Patchset 44:#include "net/http/http_request_headers.h"
    Adam Rice . resolved

    Nit: you could just predeclare `class HttpRequestHeaders;` as with `HttpResponseHeaders` below, as the compiler doesn't need to know the size of `HttpRequestHeaders` to compile this file. Only worth fixing if you're doing another upload anyway.

    Andrew Brown

    I'm already not keeping the CL dryrun around (24hrs is long passed), and it's old enough to be worth rebasing, and it's an easy fix, so I'll just do it.

    File net/http/http_util.cc
    Line 425, Patchset 44:net::HttpRequestHeaders HttpUtil::MergeHeadersAndAddUserAgent(
    Adam Rice . resolved

    As in the header file, `net::` not needed.

    Andrew Brown

    Done

    File services/network/cors/preflight_controller.cc
    Line 216, Patchset 26: // we can't use cors_exempt_headers, so the User-Agent will appear here
    Takashi Toyoshima . resolved
    Andrew Brown

    Done

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Adam Rice
    • Takashi Toyoshima
    Submit Requirements:
    • requirement satisfiedCode-Coverage
    • requirement is not satisfiedCode-Owners
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: chromium/src
    Gerrit-Branch: main
    Gerrit-Change-Id: Icf56620f99f371ea2f128e6a3194d6096b0d62cd
    Gerrit-Change-Number: 5273743
    Gerrit-PatchSet: 45
    Gerrit-Owner: Andrew Brown <m...@ajbrown.au>
    Gerrit-Reviewer: Adam Rice <ri...@chromium.org>
    Gerrit-Reviewer: Alex Moshchuk <ale...@chromium.org>
    Gerrit-Reviewer: Andrew Brown <m...@ajbrown.au>
    Gerrit-Reviewer: Devlin Cronin <rdevlin...@chromium.org>
    Gerrit-Reviewer: Min Qin <qin...@chromium.org>
    Gerrit-Reviewer: Takashi Toyoshima <toyo...@chromium.org>
    Gerrit-CC: Chromium Metrics Reviews <chromium-met...@google.com>
    Gerrit-CC: Clark DuVall <cdu...@chromium.org>
    Gerrit-CC: Giovanni Ortuno Urquidi <ort...@chromium.org>
    Gerrit-CC: Hiroki Nakagawa <nhi...@chromium.org>
    Gerrit-CC: James Maclean <wjma...@chromium.org>
    Gerrit-CC: James Su <su...@chromium.org>
    Gerrit-CC: Nate Chapin <jap...@chromium.org>
    Gerrit-CC: Oliver Dunk <olive...@chromium.org>
    Gerrit-CC: Takashi Nakayama <tn...@chromium.org>
    Gerrit-Attention: Takashi Toyoshima <toyo...@chromium.org>
    Gerrit-Attention: Adam Rice <ri...@chromium.org>
    Gerrit-Comment-Date: Fri, 26 Sep 2025 05:52:43 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    Comment-In-Reply-To: Takashi Toyoshima <toyo...@chromium.org>
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Andrew Brown (Gerrit)

    unread,
    Sep 28, 2025, 10:31:33 PMSep 28
    to Giovanni Ortuno Urquidi, Adam Rice, Clark DuVall, Devlin Cronin, Oliver Dunk, Alex Moshchuk, Takashi Toyoshima, Chromium Metrics Reviews, Takashi Nakayama, Min Qin, Hiroki Nakagawa, James Maclean, James Su, AyeAye, Chromium LUCI CQ, chromium...@chromium.org, Nate Chapin, asvitkine...@chromium.org, devtools-re...@chromium.org, extension...@chromium.org, chromium-a...@chromium.org, mkwst+w...@chromium.org, horo+...@chromium.org, shimazu+se...@chromium.org, kinuko+ser...@chromium.org, servicewor...@chromium.org, antoniosarto...@chromium.org, kenjibah...@chromium.org, jsbell+ser...@chromium.org, arthursonzog...@chromium.org, blink-revie...@chromium.org, alexmo...@chromium.org, yhanad...@chromium.org, tranbaod...@chromium.org, nona+...@chromium.org, creis...@chromium.org, shuche...@chromium.org, jbauma...@chromium.org, navigation...@chromium.org, keithle...@chromium.org, blink-...@chromium.org, blundell+...@chromium.org, gavinp...@chromium.org, kinuko...@chromium.org, loading-re...@chromium.org, loading...@chromium.org, net-r...@chromium.org, network-ser...@chromium.org
    Attention needed from Adam Rice, Giovanni Ortuno Urquidi and Takashi Toyoshima

    Andrew Brown added 2 comments

    Patchset-level comments
    File-level comment, Patchset 46 (Latest):
    Andrew Brown . unresolved

    I'm not suuuuper sure what's up with the ios-simulator test stuff? I don't recognise any of the calls in the stack trace (i.e. it shouldn't go anywhere near this CL, let alone the actual changes between patchset 44 and 45) and the test title implies it's a potentially flaky test. Do we just re-run and hope it works?

    File net/http/http_util.h
    Line 23, Patchset 44:#include "net/http/http_request_headers.h"
    Adam Rice . resolved

    Nit: you could just predeclare `class HttpRequestHeaders;` as with `HttpResponseHeaders` below, as the compiler doesn't need to know the size of `HttpRequestHeaders` to compile this file. Only worth fixing if you're doing another upload anyway.

    Andrew Brown

    I'm already not keeping the CL dryrun around (24hrs is long passed), and it's old enough to be worth rebasing, and it's an easy fix, so I'll just do it.

    Andrew Brown

    Hm, I think I misunderstood what you meant by this. Re-done, still works, but had to slightly fiddle the includes on the net unittests as well.

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Adam Rice
    • Giovanni Ortuno Urquidi
    • Takashi Toyoshima
    Submit Requirements:
    • requirement satisfiedCode-Coverage
    • requirement is not satisfiedCode-Owners
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: chromium/src
    Gerrit-Branch: main
    Gerrit-Change-Id: Icf56620f99f371ea2f128e6a3194d6096b0d62cd
    Gerrit-Change-Number: 5273743
    Gerrit-PatchSet: 46
    Gerrit-Owner: Andrew Brown <m...@ajbrown.au>
    Gerrit-Reviewer: Adam Rice <ri...@chromium.org>
    Gerrit-Reviewer: Alex Moshchuk <ale...@chromium.org>
    Gerrit-Reviewer: Andrew Brown <m...@ajbrown.au>
    Gerrit-Reviewer: Devlin Cronin <rdevlin...@chromium.org>
    Gerrit-Reviewer: Min Qin <qin...@chromium.org>
    Gerrit-Reviewer: Takashi Toyoshima <toyo...@chromium.org>
    Gerrit-CC: Chromium Metrics Reviews <chromium-met...@google.com>
    Gerrit-CC: Clark DuVall <cdu...@chromium.org>
    Gerrit-CC: Giovanni Ortuno Urquidi <ort...@chromium.org>
    Gerrit-CC: Hiroki Nakagawa <nhi...@chromium.org>
    Gerrit-CC: James Maclean <wjma...@chromium.org>
    Gerrit-CC: James Su <su...@chromium.org>
    Gerrit-CC: Nate Chapin <jap...@chromium.org>
    Gerrit-CC: Oliver Dunk <olive...@chromium.org>
    Gerrit-CC: Takashi Nakayama <tn...@chromium.org>
    Gerrit-Attention: Takashi Toyoshima <toyo...@chromium.org>
    Gerrit-Attention: Giovanni Ortuno Urquidi <ort...@chromium.org>
    Gerrit-Attention: Adam Rice <ri...@chromium.org>
    Gerrit-Comment-Date: Mon, 29 Sep 2025 02:31:21 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Adam Rice (Gerrit)

    unread,
    Sep 29, 2025, 8:32:56 AMSep 29
    to Andrew Brown, Giovanni Ortuno Urquidi, Clark DuVall, Devlin Cronin, Oliver Dunk, Alex Moshchuk, Takashi Toyoshima, Chromium Metrics Reviews, Takashi Nakayama, Min Qin, Hiroki Nakagawa, James Maclean, James Su, AyeAye, Chromium LUCI CQ, chromium...@chromium.org, Nate Chapin, asvitkine...@chromium.org, devtools-re...@chromium.org, extension...@chromium.org, chromium-a...@chromium.org, mkwst+w...@chromium.org, horo+...@chromium.org, shimazu+se...@chromium.org, kinuko+ser...@chromium.org, servicewor...@chromium.org, antoniosarto...@chromium.org, kenjibah...@chromium.org, jsbell+ser...@chromium.org, arthursonzog...@chromium.org, blink-revie...@chromium.org, alexmo...@chromium.org, yhanad...@chromium.org, tranbaod...@chromium.org, nona+...@chromium.org, creis...@chromium.org, shuche...@chromium.org, jbauma...@chromium.org, navigation...@chromium.org, keithle...@chromium.org, blink-...@chromium.org, blundell+...@chromium.org, gavinp...@chromium.org, kinuko...@chromium.org, loading-re...@chromium.org, loading...@chromium.org, net-r...@chromium.org, network-ser...@chromium.org
    Attention needed from Andrew Brown, Giovanni Ortuno Urquidi and Takashi Toyoshima

    Adam Rice added 1 comment

    Patchset-level comments
    Andrew Brown . resolved

    I'm not suuuuper sure what's up with the ios-simulator test stuff? I don't recognise any of the calls in the stack trace (i.e. it shouldn't go anywhere near this CL, let alone the actual changes between patchset 44 and 45) and the test title implies it's a potentially flaky test. Do we just re-run and hope it works?

    Adam Rice

    Yes. If a failure seems unrelated, most of the time it is just a flaky test.

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Andrew Brown
    Gerrit-Attention: Andrew Brown <m...@ajbrown.au>
    Gerrit-Attention: Giovanni Ortuno Urquidi <ort...@chromium.org>
    Gerrit-Comment-Date: Mon, 29 Sep 2025 12:32:45 +0000
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Adam Rice (Gerrit)

    unread,
    Sep 29, 2025, 8:36:46 AMSep 29
    to Andrew Brown, Giovanni Ortuno Urquidi, Clark DuVall, Devlin Cronin, Oliver Dunk, Alex Moshchuk, Takashi Toyoshima, Chromium Metrics Reviews, Takashi Nakayama, Min Qin, Hiroki Nakagawa, James Maclean, James Su, AyeAye, Chromium LUCI CQ, chromium...@chromium.org, Nate Chapin, asvitkine...@chromium.org, devtools-re...@chromium.org, extension...@chromium.org, chromium-a...@chromium.org, mkwst+w...@chromium.org, horo+...@chromium.org, shimazu+se...@chromium.org, kinuko+ser...@chromium.org, servicewor...@chromium.org, antoniosarto...@chromium.org, kenjibah...@chromium.org, jsbell+ser...@chromium.org, arthursonzog...@chromium.org, blink-revie...@chromium.org, alexmo...@chromium.org, yhanad...@chromium.org, tranbaod...@chromium.org, nona+...@chromium.org, creis...@chromium.org, shuche...@chromium.org, jbauma...@chromium.org, navigation...@chromium.org, keithle...@chromium.org, blink-...@chromium.org, blundell+...@chromium.org, gavinp...@chromium.org, kinuko...@chromium.org, loading-re...@chromium.org, loading...@chromium.org, net-r...@chromium.org, network-ser...@chromium.org
    Attention needed from Andrew Brown, Giovanni Ortuno Urquidi and Takashi Toyoshima

    Adam Rice voted Code-Review+1

    Code-Review+1
    Gerrit-Comment-Date: Mon, 29 Sep 2025 12:36:34 +0000
    Gerrit-HasComments: No
    Gerrit-Has-Labels: Yes
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Takashi Toyoshima (Gerrit)

    unread,
    Oct 3, 2025, 3:52:44 AMOct 3
    to Andrew Brown, Adam Rice, Giovanni Ortuno Urquidi, Clark DuVall, Devlin Cronin, Oliver Dunk, Alex Moshchuk, Chromium Metrics Reviews, Takashi Nakayama, Min Qin, Hiroki Nakagawa, James Maclean, James Su, AyeAye, Chromium LUCI CQ, chromium...@chromium.org, Nate Chapin, asvitkine...@chromium.org, devtools-re...@chromium.org, extension...@chromium.org, chromium-a...@chromium.org, mkwst+w...@chromium.org, horo+...@chromium.org, shimazu+se...@chromium.org, kinuko+ser...@chromium.org, servicewor...@chromium.org, antoniosarto...@chromium.org, kenjibah...@chromium.org, jsbell+ser...@chromium.org, arthursonzog...@chromium.org, blink-revie...@chromium.org, alexmo...@chromium.org, yhanad...@chromium.org, tranbaod...@chromium.org, nona+...@chromium.org, creis...@chromium.org, shuche...@chromium.org, jbauma...@chromium.org, navigation...@chromium.org, keithle...@chromium.org, blink-...@chromium.org, blundell+...@chromium.org, gavinp...@chromium.org, kinuko...@chromium.org, loading-re...@chromium.org, loading...@chromium.org, net-r...@chromium.org, network-ser...@chromium.org
    Attention needed from Andrew Brown

    Takashi Toyoshima voted and added 1 comment

    Votes added by Takashi Toyoshima

    Code-Review+1

    1 comment

    Patchset-level comments
    File-level comment, Patchset 44:
    Andrew Brown . resolved

    Well, I guess now I need +1's from all the different owners -- re-pinged Takashi, as I feel like yourself and Adam should be the first eyes over it, given this is a primarily network-focused change.

    Andrew Brown

    Sorry to be a pest, but re-pinging, as it's been a week.

    I will need reviews from both of you as Network People, eventually, in order to cover all the files (plus this is a complex & large change that can't hurt to have more eyes) so please dw about duplicate reviews. (quoting the "contributing to chromium" guide)

    Takashi Toyoshima

    Sorry for overlooking this pings. It still LGTM.

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Andrew Brown
    Submit Requirements:
      • requirement satisfiedCode-Coverage
      • requirement is not satisfiedCode-Owners
      • requirement satisfiedCode-Review
      • requirement satisfiedReview-Enforcement
      Gerrit-Attention: Andrew Brown <m...@ajbrown.au>
      Gerrit-Comment-Date: Fri, 03 Oct 2025 07:52:20 +0000
      Gerrit-HasComments: Yes
      Gerrit-Has-Labels: Yes
      Comment-In-Reply-To: Andrew Brown <m...@ajbrown.au>
      satisfied_requirement
      unsatisfied_requirement
      open
      diffy

      Takashi Toyoshima (Gerrit)

      unread,
      Oct 3, 2025, 3:56:23 AMOct 3
      to Andrew Brown, Adam Rice, Giovanni Ortuno Urquidi, Clark DuVall, Devlin Cronin, Oliver Dunk, Alex Moshchuk, Chromium Metrics Reviews, Takashi Nakayama, Min Qin, Hiroki Nakagawa, James Maclean, James Su, AyeAye, Chromium LUCI CQ, chromium...@chromium.org, Nate Chapin, asvitkine...@chromium.org, devtools-re...@chromium.org, extension...@chromium.org, chromium-a...@chromium.org, mkwst+w...@chromium.org, horo+...@chromium.org, shimazu+se...@chromium.org, kinuko+ser...@chromium.org, servicewor...@chromium.org, antoniosarto...@chromium.org, kenjibah...@chromium.org, jsbell+ser...@chromium.org, arthursonzog...@chromium.org, blink-revie...@chromium.org, alexmo...@chromium.org, yhanad...@chromium.org, tranbaod...@chromium.org, nona+...@chromium.org, creis...@chromium.org, shuche...@chromium.org, jbauma...@chromium.org, navigation...@chromium.org, keithle...@chromium.org, blink-...@chromium.org, blundell+...@chromium.org, gavinp...@chromium.org, kinuko...@chromium.org, loading-re...@chromium.org, loading...@chromium.org, net-r...@chromium.org, network-ser...@chromium.org
      Attention needed from Andrew Brown

      Takashi Toyoshima added 1 comment

      Patchset-level comments
      File-level comment, Patchset 44:
      Andrew Brown . unresolved

      Well, I guess now I need +1's from all the different owners -- re-pinged Takashi, as I feel like yourself and Adam should be the first eyes over it, given this is a primarily network-focused change.

      Andrew Brown

      Sorry to be a pest, but re-pinging, as it's been a week.

      I will need reviews from both of you as Network People, eventually, in order to cover all the files (plus this is a complex & large change that can't hurt to have more eyes) so please dw about duplicate reviews. (quoting the "contributing to chromium" guide)

      Takashi Toyoshima

      Sorry for overlooking this pings. It still LGTM.

      Takashi Toyoshima

      By the way, I think you still need a reviewer's approval on Extensions related directory.

      Open in Gerrit

      Related details

      Attention is currently required from:
      • Andrew Brown
      Submit Requirements:
        • requirement satisfiedCode-Coverage
        • requirement is not satisfiedCode-Owners
        • requirement satisfiedCode-Review
        • requirement is not satisfiedNo-Unresolved-Comments
        • requirement satisfiedReview-Enforcement
        Gerrit-Comment-Date: Fri, 03 Oct 2025 07:55:59 +0000
        Gerrit-HasComments: Yes
        Gerrit-Has-Labels: No
        satisfied_requirement
        unsatisfied_requirement
        open
        diffy

        Andrew Brown (Gerrit)

        unread,
        Oct 3, 2025, 11:47:16 PMOct 3
        to Takashi Toyoshima, Adam Rice, Giovanni Ortuno Urquidi, Clark DuVall, Devlin Cronin, Oliver Dunk, Alex Moshchuk, Chromium Metrics Reviews, Takashi Nakayama, Min Qin, Hiroki Nakagawa, James Maclean, James Su, AyeAye, Chromium LUCI CQ, chromium...@chromium.org, Nate Chapin, asvitkine...@chromium.org, devtools-re...@chromium.org, extension...@chromium.org, chromium-a...@chromium.org, mkwst+w...@chromium.org, horo+...@chromium.org, shimazu+se...@chromium.org, kinuko+ser...@chromium.org, servicewor...@chromium.org, antoniosarto...@chromium.org, kenjibah...@chromium.org, jsbell+ser...@chromium.org, arthursonzog...@chromium.org, blink-revie...@chromium.org, alexmo...@chromium.org, yhanad...@chromium.org, tranbaod...@chromium.org, nona+...@chromium.org, creis...@chromium.org, shuche...@chromium.org, jbauma...@chromium.org, navigation...@chromium.org, keithle...@chromium.org, blink-...@chromium.org, blundell+...@chromium.org, gavinp...@chromium.org, kinuko...@chromium.org, loading-re...@chromium.org, loading...@chromium.org, net-r...@chromium.org, network-ser...@chromium.org
        Attention needed from Alex Moshchuk and Devlin Cronin

        Andrew Brown added 2 comments

        Patchset-level comments
        Andrew Brown . unresolved

        Well, I guess now I need +1's from all the different owners -- re-pinged Takashi, as I feel like yourself and Adam should be the first eyes over it, given this is a primarily network-focused change.

        Andrew Brown

        Sorry to be a pest, but re-pinging, as it's been a week.

        I will need reviews from both of you as Network People, eventually, in order to cover all the files (plus this is a complex & large change that can't hurt to have more eyes) so please dw about duplicate reviews. (quoting the "contributing to chromium" guide)

        Takashi Toyoshima

        Sorry for overlooking this pings. It still LGTM.

        Takashi Toyoshima

        By the way, I think you still need a reviewer's approval on Extensions related directory.

        Andrew Brown

        All good, appreciate the vote :)

        Pinging Devlin now for extensions approval -- happy to go bother others if there's specific internal complexity to be looked at (there is a bit of weird stuff in there), but there's no visible API change for extensions anymore.

        Andrew Brown . unresolved

        Figure I might as well also ping Alex for owner review on content/public/test/url_loader_interceptor.cc to round it all off.

        Open in Gerrit

        Related details

        Attention is currently required from:
        • Alex Moshchuk
        • Devlin Cronin
        Gerrit-Attention: Devlin Cronin <rdevlin...@chromium.org>
        Gerrit-Attention: Alex Moshchuk <ale...@chromium.org>
        Gerrit-Comment-Date: Sat, 04 Oct 2025 03:46:37 +0000
        satisfied_requirement
        unsatisfied_requirement
        open
        diffy

        Alex Moshchuk (Gerrit)

        unread,
        Oct 6, 2025, 6:35:36 PMOct 6
        to Andrew Brown, Takashi Toyoshima, Adam Rice, Giovanni Ortuno Urquidi, Clark DuVall, Devlin Cronin, Oliver Dunk, Chromium Metrics Reviews, Takashi Nakayama, Min Qin, Hiroki Nakagawa, James Maclean, James Su, AyeAye, Chromium LUCI CQ, chromium...@chromium.org, Nate Chapin, asvitkine...@chromium.org, devtools-re...@chromium.org, extension...@chromium.org, chromium-a...@chromium.org, mkwst+w...@chromium.org, horo+...@chromium.org, shimazu+se...@chromium.org, kinuko+ser...@chromium.org, servicewor...@chromium.org, antoniosarto...@chromium.org, kenjibah...@chromium.org, jsbell+ser...@chromium.org, arthursonzog...@chromium.org, blink-revie...@chromium.org, alexmo...@chromium.org, yhanad...@chromium.org, tranbaod...@chromium.org, nona+...@chromium.org, creis...@chromium.org, shuche...@chromium.org, jbauma...@chromium.org, navigation...@chromium.org, keithle...@chromium.org, blink-...@chromium.org, blundell+...@chromium.org, gavinp...@chromium.org, kinuko...@chromium.org, loading-re...@chromium.org, loading...@chromium.org, net-r...@chromium.org, network-ser...@chromium.org
        Attention needed from Andrew Brown and Devlin Cronin

        Alex Moshchuk voted and added 1 comment

        Votes added by Alex Moshchuk

        Code-Review+1

        1 comment

        Patchset-level comments
        Andrew Brown . resolved

        Figure I might as well also ping Alex for owner review on content/public/test/url_loader_interceptor.cc to round it all off.

        Alex Moshchuk

        That file LGTM

        Open in Gerrit

        Related details

        Attention is currently required from:
        • Andrew Brown
        • Devlin Cronin
        Gerrit-Attention: Andrew Brown <m...@ajbrown.au>
        Gerrit-Comment-Date: Mon, 06 Oct 2025 22:35:09 +0000
        satisfied_requirement
        unsatisfied_requirement
        open
        diffy

        Devlin Cronin (Gerrit)

        unread,
        Oct 6, 2025, 8:12:44 PMOct 6
        to Andrew Brown, Kelvin Jiang, Alex Moshchuk, Takashi Toyoshima, Adam Rice, Giovanni Ortuno Urquidi, Clark DuVall, Devlin Cronin, Oliver Dunk, Chromium Metrics Reviews, Takashi Nakayama, Min Qin, Hiroki Nakagawa, James Maclean, James Su, AyeAye, Chromium LUCI CQ, chromium...@chromium.org, Nate Chapin, asvitkine...@chromium.org, devtools-re...@chromium.org, extension...@chromium.org, chromium-a...@chromium.org, mkwst+w...@chromium.org, horo+...@chromium.org, shimazu+se...@chromium.org, kinuko+ser...@chromium.org, servicewor...@chromium.org, antoniosarto...@chromium.org, kenjibah...@chromium.org, jsbell+ser...@chromium.org, arthursonzog...@chromium.org, blink-revie...@chromium.org, alexmo...@chromium.org, yhanad...@chromium.org, tranbaod...@chromium.org, nona+...@chromium.org, creis...@chromium.org, shuche...@chromium.org, jbauma...@chromium.org, navigation...@chromium.org, keithle...@chromium.org, blink-...@chromium.org, blundell+...@chromium.org, gavinp...@chromium.org, kinuko...@chromium.org, loading-re...@chromium.org, loading...@chromium.org, net-r...@chromium.org, network-ser...@chromium.org
        Attention needed from Andrew Brown and Kelvin Jiang

        Devlin Cronin added 2 comments

        Patchset-level comments
        Andrew Brown . unresolved

        Well, I guess now I need +1's from all the different owners -- re-pinged Takashi, as I feel like yourself and Adam should be the first eyes over it, given this is a primarily network-focused change.

        Andrew Brown

        Sorry to be a pest, but re-pinging, as it's been a week.

        I will need reviews from both of you as Network People, eventually, in order to cover all the files (plus this is a complex & large change that can't hurt to have more eyes) so please dw about duplicate reviews. (quoting the "contributing to chromium" guide)

        Takashi Toyoshima

        Sorry for overlooking this pings. It still LGTM.

        Takashi Toyoshima

        By the way, I think you still need a reviewer's approval on Extensions related directory.

        Andrew Brown

        All good, appreciate the vote :)

        Pinging Devlin now for extensions approval -- happy to go bother others if there's specific internal complexity to be looked at (there is a bit of weird stuff in there), but there's no visible API change for extensions anymore.

        Devlin Cronin

        Thanks, Andrew! If there's no API change, I'm okay with this at a high level (though see the one comment I added). I've added @kelvi...@chromium.org for a more thorough review, as an owner of the webRequest API.

        File chrome/browser/extensions/api/downloads/downloads_api_browsertest.cc
        Line 2049, Patchset 46 (Parent): "usER-agENt",
        Devlin Cronin . unresolved

        If there's no visible API change for extensions, is this change still needed?

        Open in Gerrit

        Related details

        Attention is currently required from:
        • Andrew Brown
        • Kelvin Jiang
        Submit Requirements:
        • requirement satisfiedCode-Coverage
        • requirement is not satisfiedCode-Owners
        • requirement satisfiedCode-Review
        • requirement is not satisfiedNo-Unresolved-Comments
        • requirement satisfiedReview-Enforcement
        Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
        Gerrit-MessageType: comment
        Gerrit-Project: chromium/src
        Gerrit-Branch: main
        Gerrit-Change-Id: Icf56620f99f371ea2f128e6a3194d6096b0d62cd
        Gerrit-Change-Number: 5273743
        Gerrit-PatchSet: 46
        Gerrit-Owner: Andrew Brown <m...@ajbrown.au>
        Gerrit-Reviewer: Adam Rice <ri...@chromium.org>
        Gerrit-Reviewer: Alex Moshchuk <ale...@chromium.org>
        Gerrit-Reviewer: Andrew Brown <m...@ajbrown.au>
        Gerrit-Reviewer: Devlin Cronin <rdevlin...@chromium.org>
        Gerrit-Reviewer: Kelvin Jiang <kelvi...@chromium.org>
        Gerrit-Reviewer: Min Qin <qin...@chromium.org>
        Gerrit-Reviewer: Takashi Toyoshima <toyo...@chromium.org>
        Gerrit-CC: Chromium Metrics Reviews <chromium-met...@google.com>
        Gerrit-CC: Clark DuVall <cdu...@chromium.org>
        Gerrit-CC: Giovanni Ortuno Urquidi <ort...@chromium.org>
        Gerrit-CC: Hiroki Nakagawa <nhi...@chromium.org>
        Gerrit-CC: James Maclean <wjma...@chromium.org>
        Gerrit-CC: James Su <su...@chromium.org>
        Gerrit-CC: Nate Chapin <jap...@chromium.org>
        Gerrit-CC: Oliver Dunk <olive...@chromium.org>
        Gerrit-CC: Takashi Nakayama <tn...@chromium.org>
        Gerrit-Attention: Kelvin Jiang <kelvi...@chromium.org>
        Gerrit-Attention: Andrew Brown <m...@ajbrown.au>
        Gerrit-Comment-Date: Tue, 07 Oct 2025 00:12:29 +0000
        satisfied_requirement
        unsatisfied_requirement
        open
        diffy

        Andrew Brown (Gerrit)

        unread,
        Oct 6, 2025, 8:48:59 PMOct 6
        to Kelvin Jiang, Alex Moshchuk, Takashi Toyoshima, Adam Rice, Giovanni Ortuno Urquidi, Clark DuVall, Devlin Cronin, Oliver Dunk, Chromium Metrics Reviews, Takashi Nakayama, Min Qin, Hiroki Nakagawa, James Maclean, James Su, AyeAye, Chromium LUCI CQ, chromium...@chromium.org, Nate Chapin, asvitkine...@chromium.org, devtools-re...@chromium.org, extension...@chromium.org, chromium-a...@chromium.org, mkwst+w...@chromium.org, horo+...@chromium.org, shimazu+se...@chromium.org, kinuko+ser...@chromium.org, servicewor...@chromium.org, antoniosarto...@chromium.org, kenjibah...@chromium.org, jsbell+ser...@chromium.org, arthursonzog...@chromium.org, blink-revie...@chromium.org, alexmo...@chromium.org, yhanad...@chromium.org, tranbaod...@chromium.org, nona+...@chromium.org, creis...@chromium.org, shuche...@chromium.org, jbauma...@chromium.org, navigation...@chromium.org, keithle...@chromium.org, blink-...@chromium.org, blundell+...@chromium.org, gavinp...@chromium.org, kinuko...@chromium.org, loading-re...@chromium.org, loading...@chromium.org, net-r...@chromium.org, network-ser...@chromium.org
        Attention needed from Devlin Cronin and Kelvin Jiang

        Andrew Brown added 1 comment

        File chrome/browser/extensions/api/downloads/downloads_api_browsertest.cc
        Devlin Cronin . unresolved

        If there's no visible API change for extensions, is this change still needed?

        Andrew Brown

        Hm, true, I guess there technically still is a "visible API change" here, but that's because chromium currently doesn't follow the fetch spec w/r/t User-Agent.

        The extensions Downloads API docs say that additional headers can be provided for the request if XMLHttpRequest allows it. Until now, XMLHttpRequest couldn't set User-Agents, but that's the core bug we're fixing. Technically I guess we're not actually changing the documented behaviour, because the docs rely on XMLHttpRequest, and we're just changing that.

        Do we need an announcement/chromestatus.com entry/whatever for this change, then? I'm not super familiar with the actual "release process" for how this code change actually ships, so there might be steps there that I'm missing.

        Open in Gerrit

        Related details

        Attention is currently required from:
        • Devlin Cronin
        • Kelvin Jiang
        Gerrit-Attention: Devlin Cronin <rdevlin...@chromium.org>
        Gerrit-Attention: Kelvin Jiang <kelvi...@chromium.org>
        Gerrit-Comment-Date: Tue, 07 Oct 2025 00:47:19 +0000
        Gerrit-HasComments: Yes
        Gerrit-Has-Labels: No
        Comment-In-Reply-To: Devlin Cronin <rdevlin...@chromium.org>
        satisfied_requirement
        unsatisfied_requirement
        open
        diffy

        Devlin Cronin (Gerrit)

        unread,
        Oct 7, 2025, 7:22:15 PMOct 7
        to Andrew Brown, Oliver Dunk, Kelvin Jiang, Alex Moshchuk, Takashi Toyoshima, Adam Rice, Giovanni Ortuno Urquidi, Clark DuVall, Devlin Cronin, Chromium Metrics Reviews, Takashi Nakayama, Min Qin, Hiroki Nakagawa, James Maclean, James Su, AyeAye, Chromium LUCI CQ, chromium...@chromium.org, Nate Chapin, asvitkine...@chromium.org, devtools-re...@chromium.org, extension...@chromium.org, chromium-a...@chromium.org, mkwst+w...@chromium.org, horo+...@chromium.org, shimazu+se...@chromium.org, kinuko+ser...@chromium.org, servicewor...@chromium.org, antoniosarto...@chromium.org, kenjibah...@chromium.org, jsbell+ser...@chromium.org, arthursonzog...@chromium.org, blink-revie...@chromium.org, alexmo...@chromium.org, yhanad...@chromium.org, tranbaod...@chromium.org, nona+...@chromium.org, creis...@chromium.org, shuche...@chromium.org, jbauma...@chromium.org, navigation...@chromium.org, keithle...@chromium.org, blink-...@chromium.org, blundell+...@chromium.org, gavinp...@chromium.org, kinuko...@chromium.org, loading-re...@chromium.org, loading...@chromium.org, net-r...@chromium.org, network-ser...@chromium.org
        Attention needed from Andrew Brown, Kelvin Jiang and Oliver Dunk

        Devlin Cronin added 1 comment

        File chrome/browser/extensions/api/downloads/downloads_api_browsertest.cc
        Devlin Cronin . unresolved

        If there's no visible API change for extensions, is this change still needed?

        Andrew Brown

        Hm, true, I guess there technically still is a "visible API change" here, but that's because chromium currently doesn't follow the fetch spec w/r/t User-Agent.

        The extensions Downloads API docs say that additional headers can be provided for the request if XMLHttpRequest allows it. Until now, XMLHttpRequest couldn't set User-Agents, but that's the core bug we're fixing. Technically I guess we're not actually changing the documented behaviour, because the docs rely on XMLHttpRequest, and we're just changing that.

        Do we need an announcement/chromestatus.com entry/whatever for this change, then? I'm not super familiar with the actual "release process" for how this code change actually ships, so there might be steps there that I'm missing.

        Devlin Cronin

        I think I'm okay with this, but I'll defer to @olive...@chromium.org on if he thinks this needs a separate announcement or discussion in the WECG.

        Open in Gerrit

        Related details

        Attention is currently required from:
        • Andrew Brown
        • Kelvin Jiang
        • Oliver Dunk
        Submit Requirements:
        • requirement satisfiedCode-Coverage
        • requirement is not satisfiedCode-Owners
        • requirement satisfiedCode-Review
        • requirement is not satisfiedNo-Unresolved-Comments
        • requirement satisfiedReview-Enforcement
        Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
        Gerrit-MessageType: comment
        Gerrit-Project: chromium/src
        Gerrit-Branch: main
        Gerrit-Change-Id: Icf56620f99f371ea2f128e6a3194d6096b0d62cd
        Gerrit-Change-Number: 5273743
        Gerrit-PatchSet: 46
        Gerrit-Owner: Andrew Brown <m...@ajbrown.au>
        Gerrit-Reviewer: Adam Rice <ri...@chromium.org>
        Gerrit-Reviewer: Alex Moshchuk <ale...@chromium.org>
        Gerrit-Reviewer: Andrew Brown <m...@ajbrown.au>
        Gerrit-Reviewer: Devlin Cronin <rdevlin...@chromium.org>
        Gerrit-Reviewer: Kelvin Jiang <kelvi...@chromium.org>
        Gerrit-Reviewer: Min Qin <qin...@chromium.org>
        Gerrit-Reviewer: Oliver Dunk <olive...@chromium.org>
        Gerrit-Reviewer: Takashi Toyoshima <toyo...@chromium.org>
        Gerrit-CC: Chromium Metrics Reviews <chromium-met...@google.com>
        Gerrit-CC: Clark DuVall <cdu...@chromium.org>
        Gerrit-CC: Giovanni Ortuno Urquidi <ort...@chromium.org>
        Gerrit-CC: Hiroki Nakagawa <nhi...@chromium.org>
        Gerrit-CC: James Maclean <wjma...@chromium.org>
        Gerrit-CC: James Su <su...@chromium.org>
        Gerrit-CC: Nate Chapin <jap...@chromium.org>
        Gerrit-CC: Takashi Nakayama <tn...@chromium.org>
        Gerrit-Attention: Kelvin Jiang <kelvi...@chromium.org>
        Gerrit-Attention: Andrew Brown <m...@ajbrown.au>
        Gerrit-Attention: Oliver Dunk <olive...@chromium.org>
        Gerrit-Comment-Date: Tue, 07 Oct 2025 23:21:44 +0000
        Gerrit-HasComments: Yes
        Gerrit-Has-Labels: No
        Comment-In-Reply-To: Devlin Cronin <rdevlin...@chromium.org>
        Comment-In-Reply-To: Andrew Brown <m...@ajbrown.au>
        satisfied_requirement
        unsatisfied_requirement
        open
        diffy

        Kelvin Jiang (Gerrit)

        unread,
        Oct 10, 2025, 6:12:35 PMOct 10
        to Andrew Brown, Oliver Dunk, Alex Moshchuk, Takashi Toyoshima, Adam Rice, Giovanni Ortuno Urquidi, Clark DuVall, Devlin Cronin, Chromium Metrics Reviews, Takashi Nakayama, Min Qin, Hiroki Nakagawa, James Maclean, James Su, AyeAye, Chromium LUCI CQ, chromium...@chromium.org, Nate Chapin, asvitkine...@chromium.org, devtools-re...@chromium.org, extension...@chromium.org, chromium-a...@chromium.org, mkwst+w...@chromium.org, horo+...@chromium.org, shimazu+se...@chromium.org, kinuko+ser...@chromium.org, servicewor...@chromium.org, antoniosarto...@chromium.org, kenjibah...@chromium.org, jsbell+ser...@chromium.org, arthursonzog...@chromium.org, blink-revie...@chromium.org, alexmo...@chromium.org, yhanad...@chromium.org, tranbaod...@chromium.org, nona+...@chromium.org, creis...@chromium.org, shuche...@chromium.org, jbauma...@chromium.org, navigation...@chromium.org, keithle...@chromium.org, blink-...@chromium.org, blundell+...@chromium.org, gavinp...@chromium.org, kinuko...@chromium.org, loading-re...@chromium.org, loading...@chromium.org, net-r...@chromium.org, network-ser...@chromium.org
        Attention needed from Andrew Brown and Oliver Dunk

        Kelvin Jiang added 1 comment

        Patchset-level comments
        File-level comment, Patchset 46 (Latest):
        Kelvin Jiang . resolved

        Will finish reviewing today, sorry for the delay

        Open in Gerrit

        Related details

        Attention is currently required from:
        • Andrew Brown
        • Oliver Dunk
        Gerrit-Attention: Andrew Brown <m...@ajbrown.au>
        Gerrit-Attention: Oliver Dunk <olive...@chromium.org>
        Gerrit-Comment-Date: Fri, 10 Oct 2025 22:12:01 +0000
        Gerrit-HasComments: Yes
        Gerrit-Has-Labels: No
        satisfied_requirement
        unsatisfied_requirement
        open
        diffy

        Kelvin Jiang (Gerrit)

        unread,
        Oct 10, 2025, 8:12:18 PMOct 10
        to Andrew Brown, Oliver Dunk, Alex Moshchuk, Takashi Toyoshima, Adam Rice, Giovanni Ortuno Urquidi, Clark DuVall, Devlin Cronin, Chromium Metrics Reviews, Takashi Nakayama, Min Qin, Hiroki Nakagawa, James Maclean, James Su, AyeAye, Chromium LUCI CQ, chromium...@chromium.org, Nate Chapin, asvitkine...@chromium.org, devtools-re...@chromium.org, extension...@chromium.org, chromium-a...@chromium.org, mkwst+w...@chromium.org, horo+...@chromium.org, shimazu+se...@chromium.org, kinuko+ser...@chromium.org, servicewor...@chromium.org, antoniosarto...@chromium.org, kenjibah...@chromium.org, jsbell+ser...@chromium.org, arthursonzog...@chromium.org, blink-revie...@chromium.org, alexmo...@chromium.org, yhanad...@chromium.org, tranbaod...@chromium.org, nona+...@chromium.org, creis...@chromium.org, shuche...@chromium.org, jbauma...@chromium.org, navigation...@chromium.org, keithle...@chromium.org, blink-...@chromium.org, blundell+...@chromium.org, gavinp...@chromium.org, kinuko...@chromium.org, loading-re...@chromium.org, loading...@chromium.org, net-r...@chromium.org, network-ser...@chromium.org
        Attention needed from Andrew Brown and Oliver Dunk

        Kelvin Jiang added 13 comments

        Patchset-level comments
        Kelvin Jiang . unresolved

        I have a lot of questions and I might ask more in another pass:

        With respect to extensions that can modify network requests, what happens here?

        1. Before the request is sent, compute the value of `content_user_agent` which will be added to headers later?
        2. Request headers are set, and modifications from extensions are made?
        3. CORS checks happen but don't merge headers yet because `content_user_agent` is exempt?
        4. Now merge `content_user_agent` into headers?

        File extensions/browser/api/web_request/extension_web_request_event_router.h
        Line 192, Patchset 46 (Latest): net::HttpRequestHeaders* exposed_headers);
        Kelvin Jiang . unresolved

        nit: this is "script_exposed_headers" in the .cc file, why the "script_" part? and can we add a comment here describing what it is?

        File extensions/browser/api/web_request/extension_web_request_event_router.cc
        Line 592, Patchset 46 (Latest): // User-Agent.
        Kelvin Jiang . unresolved

        by this you mean the CORS exempt user agent that should be merged into request headers later?

        Line 1113, Patchset 46 (Latest): // Report the script_exposed_headers if given
        Kelvin Jiang . resolved

        style nit: period at end of comments, and that comments start with a capital letter.

        File extensions/browser/api/web_request/web_request_api_helpers.h
        Line 445, Patchset 46 (Latest):// Modifies the headers in `request_headers` according to `deltas`. Conflicts
        Kelvin Jiang . unresolved

        nit: "Modifies the headers in `request_headers` and `script_exposed_request_headers` according to `deltas`.

        File extensions/browser/api/web_request/web_request_api_helpers.cc
        Line 439, Patchset 46 (Latest): // |script_exposed_headers| may have a (User-Agent) header when
        Kelvin Jiang . unresolved

        nit: backticks around variable names instead of pipes. I also think this comment is better added before the function name in web_request_api_helpers.h as an example of why we use `script_exposed_headers` in addition to `request_headers` ?

        Line 1155, Patchset 46 (Latest): // Parse old cookie line. Use request_headers for simplicity as
        // script_exposed_headers should never differ on cookies.
        Kelvin Jiang . unresolved

        nit: if you want to guarantee this, add a DCHECK

        File extensions/browser/api/web_request/web_request_proxying_url_loader_factory.h
        Line 220, Patchset 46 (Latest): // that has to happen in the network stack (after CORS checks).
        Kelvin Jiang . unresolved

        dumb question: merging before would fail CORS checks?

        File extensions/browser/api/web_request/web_request_proxying_url_loader_factory.cc
        Line 157, Patchset 46 (Latest): request_.headers,
        Kelvin Jiang . unresolved

        nit: just use `request` instead of `request_` here. No difference in functionality but it reads a bit cleaner

        Line 774, Patchset 46 (Latest): // We have to reconstruct the script_exposed_headers_ here in case something
        Kelvin Jiang . unresolved

        style nit: surround variable names in backticks if you can, or pipes to be consistent with the rest of the file

        Line 775, Patchset 46 (Latest): // has changed
        Kelvin Jiang . unresolved

        This implies that one of the `request_`'s headers, cors_exempt_headers or content_user_agent has changed? I'm curious where this could happen between when we first initialize script_exposed_headers_ and now.

        File extensions/browser/api/web_request/web_request_proxying_websocket.cc
        Line 360, Patchset 46 (Latest): &request_headers_, nullptr);
        Kelvin Jiang . unresolved

        just curious: why is it "safe" to pass in null here?

        File extensions/browser/api/web_request/web_request_proxying_webtransport.cc
        Line 111, Patchset 46 (Latest): &request_headers_, nullptr);
        Kelvin Jiang . unresolved

        here too

        Gerrit-Comment-Date: Sat, 11 Oct 2025 00:11:43 +0000
        Gerrit-HasComments: Yes
        Gerrit-Has-Labels: No
        satisfied_requirement
        unsatisfied_requirement
        open
        diffy

        Andrew Brown (Gerrit)

        unread,
        Oct 10, 2025, 9:15:20 PMOct 10
        to Oliver Dunk, Kelvin Jiang, Alex Moshchuk, Takashi Toyoshima, Adam Rice, Giovanni Ortuno Urquidi, Clark DuVall, Devlin Cronin, Chromium Metrics Reviews, Takashi Nakayama, Min Qin, Hiroki Nakagawa, James Maclean, James Su, AyeAye, Chromium LUCI CQ, chromium...@chromium.org, Nate Chapin, asvitkine...@chromium.org, devtools-re...@chromium.org, extension...@chromium.org, chromium-a...@chromium.org, mkwst+w...@chromium.org, horo+...@chromium.org, shimazu+se...@chromium.org, kinuko+ser...@chromium.org, servicewor...@chromium.org, antoniosarto...@chromium.org, kenjibah...@chromium.org, jsbell+ser...@chromium.org, arthursonzog...@chromium.org, blink-revie...@chromium.org, alexmo...@chromium.org, yhanad...@chromium.org, tranbaod...@chromium.org, nona+...@chromium.org, creis...@chromium.org, shuche...@chromium.org, jbauma...@chromium.org, navigation...@chromium.org, keithle...@chromium.org, blink-...@chromium.org, blundell+...@chromium.org, gavinp...@chromium.org, kinuko...@chromium.org, loading-re...@chromium.org, loading...@chromium.org, net-r...@chromium.org, network-ser...@chromium.org
        Attention needed from Kelvin Jiang and Oliver Dunk

        Andrew Brown added 13 comments

        Patchset-level comments
        Kelvin Jiang . unresolved

        I have a lot of questions and I might ask more in another pass:

        With respect to extensions that can modify network requests, what happens here?

        1. Before the request is sent, compute the value of `content_user_agent` which will be added to headers later?
        2. Request headers are set, and modifications from extensions are made?
        3. CORS checks happen but don't merge headers yet because `content_user_agent` is exempt?
        4. Now merge `content_user_agent` into headers?

        Andrew Brown

        No worries, thanks for your review! Happy to answer questions, fire away. This might be too granular of a breakdown, or there might be more aspects to ask about, but this is how I'm conceptualising what happens:

        1. Start with a `network::ResourceRequest` with `headers`, `cors_exempt_headers`, and `content_user_agent` which comes from DevTools or FetchContext. (All three of these must be kept separate until after CORS checks.)
        2. Extensions code receives this request.
        3. Extensions code has to invent the `script_exposed_headers`, which is the headers that will be *really* sent on this request, after CORS. This has to be a separate object because again we can't merge them all into the `headers` until after CORS.
        4. Extensions code tells a running extension that the `script_exposed_headers` are the headers for "this request", so the extension sees the "real" final state of the request headers, including `content_user_agent`.
        5. All extensions modifications are applied to *both* the real `headers` and the user-visible `script_exposed_headers`. This keeps the `script_exposed_headers` that the user can see in-sync with the real `headers` but enables us to make sure they stay separate.
        6. After all extensions have done modifications/looked at things/etc, toss away the `script_exposed_headers`. We go back to having a `network::ResourceRequest` with `headers`, `cors_exempt_headers`, and `content_user_agent`, all separate, but with all the extensions modifications applied to `headers` as requested.
        7. CORS checks happen on `headers`. A CORS preflight may be sent for User-Agent here if the request has a User-Agent specified on the `headers`, as it must have come from an untrusted source.
        8. After CORS, if the preflight said it's fine, then we can use the `headers` User-Agent. If it's not fine, or if there wasn't one, we can merge the `content_user_agent` onto the headers to actually make the request.

        File extensions/browser/api/web_request/extension_web_request_event_router.h
        Line 192, Patchset 46 (Latest): net::HttpRequestHeaders* exposed_headers);
        Kelvin Jiang . unresolved

        nit: this is "script_exposed_headers" in the .cc file, why the "script_" part? and can we add a comment here describing what it is?

        Andrew Brown

        `script_exposed` vs `exposed` are basically arbitrary names. My original name was `user_visible_headers` but it's not clear who the *user* is (is it the extensions code, or page JS code, or the person sitting at the computer, or what), so I changed it.

        As long as we all think the name indicates "headers that the extension will see", that's the goal. Possibly switch to use `exposed_headers` everywhere?

        File extensions/browser/api/web_request/extension_web_request_event_router.cc
        Kelvin Jiang . unresolved

        by this you mean the CORS exempt user agent that should be merged into request headers later?

        Andrew Brown

        If the headers already have a User-Agent it will be that, e.g. if this request comes from someone doing `fetch('foo.com' {headers: {"User-Agent": "baz"}});`, then the exposed_headers will have "User-Agent: baz". The content_user_agent shouldn't override any other User-Agent.

        So it's not guaranteed that these headers have the CORS exempt User-Agent, just that they have *a* User-Agent.

        Line 1113, Patchset 46 (Latest): // Report the script_exposed_headers if given
        Kelvin Jiang . unresolved

        style nit: period at end of comments, and that comments start with a capital letter.

        Andrew Brown

        Fixed nit locally, will upload once other comments are also resolved (e.g. "script_exposed_headers" vs "exposed_headers" name)

        File extensions/browser/api/web_request/web_request_api_helpers.h
        Line 445, Patchset 46 (Latest):// Modifies the headers in `request_headers` according to `deltas`. Conflicts
        Kelvin Jiang . unresolved

        nit: "Modifies the headers in `request_headers` and `script_exposed_request_headers` according to `deltas`.

        Andrew Brown

        Fixed nit locally, will upload once other comments are also resolved (e.g. "script_exposed_headers" vs "exposed_headers" name)

        File extensions/browser/api/web_request/web_request_api_helpers.cc
        Line 439, Patchset 46 (Latest): // |script_exposed_headers| may have a (User-Agent) header when
        Kelvin Jiang . unresolved

        nit: backticks around variable names instead of pipes. I also think this comment is better added before the function name in web_request_api_helpers.h as an example of why we use `script_exposed_headers` in addition to `request_headers` ?

        Andrew Brown

        OK to comment in both locations? (leave this comment but also add it to the function comment in the .h file?)

        Line 1155, Patchset 46 (Latest): // Parse old cookie line. Use request_headers for simplicity as
        // script_exposed_headers should never differ on cookies.
        Kelvin Jiang . unresolved

        nit: if you want to guarantee this, add a DCHECK

        Andrew Brown

        Fixed nit locally, will upload once other comments are also resolved (e.g. "script_exposed_headers" vs "exposed_headers" name)

        File extensions/browser/api/web_request/web_request_proxying_url_loader_factory.h
        Line 220, Patchset 46 (Latest): // that has to happen in the network stack (after CORS checks).
        Kelvin Jiang . unresolved

        dumb question: merging before would fail CORS checks?

        Andrew Brown

        Unfortunately yeah, because this all happens before the CORS checks, if we put a User-Agent on the `headers`, it triggers a CORS preflight. (Currently CORS ignores "User-Agent" because it's on the "banned" list in `net/http/http_util.cc` but this is the actual bug we're fixing -- it shouldn't be there.)

        Lots of websites aren't expecting to receive a CORS preflight for "User-Agent" (because it's already on every request ever!), so they tell CORS "no User-Agent please" and then the request fails when it shouldn't.

        File extensions/browser/api/web_request/web_request_proxying_url_loader_factory.cc
        Kelvin Jiang . unresolved

        nit: just use `request` instead of `request_` here. No difference in functionality but it reads a bit cleaner

        Andrew Brown

        Fixed nit locally, will upload once other comments are also resolved (e.g. "script_exposed_headers" vs "exposed_headers" name)

        Line 774, Patchset 46 (Latest): // We have to reconstruct the script_exposed_headers_ here in case something
        Kelvin Jiang . unresolved

        style nit: surround variable names in backticks if you can, or pipes to be consistent with the rest of the file

        Andrew Brown

        Fixed nit locally, will upload once other comments are also resolved (e.g. "script_exposed_headers" vs "exposed_headers" name)

        Kelvin Jiang . unresolved

        This implies that one of the `request_`'s headers, cors_exempt_headers or content_user_agent has changed? I'm curious where this could happen between when we first initialize script_exposed_headers_ and now.

        Andrew Brown

        Honestly I have no idea whether that could happen; in *theory* they should always be maintained the same, so this isn't necessary. I'll try removing this (in the next upload) and we'll see what happens with the trybots.

        File extensions/browser/api/web_request/web_request_proxying_websocket.cc
        Line 360, Patchset 46 (Latest): &request_headers_, nullptr);
        Kelvin Jiang . unresolved

        just curious: why is it "safe" to pass in null here?

        Andrew Brown

        Websocket and Webtransport behave differently w/r/t User-Agent (afaict) later in the network stack, so they don't need special handling to maintain & report the `script_exposed_request_headers` -- they can just report the usual `request_headers`.

        `extensions_web_request_event_router.cc:1114` supports these alternatives by not requiring `script_exposed_request_headers` to be given -- it checks for nullptr before passing it off to the actual event. Maybe preference `std::optional` to make this more explicit?

        File extensions/browser/api/web_request/web_request_proxying_webtransport.cc
        Line 111, Patchset 46 (Latest): &request_headers_, nullptr);
        Kelvin Jiang . resolved

        here too

        Andrew Brown

        Same as above

        Open in Gerrit

        Related details

        Attention is currently required from:
        • Kelvin Jiang
        • Oliver Dunk
        Gerrit-Attention: Kelvin Jiang <kelvi...@chromium.org>
        Gerrit-Attention: Oliver Dunk <olive...@chromium.org>
        Gerrit-Comment-Date: Sat, 11 Oct 2025 01:12:31 +0000
        Gerrit-HasComments: Yes
        Gerrit-Has-Labels: No
        Comment-In-Reply-To: Kelvin Jiang <kelvi...@chromium.org>
        satisfied_requirement
        unsatisfied_requirement
        open
        diffy

        Andrew Brown (Gerrit)

        unread,
        Oct 12, 2025, 9:11:38 PMOct 12
        to Oliver Dunk, Kelvin Jiang, Alex Moshchuk, Takashi Toyoshima, Adam Rice, Giovanni Ortuno Urquidi, Clark DuVall, Devlin Cronin, Chromium Metrics Reviews, Takashi Nakayama, Min Qin, Hiroki Nakagawa, James Maclean, James Su, AyeAye, Chromium LUCI CQ, chromium...@chromium.org, Nate Chapin, asvitkine...@chromium.org, devtools-re...@chromium.org, extension...@chromium.org, chromium-a...@chromium.org, mkwst+w...@chromium.org, horo+...@chromium.org, shimazu+se...@chromium.org, kinuko+ser...@chromium.org, servicewor...@chromium.org, antoniosarto...@chromium.org, kenjibah...@chromium.org, jsbell+ser...@chromium.org, arthursonzog...@chromium.org, blink-revie...@chromium.org, alexmo...@chromium.org, yhanad...@chromium.org, tranbaod...@chromium.org, nona+...@chromium.org, creis...@chromium.org, shuche...@chromium.org, jbauma...@chromium.org, navigation...@chromium.org, keithle...@chromium.org, blink-...@chromium.org, blundell+...@chromium.org, gavinp...@chromium.org, kinuko...@chromium.org, loading-re...@chromium.org, loading...@chromium.org, net-r...@chromium.org, network-ser...@chromium.org
        Attention needed from Kelvin Jiang and Oliver Dunk

        Andrew Brown added 1 comment

        File extensions/browser/api/web_request/web_request_proxying_websocket.cc
        Line 360, Patchset 46 (Latest): &request_headers_, nullptr);
        Kelvin Jiang . unresolved

        just curious: why is it "safe" to pass in null here?

        Andrew Brown

        Websocket and Webtransport behave differently w/r/t User-Agent (afaict) later in the network stack, so they don't need special handling to maintain & report the `script_exposed_request_headers` -- they can just report the usual `request_headers`.

        `extensions_web_request_event_router.cc:1114` supports these alternatives by not requiring `script_exposed_request_headers` to be given -- it checks for nullptr before passing it off to the actual event. Maybe preference `std::optional` to make this more explicit?

        Andrew Brown

        Looking at this again, it occurs to me that in these cases we should just also pass `&request_headers_` as the `script_exposed_request_headers` to be reported, rather than mucking around with `std::optional` pointers or other silly `nullptr` tricks.

        I've done this locally, will upload with the rest of the nits, etc.

        Gerrit-Comment-Date: Mon, 13 Oct 2025 01:09:00 +0000
        Gerrit-HasComments: Yes
        Gerrit-Has-Labels: No
        Comment-In-Reply-To: Kelvin Jiang <kelvi...@chromium.org>
        Comment-In-Reply-To: Andrew Brown <m...@ajbrown.au>
        satisfied_requirement
        unsatisfied_requirement
        open
        diffy

        Kelvin Jiang (Gerrit)

        unread,
        Oct 14, 2025, 9:56:09 PMOct 14
        to Andrew Brown, Oliver Dunk, Alex Moshchuk, Takashi Toyoshima, Adam Rice, Giovanni Ortuno Urquidi, Clark DuVall, Devlin Cronin, Chromium Metrics Reviews, Takashi Nakayama, Min Qin, Hiroki Nakagawa, James Maclean, James Su, AyeAye, Chromium LUCI CQ, chromium...@chromium.org, Nate Chapin, asvitkine...@chromium.org, devtools-re...@chromium.org, extension...@chromium.org, chromium-a...@chromium.org, mkwst+w...@chromium.org, horo+...@chromium.org, shimazu+se...@chromium.org, kinuko+ser...@chromium.org, servicewor...@chromium.org, antoniosarto...@chromium.org, kenjibah...@chromium.org, jsbell+ser...@chromium.org, arthursonzog...@chromium.org, blink-revie...@chromium.org, alexmo...@chromium.org, yhanad...@chromium.org, tranbaod...@chromium.org, nona+...@chromium.org, creis...@chromium.org, shuche...@chromium.org, jbauma...@chromium.org, navigation...@chromium.org, keithle...@chromium.org, blink-...@chromium.org, blundell+...@chromium.org, gavinp...@chromium.org, kinuko...@chromium.org, loading-re...@chromium.org, loading...@chromium.org, net-r...@chromium.org, network-ser...@chromium.org
        Attention needed from Andrew Brown and Oliver Dunk

        Kelvin Jiang added 2 comments

        Patchset-level comments
        Kelvin Jiang . resolved

        Going to take a more detailed pass tomorrow, mind addressing the nits since those shouldn't be blocked?

        File extensions/browser/api/web_request/web_request_proxying_websocket.cc
        Line 360, Patchset 46 (Latest): &request_headers_, nullptr);
        Kelvin Jiang . unresolved

        just curious: why is it "safe" to pass in null here?

        Andrew Brown

        Websocket and Webtransport behave differently w/r/t User-Agent (afaict) later in the network stack, so they don't need special handling to maintain & report the `script_exposed_request_headers` -- they can just report the usual `request_headers`.

        `extensions_web_request_event_router.cc:1114` supports these alternatives by not requiring `script_exposed_request_headers` to be given -- it checks for nullptr before passing it off to the actual event. Maybe preference `std::optional` to make this more explicit?

        Andrew Brown

        Looking at this again, it occurs to me that in these cases we should just also pass `&request_headers_` as the `script_exposed_request_headers` to be reported, rather than mucking around with `std::optional` pointers or other silly `nullptr` tricks.

        I've done this locally, will upload with the rest of the nits, etc.

        Kelvin Jiang

        Ack

        Open in Gerrit

        Related details

        Attention is currently required from:
        • Andrew Brown
        • Oliver Dunk
        Gerrit-Attention: Andrew Brown <m...@ajbrown.au>
        Gerrit-Attention: Oliver Dunk <olive...@chromium.org>
        Gerrit-Comment-Date: Wed, 15 Oct 2025 01:55:30 +0000
        satisfied_requirement
        unsatisfied_requirement
        open
        diffy

        Andrew Brown (Gerrit)

        unread,
        Oct 15, 2025, 8:06:58 AMOct 15
        to Oliver Dunk, Kelvin Jiang, Alex Moshchuk, Takashi Toyoshima, Adam Rice, Giovanni Ortuno Urquidi, Clark DuVall, Devlin Cronin, Chromium Metrics Reviews, Takashi Nakayama, Min Qin, Hiroki Nakagawa, James Maclean, James Su, AyeAye, Chromium LUCI CQ, chromium...@chromium.org, Nate Chapin, asvitkine...@chromium.org, devtools-re...@chromium.org, extension...@chromium.org, chromium-a...@chromium.org, mkwst+w...@chromium.org, horo+...@chromium.org, shimazu+se...@chromium.org, kinuko+ser...@chromium.org, servicewor...@chromium.org, antoniosarto...@chromium.org, kenjibah...@chromium.org, jsbell+ser...@chromium.org, arthursonzog...@chromium.org, blink-revie...@chromium.org, alexmo...@chromium.org, yhanad...@chromium.org, tranbaod...@chromium.org, nona+...@chromium.org, creis...@chromium.org, shuche...@chromium.org, jbauma...@chromium.org, navigation...@chromium.org, keithle...@chromium.org, blink-...@chromium.org, blundell+...@chromium.org, gavinp...@chromium.org, kinuko...@chromium.org, loading-re...@chromium.org, loading...@chromium.org, net-r...@chromium.org, network-ser...@chromium.org
        Attention needed from Kelvin Jiang and Oliver Dunk

        Andrew Brown added 11 comments

        Patchset-level comments
        Kelvin Jiang . resolved

        Going to take a more detailed pass tomorrow, mind addressing the nits since those shouldn't be blocked?

        Andrew Brown

        Yeah, no worries, done.

        I also rebased (mmm, 2.5 hour compile, yippee), and made a one other hopefully-non-behaviour-affecting change: the new `exposed_headers` on the `BlockedRequest` should follow the same usage pattern as the other `headers`, so instead of null-checking it everywhere, I switched to just `DCHECK()` once at the very start.

        File extensions/browser/api/web_request/extension_web_request_event_router.h
        Line 192, Patchset 46: net::HttpRequestHeaders* exposed_headers);
        Kelvin Jiang . unresolved

        nit: this is "script_exposed_headers" in the .cc file, why the "script_" part? and can we add a comment here describing what it is?

        Andrew Brown

        `script_exposed` vs `exposed` are basically arbitrary names. My original name was `user_visible_headers` but it's not clear who the *user* is (is it the extensions code, or page JS code, or the person sitting at the computer, or what), so I changed it.

        As long as we all think the name indicates "headers that the extension will see", that's the goal. Possibly switch to use `exposed_headers` everywhere?

        Andrew Brown

        Switched to use `exposed_headers` most places, except for places where we already have a variable `request_headers`, then it's called `exposed_request_headers`.

        I think this is mostly clear, and avoids questions about what "script" means? Thoughts welcome.

        File extensions/browser/api/web_request/extension_web_request_event_router.cc
        Line 592, Patchset 46: // User-Agent.
        Kelvin Jiang . unresolved

        by this you mean the CORS exempt user agent that should be merged into request headers later?

        Andrew Brown

        If the headers already have a User-Agent it will be that, e.g. if this request comes from someone doing `fetch('foo.com' {headers: {"User-Agent": "baz"}});`, then the exposed_headers will have "User-Agent: baz". The content_user_agent shouldn't override any other User-Agent.

        So it's not guaranteed that these headers have the CORS exempt User-Agent, just that they have *a* User-Agent.

        Andrew Brown

        I've updated this comment, hopefully it's clearer now?

        Line 1113, Patchset 46: // Report the script_exposed_headers if given
        Kelvin Jiang . resolved

        style nit: period at end of comments, and that comments start with a capital letter.

        Andrew Brown

        Fixed nit locally, will upload once other comments are also resolved (e.g. "script_exposed_headers" vs "exposed_headers" name)

        Andrew Brown

        Done

        File extensions/browser/api/web_request/web_request_api_helpers.h
        Line 445, Patchset 46:// Modifies the headers in `request_headers` according to `deltas`. Conflicts
        Kelvin Jiang . resolved

        nit: "Modifies the headers in `request_headers` and `script_exposed_request_headers` according to `deltas`.

        Andrew Brown

        Fixed nit locally, will upload once other comments are also resolved (e.g. "script_exposed_headers" vs "exposed_headers" name)

        Andrew Brown

        Done

        File extensions/browser/api/web_request/web_request_api_helpers.cc
        Line 439, Patchset 46: // |script_exposed_headers| may have a (User-Agent) header when
        Kelvin Jiang . resolved

        nit: backticks around variable names instead of pipes. I also think this comment is better added before the function name in web_request_api_helpers.h as an example of why we use `script_exposed_headers` in addition to `request_headers` ?

        Andrew Brown

        OK to comment in both locations? (leave this comment but also add it to the function comment in the .h file?)

        Andrew Brown

        Commented in both locations.

        Line 1155, Patchset 46: // Parse old cookie line. Use request_headers for simplicity as

        // script_exposed_headers should never differ on cookies.
        Kelvin Jiang . resolved

        nit: if you want to guarantee this, add a DCHECK

        Andrew Brown

        Fixed nit locally, will upload once other comments are also resolved (e.g. "script_exposed_headers" vs "exposed_headers" name)

        Andrew Brown

        Actually I looked more at this and while I haven't *noticed* anything that would cause `exposed_headers` to have a different Cookie, I don't think its explicitly impossible (the `Cookie` header is usually CORS-exempt, so it's possible it could end up on the `cors_exempt_headers`).

        It's actually not "worse" to check the `exposed_headers` all the time anymore, because the code expects them to be non-null, and therefore you don't have to check that here, so I'll just do that instead.

        File extensions/browser/api/web_request/web_request_proxying_url_loader_factory.cc
        Line 157, Patchset 46: request_.headers,
        Kelvin Jiang . resolved

        nit: just use `request` instead of `request_` here. No difference in functionality but it reads a bit cleaner

        Andrew Brown

        Fixed nit locally, will upload once other comments are also resolved (e.g. "script_exposed_headers" vs "exposed_headers" name)

        Andrew Brown

        Done

        Line 774, Patchset 46: // We have to reconstruct the script_exposed_headers_ here in case something
        Kelvin Jiang . resolved

        style nit: surround variable names in backticks if you can, or pipes to be consistent with the rest of the file

        Andrew Brown

        Fixed nit locally, will upload once other comments are also resolved (e.g. "script_exposed_headers" vs "exposed_headers" name)

        Andrew Brown

        Done

        Line 775, Patchset 46: // has changed
        Kelvin Jiang . resolved

        This implies that one of the `request_`'s headers, cors_exempt_headers or content_user_agent has changed? I'm curious where this could happen between when we first initialize script_exposed_headers_ and now.

        Andrew Brown

        Honestly I have no idea whether that could happen; in *theory* they should always be maintained the same, so this isn't necessary. I'll try removing this (in the next upload) and we'll see what happens with the trybots.

        Andrew Brown

        Done

        File extensions/browser/api/web_request/web_request_proxying_websocket.cc
        Line 360, Patchset 46: &request_headers_, nullptr);
        Kelvin Jiang . resolved

        just curious: why is it "safe" to pass in null here?

        Andrew Brown

        Websocket and Webtransport behave differently w/r/t User-Agent (afaict) later in the network stack, so they don't need special handling to maintain & report the `script_exposed_request_headers` -- they can just report the usual `request_headers`.

        `extensions_web_request_event_router.cc:1114` supports these alternatives by not requiring `script_exposed_request_headers` to be given -- it checks for nullptr before passing it off to the actual event. Maybe preference `std::optional` to make this more explicit?

        Andrew Brown

        Looking at this again, it occurs to me that in these cases we should just also pass `&request_headers_` as the `script_exposed_request_headers` to be reported, rather than mucking around with `std::optional` pointers or other silly `nullptr` tricks.

        I've done this locally, will upload with the rest of the nits, etc.

        Kelvin Jiang

        Ack

        Andrew Brown

        Done

        Open in Gerrit

        Related details

        Attention is currently required from:
        • Kelvin Jiang
        • Oliver Dunk
        Submit Requirements:
          • requirement satisfiedCode-Coverage
          • requirement is not satisfiedCode-Owners
          • requirement is not satisfiedCode-Review
          • requirement is not satisfiedNo-Unresolved-Comments
          • requirement is not satisfiedReview-Enforcement
          Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
          Gerrit-MessageType: comment
          Gerrit-Project: chromium/src
          Gerrit-Branch: main
          Gerrit-Change-Id: Icf56620f99f371ea2f128e6a3194d6096b0d62cd
          Gerrit-Change-Number: 5273743
          Gerrit-PatchSet: 48
          Gerrit-Owner: Andrew Brown <m...@ajbrown.au>
          Gerrit-Reviewer: Adam Rice <ri...@chromium.org>
          Gerrit-Reviewer: Alex Moshchuk <ale...@chromium.org>
          Gerrit-Reviewer: Andrew Brown <m...@ajbrown.au>
          Gerrit-Reviewer: Devlin Cronin <rdevlin...@chromium.org>
          Gerrit-Reviewer: Kelvin Jiang <kelvi...@chromium.org>
          Gerrit-Reviewer: Min Qin <qin...@chromium.org>
          Gerrit-Reviewer: Oliver Dunk <olive...@chromium.org>
          Gerrit-Reviewer: Takashi Toyoshima <toyo...@chromium.org>
          Gerrit-CC: Chromium Metrics Reviews <chromium-met...@google.com>
          Gerrit-CC: Clark DuVall <cdu...@chromium.org>
          Gerrit-CC: Giovanni Ortuno Urquidi <ort...@chromium.org>
          Gerrit-CC: Hiroki Nakagawa <nhi...@chromium.org>
          Gerrit-CC: James Maclean <wjma...@chromium.org>
          Gerrit-CC: James Su <su...@chromium.org>
          Gerrit-CC: Nate Chapin <jap...@chromium.org>
          Gerrit-CC: Takashi Nakayama <tn...@chromium.org>
          Gerrit-Attention: Kelvin Jiang <kelvi...@chromium.org>
          Gerrit-Attention: Oliver Dunk <olive...@chromium.org>
          Gerrit-Comment-Date: Wed, 15 Oct 2025 12:05:00 +0000
          satisfied_requirement
          unsatisfied_requirement
          open
          diffy

          Andrew Brown (Gerrit)

          unread,
          Oct 15, 2025, 8:13:34 AMOct 15
          to Oliver Dunk, Kelvin Jiang, Alex Moshchuk, Takashi Toyoshima, Adam Rice, Giovanni Ortuno Urquidi, Clark DuVall, Devlin Cronin, Chromium Metrics Reviews, Takashi Nakayama, Min Qin, Hiroki Nakagawa, James Maclean, James Su, AyeAye, Chromium LUCI CQ, chromium...@chromium.org, Nate Chapin, asvitkine...@chromium.org, devtools-re...@chromium.org, extension...@chromium.org, chromium-a...@chromium.org, mkwst+w...@chromium.org, horo+...@chromium.org, shimazu+se...@chromium.org, kinuko+ser...@chromium.org, servicewor...@chromium.org, antoniosarto...@chromium.org, kenjibah...@chromium.org, jsbell+ser...@chromium.org, arthursonzog...@chromium.org, blink-revie...@chromium.org, alexmo...@chromium.org, yhanad...@chromium.org, tranbaod...@chromium.org, nona+...@chromium.org, creis...@chromium.org, shuche...@chromium.org, jbauma...@chromium.org, navigation...@chromium.org, keithle...@chromium.org, blink-...@chromium.org, blundell+...@chromium.org, gavinp...@chromium.org, kinuko...@chromium.org, loading-re...@chromium.org, loading...@chromium.org, net-r...@chromium.org, network-ser...@chromium.org
          Attention needed from Kelvin Jiang and Oliver Dunk

          Andrew Brown added 1 comment

          Patchset-level comments
          File-level comment, Patchset 48 (Latest):
          Andrew Brown . unresolved

          Oh also, could someone please put this through the trybots again for me?

          There's a couple of new `DCHECK()`s that I'm not 100% confident in, so it'd be good to send it through the bots to be sure.

          Gerrit-Comment-Date: Wed, 15 Oct 2025 12:11:42 +0000
          Gerrit-HasComments: Yes
          Gerrit-Has-Labels: No
          satisfied_requirement
          unsatisfied_requirement
          open
          diffy

          Luis Hernández (Gerrit)

          unread,
          Oct 15, 2025, 4:08:49 PMOct 15
          to Andrew Brown, Oliver Dunk, Kelvin Jiang, Alex Moshchuk, Takashi Toyoshima, Adam Rice, Giovanni Ortuno Urquidi, Clark DuVall, Devlin Cronin, Chromium Metrics Reviews, Takashi Nakayama, Min Qin, Hiroki Nakagawa, James Maclean, James Su, AyeAye, Chromium LUCI CQ, chromium...@chromium.org, Nate Chapin, asvitkine...@chromium.org, devtools-re...@chromium.org, extension...@chromium.org, chromium-a...@chromium.org, mkwst+w...@chromium.org, horo+...@chromium.org, shimazu+se...@chromium.org, kinuko+ser...@chromium.org, servicewor...@chromium.org, antoniosarto...@chromium.org, kenjibah...@chromium.org, jsbell+ser...@chromium.org, arthursonzog...@chromium.org, blink-revie...@chromium.org, alexmo...@chromium.org, yhanad...@chromium.org, tranbaod...@chromium.org, nona+...@chromium.org, creis...@chromium.org, shuche...@chromium.org, jbauma...@chromium.org, navigation...@chromium.org, keithle...@chromium.org, blink-...@chromium.org, blundell+...@chromium.org, gavinp...@chromium.org, kinuko...@chromium.org, loading-re...@chromium.org, loading...@chromium.org, net-r...@chromium.org, network-ser...@chromium.org
          Attention needed from Andrew Brown, Kelvin Jiang and Oliver Dunk

          Luis Hernández added 1 comment

          Patchset-level comments
          Luis Hernández . resolved

          J

          Open in Gerrit

          Related details

          Attention is currently required from:
          • Andrew Brown
          • Kelvin Jiang
          • Oliver Dunk
          Gerrit-CC: Luis Hernández <lh15...@gmail.com>
          Gerrit-CC: Nate Chapin <jap...@chromium.org>
          Gerrit-CC: Takashi Nakayama <tn...@chromium.org>
          Gerrit-Attention: Kelvin Jiang <kelvi...@chromium.org>
          Gerrit-Attention: Andrew Brown <m...@ajbrown.au>
          Gerrit-Attention: Oliver Dunk <olive...@chromium.org>
          Gerrit-Comment-Date: Wed, 15 Oct 2025 20:08:23 +0000
          Gerrit-HasComments: Yes
          Gerrit-Has-Labels: No
          satisfied_requirement
          unsatisfied_requirement
          open
          diffy

          Kelvin Jiang (Gerrit)

          unread,
          Oct 15, 2025, 9:27:56 PMOct 15
          to Andrew Brown, Oliver Dunk, Alex Moshchuk, Takashi Toyoshima, Adam Rice, Giovanni Ortuno Urquidi, Clark DuVall, Devlin Cronin, Chromium Metrics Reviews, Takashi Nakayama, Min Qin, Hiroki Nakagawa, James Maclean, James Su, AyeAye, Chromium LUCI CQ, chromium...@chromium.org, Nate Chapin, asvitkine...@chromium.org, devtools-re...@chromium.org, extension...@chromium.org, chromium-a...@chromium.org, mkwst+w...@chromium.org, horo+...@chromium.org, shimazu+se...@chromium.org, kinuko+ser...@chromium.org, servicewor...@chromium.org, antoniosarto...@chromium.org, kenjibah...@chromium.org, jsbell+ser...@chromium.org, arthursonzog...@chromium.org, blink-revie...@chromium.org, alexmo...@chromium.org, yhanad...@chromium.org, tranbaod...@chromium.org, nona+...@chromium.org, creis...@chromium.org, shuche...@chromium.org, jbauma...@chromium.org, navigation...@chromium.org, keithle...@chromium.org, blink-...@chromium.org, blundell+...@chromium.org, gavinp...@chromium.org, kinuko...@chromium.org, loading-re...@chromium.org, loading...@chromium.org, net-r...@chromium.org, network-ser...@chromium.org
          Attention needed from Andrew Brown and Oliver Dunk

          Kelvin Jiang added 9 comments

          Patchset-level comments
          Kelvin Jiang . resolved

          Thanks for resolving most of the nits, assuming your approach works, most of my review is geared towards:

          • making sure I understand what's happening
          • evaluating how we can implement this solution while keeping the code clean and readable

          one more question:

          at any point inside the extensions webRequest code (before the extension makes changes to headers), since we set some CORS exempt headers in "exposed_headers", will any of those headers be present in the raw "request_headers"?

          File extensions/browser/api/web_request/extension_web_request_event_router.h
          Line 191, Patchset 48 (Latest): net::HttpRequestHeaders* request_headers,
          net::HttpRequestHeaders* exposed_headers);
          Kelvin Jiang . unresolved

          What do you think is cleaner and more readable? having two header objects like now or wrapping these in a struct since I see many places where these two are side by side? Also we can add struct methods that when called once, will modify both set of headers!

          Also, I assume we need to use a `net::HttpRequestHeaders*` for headers that need to skip CORS and get applied afterwards because extensions should be able to modify these?

          Line 192, Patchset 46: net::HttpRequestHeaders* exposed_headers);
          Kelvin Jiang . unresolved

          nit: this is "script_exposed_headers" in the .cc file, why the "script_" part? and can we add a comment here describing what it is?

          Andrew Brown

          `script_exposed` vs `exposed` are basically arbitrary names. My original name was `user_visible_headers` but it's not clear who the *user* is (is it the extensions code, or page JS code, or the person sitting at the computer, or what), so I changed it.

          As long as we all think the name indicates "headers that the extension will see", that's the goal. Possibly switch to use `exposed_headers` everywhere?

          Andrew Brown

          Switched to use `exposed_headers` most places, except for places where we already have a variable `request_headers`, then it's called `exposed_request_headers`.

          I think this is mostly clear, and avoids questions about what "script" means? Thoughts welcome.

          Kelvin Jiang

          how about `extension_visible_headers` ?

          as in: "these are the headers that will be visible to extensions"

          File extensions/browser/api/web_request/extension_web_request_event_router.cc
          Line 591, Patchset 48 (Latest): // The request headers that should be exposed to extensions for this request.
          Kelvin Jiang . unresolved

          reword nit: "the request headers that are shown to extensions for this request."

          "expose" kind of hints that there are headers that we hide

          File extensions/browser/api/web_request/web_request_api_helpers.h
          Line 446, Patchset 48 (Latest):// according to `deltas`. Conflicts are tried to be resolved.
          Kelvin Jiang . unresolved

          Grammar is tried to make sense.

          wording nit: "modifies the <etc> according to deltas and attempts to resolve conflicts".

          File extensions/browser/api/web_request/web_request_info.cc
          Line 207, Patchset 48 (Latest): CreateRequestBodyData(method, exposed_headers, data_sources);
          Kelvin Jiang . unresolved

          tiny optonal nit: no reason for this LOC change, I just go with whatever's more readable if it adheres to the style guide

          File extensions/browser/api/web_request/web_request_proxying_url_loader_factory.cc
          Line 780, Patchset 48 (Latest): // modification
          Kelvin Jiang . unresolved

          styling nit: period at end of comment

          File extensions/browser/api/web_request/web_request_proxying_websocket.cc
          Line 363, Patchset 48 (Latest): &request_headers_, &request_headers_);
          Kelvin Jiang . unresolved

          nit: if we don't need special "exposed" headers then we should just pass null here. This would prevent bugs where doing something to a header object twice has an unintended effect (since both of these point to the same object.)

          That probably means that elsewhere, if "exposed headers" (or whatever we rename it to) is null, fall back to the original headers.

          File extensions/browser/api/web_request/web_request_proxying_webtransport.cc
          Line 113, Patchset 48 (Latest): &request_headers_, &request_headers_);
          Kelvin Jiang . unresolved

          ditto comment from web_request_proxying_websocket.cc

          Open in Gerrit

          Related details

          Attention is currently required from:
          • Andrew Brown
          • Oliver Dunk
          Gerrit-CC: Name of user not set #4416269
          Gerrit-CC: Nate Chapin <jap...@chromium.org>
          Gerrit-CC: Takashi Nakayama <tn...@chromium.org>
          Gerrit-Attention: Andrew Brown <m...@ajbrown.au>
          Gerrit-Attention: Oliver Dunk <olive...@chromium.org>
          Gerrit-Comment-Date: Thu, 16 Oct 2025 01:27:25 +0000
          Gerrit-HasComments: Yes
          Gerrit-Has-Labels: No
          satisfied_requirement
          unsatisfied_requirement
          open
          diffy

          Kelvin Jiang (Gerrit)

          unread,
          Oct 15, 2025, 9:28:34 PMOct 15
          to Andrew Brown, Oliver Dunk, Alex Moshchuk, Takashi Toyoshima, Adam Rice, Giovanni Ortuno Urquidi, Clark DuVall, Devlin Cronin, Chromium Metrics Reviews, Takashi Nakayama, Min Qin, Hiroki Nakagawa, James Maclean, James Su, AyeAye, Chromium LUCI CQ, chromium...@chromium.org, Nate Chapin, asvitkine...@chromium.org, devtools-re...@chromium.org, extension...@chromium.org, chromium-a...@chromium.org, mkwst+w...@chromium.org, horo+...@chromium.org, shimazu+se...@chromium.org, kinuko+ser...@chromium.org, servicewor...@chromium.org, antoniosarto...@chromium.org, kenjibah...@chromium.org, jsbell+ser...@chromium.org, arthursonzog...@chromium.org, blink-revie...@chromium.org, alexmo...@chromium.org, yhanad...@chromium.org, tranbaod...@chromium.org, nona+...@chromium.org, creis...@chromium.org, shuche...@chromium.org, jbauma...@chromium.org, navigation...@chromium.org, keithle...@chromium.org, blink-...@chromium.org, blundell+...@chromium.org, gavinp...@chromium.org, kinuko...@chromium.org, loading-re...@chromium.org, loading...@chromium.org, net-r...@chromium.org, network-ser...@chromium.org
          Attention needed from Andrew Brown and Oliver Dunk

          Kelvin Jiang added 1 comment

          Patchset-level comments
          Kelvin Jiang . resolved

          So yes, let me know if using a struct in certain places would make things cleaner or more readable too, and thanks for all the effort!

          satisfied_requirement
          unsatisfied_requirement
          open
          diffy

          Andrew Brown (Gerrit)

          unread,
          Oct 16, 2025, 12:34:47 AMOct 16
          to Kelvin Jiang, Oliver Dunk, Alex Moshchuk, Takashi Toyoshima, Adam Rice, Giovanni Ortuno Urquidi, Clark DuVall, Devlin Cronin, Chromium Metrics Reviews, Takashi Nakayama, Min Qin, Hiroki Nakagawa, James Maclean, James Su, AyeAye, Chromium LUCI CQ, chromium...@chromium.org, Nate Chapin, asvitkine...@chromium.org, devtools-re...@chromium.org, extension...@chromium.org, chromium-a...@chromium.org, mkwst+w...@chromium.org, horo+...@chromium.org, shimazu+se...@chromium.org, kinuko+ser...@chromium.org, servicewor...@chromium.org, antoniosarto...@chromium.org, kenjibah...@chromium.org, jsbell+ser...@chromium.org, arthursonzog...@chromium.org, blink-revie...@chromium.org, alexmo...@chromium.org, yhanad...@chromium.org, tranbaod...@chromium.org, nona+...@chromium.org, creis...@chromium.org, shuche...@chromium.org, jbauma...@chromium.org, navigation...@chromium.org, keithle...@chromium.org, blink-...@chromium.org, blundell+...@chromium.org, gavinp...@chromium.org, kinuko...@chromium.org, loading-re...@chromium.org, loading...@chromium.org, net-r...@chromium.org, network-ser...@chromium.org
          Attention needed from Kelvin Jiang and Oliver Dunk

          Andrew Brown added 10 comments

          Patchset-level comments
          Kelvin Jiang . resolved

          Thanks for resolving most of the nits, assuming your approach works, most of my review is geared towards:

          • making sure I understand what's happening
          • evaluating how we can implement this solution while keeping the code clean and readable

          one more question:

          at any point inside the extensions webRequest code (before the extension makes changes to headers), since we set some CORS exempt headers in "exposed_headers", will any of those headers be present in the raw "request_headers"?

          Andrew Brown

          It's possible that the raw `request_headers` has "X-Header-Name: foo" and the `cors_exempt_headers` has "X-Header-Name: bar", yes. In this case, on the final request, the `cors_exempt_headers` value will override the `request_headers` value. This generally shouldn't be relied on, but the CL slightly standardises the header merging behaviour by implementing `net::HttpUtil::MergeAndAddUserAgent` to combine everything together, and now all places that do single merges use this. (Unfortunately extensions is a weird edge case because it has to keep things up-to-date all the time, so it is substantially cheaper to modify everything, rather than doing a whole new `MergeAndAddUserAgent` every single time.)


          Possibly there is bad behaviour here where extensions will see a header on the `exposed_headers`, modify it (which will go to the to-be-discarded `exposed_headers` and the request's ordinary `headers`), but then the final request will still use the unmodified `cors_exempt_headers` value.

          I'm not sure whether this is worth worrying about in light of the *current* behaviour, which is that extensions never gets access to the `cors_exempt_headers` at all? The choice is between:

          • current behaviour: `headers` has "X-Foo: value1" and `cors_exempt_headers` has "X-Foo: value2" -> an extension will see "X-Foo: value1", then any changes will eventually be clobbered by "value2"
          • this CL behaviour: same setup -> an extension will see "X-Foo: value2", and any changes are clobbered back to "value2"
          File extensions/browser/api/web_request/extension_web_request_event_router.h
          Line 191, Patchset 48: net::HttpRequestHeaders* request_headers,
          net::HttpRequestHeaders* exposed_headers);
          Kelvin Jiang . unresolved

          What do you think is cleaner and more readable? having two header objects like now or wrapping these in a struct since I see many places where these two are side by side? Also we can add struct methods that when called once, will modify both set of headers!

          Also, I assume we need to use a `net::HttpRequestHeaders*` for headers that need to skip CORS and get applied afterwards because extensions should be able to modify these?

          Andrew Brown

          Hmm, not sure. I don't think there is much benefit to combining them because most functions will still need to do things with one or the other individually (i.e. it's not like we do `foo(both)` which calls `bar(both)` which calls `baz(both)` that splits them up, where `foo` and `bar` never need to go inside the `both` struct -- basically every level will need to go inside the `both` struct. The only super-relevant benefit will be that last level doesn't need to do two `headers->SetHeader(key, val)`, it can do a special `SetBoth(both, key, val)`, but I think that's maybe less clear than just doing two SetHeaders. Also, there are a lot of places (e.g. WebRequestInfo) that only have the `exposed_headers` still, and implicitly receive the `headers` via access to the ResourceRequest or similar. So none of those places would benefit from some sort of `TwoHeaders` struct.

          If you would prefer to combine the two into some struct I'm happy to do that, but my thought is probably that keeping them separate looks better. You're the owner who'll have to deal with things long-term though, so please override me if you want.

          ---

          I'm not sure what you mean about headers that skip CORS and get applied afterwards. Are you talking about cases where the extensions modifies "Not-Cors-Exempt: x" to be "Not-Cors-Exempt: y", and this modification would go onto `headers` and cause a CORS check?

          This doesn't need special handling (as of right now) because these headers are all on the list in `net/http/http_util.cc`, and headers from that list are assumed to always be CORS-safe no matter where they are. This is because javascript APIs do not allow setting values for any of those headers, so if they have a value set, it must have come from somewhere else. This CL will not change any of that behaviour, except for User-Agent.

          Does this mean, then, that extensions-set User-Agent values should be exempt from CORS checks? If so, we need special logic to ensure that if extensions modifies User-Agent, that change is reflected in the `content_user_agent` value, not just set onto `headers`, because values of `user_agent` on the `headers` will trigger CORS.

          Line 192, Patchset 46: net::HttpRequestHeaders* exposed_headers);
          Kelvin Jiang . resolved

          nit: this is "script_exposed_headers" in the .cc file, why the "script_" part? and can we add a comment here describing what it is?

          Andrew Brown

          `script_exposed` vs `exposed` are basically arbitrary names. My original name was `user_visible_headers` but it's not clear who the *user* is (is it the extensions code, or page JS code, or the person sitting at the computer, or what), so I changed it.

          As long as we all think the name indicates "headers that the extension will see", that's the goal. Possibly switch to use `exposed_headers` everywhere?

          Andrew Brown

          Switched to use `exposed_headers` most places, except for places where we already have a variable `request_headers`, then it's called `exposed_request_headers`.

          I think this is mostly clear, and avoids questions about what "script" means? Thoughts welcome.

          Kelvin Jiang

          how about `extension_visible_headers` ?

          as in: "these are the headers that will be visible to extensions"

          Andrew Brown

          Sounds good to me :) Done.

          File extensions/browser/api/web_request/extension_web_request_event_router.cc
          Line 591, Patchset 48: // The request headers that should be exposed to extensions for this request.
          Kelvin Jiang . resolved

          reword nit: "the request headers that are shown to extensions for this request."

          "expose" kind of hints that there are headers that we hide

          Andrew Brown

          Done

          File extensions/browser/api/web_request/web_request_api_helpers.h
          Line 446, Patchset 48:// according to `deltas`. Conflicts are tried to be resolved.
          Kelvin Jiang . resolved

          Grammar is tried to make sense.

          wording nit: "modifies the <etc> according to deltas and attempts to resolve conflicts".

          Andrew Brown

          Yeah, that read strangely to me too. Done.

          File extensions/browser/api/web_request/web_request_info.cc
          Line 207, Patchset 48: CreateRequestBodyData(method, exposed_headers, data_sources);
          Kelvin Jiang . resolved

          tiny optonal nit: no reason for this LOC change, I just go with whatever's more readable if it adheres to the style guide

          Andrew Brown

          I think the line is slightly too long, `git cl upload` yells at me and say I need to autoformat :(

          Anyway, with the new `extensions_visible` name, it's definitely too long, so it has to stay.

          File extensions/browser/api/web_request/web_request_proxying_url_loader_factory.cc
          Line 778, Patchset 49 (Latest): request_.content_user_agent);
          Andrew Brown . unresolved

          I re-added this because I think it was what caused the test failures. I have no idea how or why, but I was able to pass header-modifying tests locally with this line added, and they failed without it.

          Still needs another trybot run to confirm.

          Line 780, Patchset 48: // modification
          Kelvin Jiang . resolved

          styling nit: period at end of comment

          Andrew Brown

          Agh, I knew I'd miss one. Fixed.

          File extensions/browser/api/web_request/web_request_proxying_websocket.cc
          Line 363, Patchset 48: &request_headers_, &request_headers_);
          Kelvin Jiang . resolved

          nit: if we don't need special "exposed" headers then we should just pass null here. This would prevent bugs where doing something to a header object twice has an unintended effect (since both of these point to the same object.)

          That probably means that elsewhere, if "exposed headers" (or whatever we rename it to) is null, fall back to the original headers.

          Andrew Brown

          Ok yeah, so not worth passing both, return to the original impl where webtransport and websocket pass in nullptr and the OnBeforeSendHeaders has to check which one to use. Can do.


          I also added a comment to `extension_web_request_event_router.h` for `OnBeforeSendHeaders()` to explain that it handles `nullptr` in the `extensions_visible_request_headers`.

          File extensions/browser/api/web_request/web_request_proxying_webtransport.cc
          Line 113, Patchset 48: &request_headers_, &request_headers_);
          Kelvin Jiang . resolved

          ditto comment from web_request_proxying_websocket.cc

          Andrew Brown

          Fixed as above.

          Open in Gerrit

          Related details

          Attention is currently required from:
          • Kelvin Jiang
          • Oliver Dunk
          Submit Requirements:
          • requirement satisfiedCode-Coverage
          • requirement is not satisfiedCode-Owners
          • requirement is not satisfiedCode-Review
          • requirement is not satisfiedNo-Unresolved-Comments
          • requirement is not satisfiedReview-Enforcement
          Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
          Gerrit-MessageType: comment
          Gerrit-Project: chromium/src
          Gerrit-Branch: main
          Gerrit-Change-Id: Icf56620f99f371ea2f128e6a3194d6096b0d62cd
          Gerrit-Change-Number: 5273743
          Gerrit-PatchSet: 49
          Gerrit-Owner: Andrew Brown <m...@ajbrown.au>
          Gerrit-Reviewer: Adam Rice <ri...@chromium.org>
          Gerrit-Reviewer: Alex Moshchuk <ale...@chromium.org>
          Gerrit-Reviewer: Andrew Brown <m...@ajbrown.au>
          Gerrit-Reviewer: Devlin Cronin <rdevlin...@chromium.org>
          Gerrit-Reviewer: Kelvin Jiang <kelvi...@chromium.org>
          Gerrit-Reviewer: Min Qin <qin...@chromium.org>
          Gerrit-Reviewer: Oliver Dunk <olive...@chromium.org>
          Gerrit-Reviewer: Takashi Toyoshima <toyo...@chromium.org>
          Gerrit-CC: Chromium Metrics Reviews <chromium-met...@google.com>
          Gerrit-CC: Clark DuVall <cdu...@chromium.org>
          Gerrit-CC: Giovanni Ortuno Urquidi <ort...@chromium.org>
          Gerrit-CC: Hiroki Nakagawa <nhi...@chromium.org>
          Gerrit-CC: James Maclean <wjma...@chromium.org>
          Gerrit-CC: James Su <su...@chromium.org>
          Gerrit-CC: Name of user not set #4416269
          Gerrit-CC: Nate Chapin <jap...@chromium.org>
          Gerrit-CC: Takashi Nakayama <tn...@chromium.org>
          Gerrit-Attention: Kelvin Jiang <kelvi...@chromium.org>
          Gerrit-Attention: Oliver Dunk <olive...@chromium.org>
          Gerrit-Comment-Date: Thu, 16 Oct 2025 04:32:55 +0000
          Gerrit-HasComments: Yes
          Gerrit-Has-Labels: No
          satisfied_requirement
          unsatisfied_requirement
          open
          diffy

          Andrea Orru (Gerrit)

          unread,
          Oct 17, 2025, 5:46:42 PMOct 17
          to Andrew Brown, Kelvin Jiang, Oliver Dunk, Alex Moshchuk, Takashi Toyoshima, Adam Rice, Giovanni Ortuno Urquidi, Clark DuVall, Devlin Cronin, Chromium Metrics Reviews, Takashi Nakayama, Min Qin, Hiroki Nakagawa, James Maclean, James Su, AyeAye, Chromium LUCI CQ, chromium...@chromium.org, Nate Chapin, asvitkine...@chromium.org, devtools-re...@chromium.org, extension...@chromium.org, chromium-a...@chromium.org, mkwst+w...@chromium.org, horo+...@chromium.org, shimazu+se...@chromium.org, kinuko+ser...@chromium.org, servicewor...@chromium.org, antoniosarto...@chromium.org, kenjibah...@chromium.org, jsbell+ser...@chromium.org, arthursonzog...@chromium.org, blink-revie...@chromium.org, alexmo...@chromium.org, yhanad...@chromium.org, tranbaod...@chromium.org, nona+...@chromium.org, creis...@chromium.org, shuche...@chromium.org, jbauma...@chromium.org, navigation...@chromium.org, keithle...@chromium.org, blink-...@chromium.org, blundell+...@chromium.org, gavinp...@chromium.org, kinuko...@chromium.org, loading-re...@chromium.org, loading...@chromium.org, net-r...@chromium.org, network-ser...@chromium.org
          Attention needed from Andrew Brown, Kelvin Jiang and Oliver Dunk

          Andrea Orru added 4 comments

          File extensions/browser/api/web_request/web_request_api_helpers.h
          Line 446, Patchset 49 (Latest):// `extension_visible_request_headers` according to `deltas, and attempts to
          Andrea Orru . unresolved

          `deltas` missing a backtick

          File extensions/browser/api/web_request/web_request_api_helpers.cc
          Line 1193, Patchset 49 (Latest): DCHECK(extension_visible_request_headers);
          Andrea Orru . unresolved

          Elsewhere you are passing `nullptr` to `OnBeforeSendHeaders` for this parameter. Are you sure we can't end up with a `nullptr` here?

          File extensions/browser/api/web_request/web_request_proxying_websocket.cc
          Line 87, Patchset 49 (Latest): /*extension_visible_headers=*/request.headers)),
          Andrea Orru . unresolved

          Are these the extension visible headers? These haven't been merged? Or am I missing something?

          Line 363, Patchset 49 (Latest): &request_headers_, nullptr);
          Andrea Orru . unresolved

          This is the `nullptr` I'm referring to. I noticed you used `&request_headers_` in `web_request_proxying_webtransport.cc` instead of `nullptr`. Can't you do the same here?

          Open in Gerrit

          Related details

          Attention is currently required from:
          • Andrew Brown
          • Kelvin Jiang
          • Oliver Dunk
          Submit Requirements:
          • requirement satisfiedCode-Coverage
          • requirement is not satisfiedCode-Owners
          • requirement is not satisfiedCode-Review
          • requirement is not satisfiedNo-Unresolved-Comments
          • requirement is not satisfiedReview-Enforcement
          Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
          Gerrit-MessageType: comment
          Gerrit-Project: chromium/src
          Gerrit-Branch: main
          Gerrit-Change-Id: Icf56620f99f371ea2f128e6a3194d6096b0d62cd
          Gerrit-Change-Number: 5273743
          Gerrit-PatchSet: 49
          Gerrit-Owner: Andrew Brown <m...@ajbrown.au>
          Gerrit-Reviewer: Adam Rice <ri...@chromium.org>
          Gerrit-Reviewer: Alex Moshchuk <ale...@chromium.org>
          Gerrit-Reviewer: Andrea Orru <andre...@chromium.org>
          Gerrit-Reviewer: Andrew Brown <m...@ajbrown.au>
          Gerrit-Reviewer: Devlin Cronin <rdevlin...@chromium.org>
          Gerrit-Reviewer: Kelvin Jiang <kelvi...@chromium.org>
          Gerrit-Reviewer: Min Qin <qin...@chromium.org>
          Gerrit-Reviewer: Oliver Dunk <olive...@chromium.org>
          Gerrit-Reviewer: Takashi Toyoshima <toyo...@chromium.org>
          Gerrit-CC: Chromium Metrics Reviews <chromium-met...@google.com>
          Gerrit-CC: Clark DuVall <cdu...@chromium.org>
          Gerrit-CC: Giovanni Ortuno Urquidi <ort...@chromium.org>
          Gerrit-CC: Hiroki Nakagawa <nhi...@chromium.org>
          Gerrit-CC: James Maclean <wjma...@chromium.org>
          Gerrit-CC: James Su <su...@chromium.org>
          Gerrit-CC: Name of user not set #4416269
          Gerrit-CC: Nate Chapin <jap...@chromium.org>
          Gerrit-CC: Takashi Nakayama <tn...@chromium.org>
          Gerrit-Attention: Kelvin Jiang <kelvi...@chromium.org>
          Gerrit-Attention: Andrew Brown <m...@ajbrown.au>
          Gerrit-Attention: Oliver Dunk <olive...@chromium.org>
          Gerrit-Comment-Date: Fri, 17 Oct 2025 21:46:31 +0000
          Gerrit-HasComments: Yes
          Gerrit-Has-Labels: No
          satisfied_requirement
          unsatisfied_requirement
          open
          diffy

          Andrea Orru (Gerrit)

          unread,
          Oct 17, 2025, 6:10:54 PMOct 17
          to Andrew Brown, Kelvin Jiang, Oliver Dunk, Alex Moshchuk, Takashi Toyoshima, Adam Rice, Giovanni Ortuno Urquidi, Clark DuVall, Devlin Cronin, Chromium Metrics Reviews, Takashi Nakayama, Min Qin, Hiroki Nakagawa, James Maclean, James Su, AyeAye, Chromium LUCI CQ, chromium...@chromium.org, Nate Chapin, asvitkine...@chromium.org, devtools-re...@chromium.org, extension...@chromium.org, chromium-a...@chromium.org, mkwst+w...@chromium.org, horo+...@chromium.org, shimazu+se...@chromium.org, kinuko+ser...@chromium.org, servicewor...@chromium.org, antoniosarto...@chromium.org, kenjibah...@chromium.org, jsbell+ser...@chromium.org, arthursonzog...@chromium.org, blink-revie...@chromium.org, alexmo...@chromium.org, yhanad...@chromium.org, tranbaod...@chromium.org, nona+...@chromium.org, creis...@chromium.org, shuche...@chromium.org, jbauma...@chromium.org, navigation...@chromium.org, keithle...@chromium.org, blink-...@chromium.org, blundell+...@chromium.org, gavinp...@chromium.org, kinuko...@chromium.org, loading-re...@chromium.org, loading...@chromium.org, net-r...@chromium.org, network-ser...@chromium.org
          Attention needed from Andrew Brown, Kelvin Jiang and Oliver Dunk

          Andrea Orru added 1 comment

          File extensions/browser/api/web_request/web_request_api_helpers.cc
          Line 1193, Patchset 49 (Latest): DCHECK(extension_visible_request_headers);
          Andrea Orru . unresolved

          Elsewhere you are passing `nullptr` to `OnBeforeSendHeaders` for this parameter. Are you sure we can't end up with a `nullptr` here?

          Andrea Orru

          Looks from the failed tests that we can.

          Gerrit-Comment-Date: Fri, 17 Oct 2025 22:10:40 +0000
          Gerrit-HasComments: Yes
          Gerrit-Has-Labels: No
          Comment-In-Reply-To: Andrea Orru <andre...@chromium.org>
          satisfied_requirement
          unsatisfied_requirement
          open
          diffy

          Andrew Brown (Gerrit)

          unread,
          Oct 17, 2025, 6:23:34 PMOct 17
          to Andrea Orru, Kelvin Jiang, Oliver Dunk, Alex Moshchuk, Takashi Toyoshima, Adam Rice, Giovanni Ortuno Urquidi, Clark DuVall, Devlin Cronin, Chromium Metrics Reviews, Takashi Nakayama, Min Qin, Hiroki Nakagawa, James Maclean, James Su, AyeAye, Chromium LUCI CQ, chromium...@chromium.org, Nate Chapin, asvitkine...@chromium.org, devtools-re...@chromium.org, extension...@chromium.org, chromium-a...@chromium.org, mkwst+w...@chromium.org, horo+...@chromium.org, shimazu+se...@chromium.org, kinuko+ser...@chromium.org, servicewor...@chromium.org, antoniosarto...@chromium.org, kenjibah...@chromium.org, jsbell+ser...@chromium.org, arthursonzog...@chromium.org, blink-revie...@chromium.org, alexmo...@chromium.org, yhanad...@chromium.org, tranbaod...@chromium.org, nona+...@chromium.org, creis...@chromium.org, shuche...@chromium.org, jbauma...@chromium.org, navigation...@chromium.org, keithle...@chromium.org, blink-...@chromium.org, blundell+...@chromium.org, gavinp...@chromium.org, kinuko...@chromium.org, loading-re...@chromium.org, loading...@chromium.org, net-r...@chromium.org, network-ser...@chromium.org
          Attention needed from Kelvin Jiang and Oliver Dunk

          Andrew Brown added 1 comment

          File extensions/browser/api/web_request/web_request_api_helpers.cc
          Line 1193, Patchset 49 (Latest): DCHECK(extension_visible_request_headers);
          Andrea Orru . unresolved

          Elsewhere you are passing `nullptr` to `OnBeforeSendHeaders` for this parameter. Are you sure we can't end up with a `nullptr` here?

          Andrea Orru

          Looks from the failed tests that we can.

          Andrew Brown

          Yeah, I spotted dcheck failures from the websocket tests.


          My implementation that passed, 2 patchsets ago, handled this by checking `extension_visible_request_headers` every single time it was going to be used, but I figured that's a lot of extra code, so worth switching to dcheck to see if that might not be necessary. (And it wouldn't have been a problem if we'd stayed with the "just pass request headers twice" approach for websockets & webtransport, but I guess that might have had other issues if every action actually was executed twice.)


          Anyway, it seems like we do need to check everywhere. I'll revert that change and reupload, hopefully in the next 15 min or so.

          Open in Gerrit

          Related details

          Attention is currently required from:
          • Kelvin Jiang
          • Oliver Dunk
          Gerrit-Attention: Oliver Dunk <olive...@chromium.org>
          Gerrit-Comment-Date: Fri, 17 Oct 2025 22:23:00 +0000
          satisfied_requirement
          unsatisfied_requirement
          open
          diffy

          Andrew Brown (Gerrit)

          unread,
          Oct 17, 2025, 7:29:23 PMOct 17
          to Andrea Orru, Kelvin Jiang, Oliver Dunk, Alex Moshchuk, Takashi Toyoshima, Adam Rice, Giovanni Ortuno Urquidi, Clark DuVall, Devlin Cronin, Chromium Metrics Reviews, Takashi Nakayama, Min Qin, Hiroki Nakagawa, James Maclean, James Su, AyeAye, Chromium LUCI CQ, chromium...@chromium.org, Nate Chapin, asvitkine...@chromium.org, devtools-re...@chromium.org, extension...@chromium.org, chromium-a...@chromium.org, mkwst+w...@chromium.org, horo+...@chromium.org, shimazu+se...@chromium.org, kinuko+ser...@chromium.org, servicewor...@chromium.org, antoniosarto...@chromium.org, kenjibah...@chromium.org, jsbell+ser...@chromium.org, arthursonzog...@chromium.org, blink-revie...@chromium.org, alexmo...@chromium.org, yhanad...@chromium.org, tranbaod...@chromium.org, nona+...@chromium.org, creis...@chromium.org, shuche...@chromium.org, jbauma...@chromium.org, navigation...@chromium.org, keithle...@chromium.org, blink-...@chromium.org, blundell+...@chromium.org, gavinp...@chromium.org, kinuko...@chromium.org, loading-re...@chromium.org, loading...@chromium.org, net-r...@chromium.org, network-ser...@chromium.org
          Attention needed from Andrea Orru, Kelvin Jiang and Oliver Dunk

          Andrew Brown added 4 comments

          File extensions/browser/api/web_request/web_request_api_helpers.h
          Line 446, Patchset 49:// `extension_visible_request_headers` according to `deltas, and attempts to
          Andrea Orru . resolved

          `deltas` missing a backtick

          Andrew Brown

          Done

          File extensions/browser/api/web_request/web_request_api_helpers.cc
          Line 1193, Patchset 49: DCHECK(extension_visible_request_headers);
          Andrea Orru . unresolved

          Elsewhere you are passing `nullptr` to `OnBeforeSendHeaders` for this parameter. Are you sure we can't end up with a `nullptr` here?

          Andrea Orru

          Looks from the failed tests that we can.

          Andrew Brown

          Yeah, I spotted dcheck failures from the websocket tests.


          My implementation that passed, 2 patchsets ago, handled this by checking `extension_visible_request_headers` every single time it was going to be used, but I figured that's a lot of extra code, so worth switching to dcheck to see if that might not be necessary. (And it wouldn't have been a problem if we'd stayed with the "just pass request headers twice" approach for websockets & webtransport, but I guess that might have had other issues if every action actually was executed twice.)


          Anyway, it seems like we do need to check everywhere. I'll revert that change and reupload, hopefully in the next 15 min or so.

          Andrew Brown

          Hopefully done but needs a new dry run.
          ...so much for 15 minutes, lol.

          File extensions/browser/api/web_request/web_request_proxying_websocket.cc
          Line 87, Patchset 49: /*extension_visible_headers=*/request.headers)),
          Andrea Orru . unresolved

          Are these the extension visible headers? These haven't been merged? Or am I missing something?

          Andrew Brown

          Websocket requests are immune to CORS (at least by my reading of https://developer.mozilla.org/en-US/docs/Web/HTTP/Guides/CORS). This is a huge relief because otherwise I would need to manage their own completely different way of passing User-Agents down through mojo -- see `WebRequestProxyingWebSocket::StartProxying()`, where User-Agent is actually added to the headers there.

          So AFAICT they don't actually need any special `extension_visible_headers` behaviour, because they're safe to put all headers onto the ordinary `headers`, including User-Agent, which they already do, without triggering CORS stuff later on.

          I've added a comment to explain this -- wording suggestions welcome to make sure it's clear.

          Line 363, Patchset 49: &request_headers_, nullptr);
          Andrea Orru . resolved

          This is the `nullptr` I'm referring to. I noticed you used `&request_headers_` in `web_request_proxying_webtransport.cc` instead of `nullptr`. Can't you do the same here?

          Andrew Brown

          Mm, I must have missed changing that, my bad. I had thought to pass `&request_headers_` twice, no weird nullptr handling necessary, but preference by webRequest API owners was to pass `nullptr` and check for it, to avoid any weird behaviour from potentially handling the same object twice.


          https://chromium-review.googlesource.com/c/chromium/src/+/5273743/comment/b9d31962_44f08fa2/


          IIRC I commented about `nullptr` handling somewhere in the event_router file, but I've also added comments to `web_request_api_helpers.h` to explain that they need to handle `nullptr` in some cases too.

          Open in Gerrit

          Related details

          Attention is currently required from:
          • Andrea Orru
          • Kelvin Jiang
          • Oliver Dunk
          Submit Requirements:
          • requirement satisfiedCode-Coverage
          • requirement is not satisfiedCode-Owners
          • requirement is not satisfiedCode-Review
          • requirement is not satisfiedNo-Unresolved-Comments
          • requirement is not satisfiedReview-Enforcement
          Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
          Gerrit-MessageType: comment
          Gerrit-Project: chromium/src
          Gerrit-Branch: main
          Gerrit-Change-Id: Icf56620f99f371ea2f128e6a3194d6096b0d62cd
          Gerrit-Change-Number: 5273743
          Gerrit-PatchSet: 51
          Gerrit-Owner: Andrew Brown <m...@ajbrown.au>
          Gerrit-Reviewer: Adam Rice <ri...@chromium.org>
          Gerrit-Reviewer: Alex Moshchuk <ale...@chromium.org>
          Gerrit-Reviewer: Andrea Orru <andre...@chromium.org>
          Gerrit-Reviewer: Andrew Brown <m...@ajbrown.au>
          Gerrit-Reviewer: Devlin Cronin <rdevlin...@chromium.org>
          Gerrit-Reviewer: Kelvin Jiang <kelvi...@chromium.org>
          Gerrit-Reviewer: Min Qin <qin...@chromium.org>
          Gerrit-Reviewer: Oliver Dunk <olive...@chromium.org>
          Gerrit-Reviewer: Takashi Toyoshima <toyo...@chromium.org>
          Gerrit-CC: Chromium Metrics Reviews <chromium-met...@google.com>
          Gerrit-CC: Clark DuVall <cdu...@chromium.org>
          Gerrit-CC: Giovanni Ortuno Urquidi <ort...@chromium.org>
          Gerrit-CC: Hiroki Nakagawa <nhi...@chromium.org>
          Gerrit-CC: James Maclean <wjma...@chromium.org>
          Gerrit-CC: James Su <su...@chromium.org>
          Gerrit-CC: Name of user not set #4416269
          Gerrit-CC: Nate Chapin <jap...@chromium.org>
          Gerrit-CC: Takashi Nakayama <tn...@chromium.org>
          Gerrit-Attention: Kelvin Jiang <kelvi...@chromium.org>
          Gerrit-Attention: Oliver Dunk <olive...@chromium.org>
          Gerrit-Attention: Andrea Orru <andre...@chromium.org>
          Gerrit-Comment-Date: Fri, 17 Oct 2025 23:28:45 +0000
          Gerrit-HasComments: Yes
          Gerrit-Has-Labels: No
          Comment-In-Reply-To: Andrew Brown <m...@ajbrown.au>
          Comment-In-Reply-To: Andrea Orru <andre...@chromium.org>
          satisfied_requirement
          unsatisfied_requirement
          open
          diffy

          Andrew Brown (Gerrit)

          unread,
          Oct 17, 2025, 7:30:59 PMOct 17
          to Andrea Orru, Kelvin Jiang, Oliver Dunk, Alex Moshchuk, Takashi Toyoshima, Adam Rice, Giovanni Ortuno Urquidi, Clark DuVall, Devlin Cronin, Chromium Metrics Reviews, Takashi Nakayama, Min Qin, Hiroki Nakagawa, James Maclean, James Su, AyeAye, Chromium LUCI CQ, chromium...@chromium.org, Nate Chapin, asvitkine...@chromium.org, devtools-re...@chromium.org, extension...@chromium.org, chromium-a...@chromium.org, mkwst+w...@chromium.org, horo+...@chromium.org, shimazu+se...@chromium.org, kinuko+ser...@chromium.org, servicewor...@chromium.org, antoniosarto...@chromium.org, kenjibah...@chromium.org, jsbell+ser...@chromium.org, arthursonzog...@chromium.org, blink-revie...@chromium.org, alexmo...@chromium.org, yhanad...@chromium.org, tranbaod...@chromium.org, nona+...@chromium.org, creis...@chromium.org, shuche...@chromium.org, jbauma...@chromium.org, navigation...@chromium.org, keithle...@chromium.org, blink-...@chromium.org, blundell+...@chromium.org, gavinp...@chromium.org, kinuko...@chromium.org, loading-re...@chromium.org, loading...@chromium.org, net-r...@chromium.org, network-ser...@chromium.org
          Attention needed from Andrew Brown, Kelvin Jiang and Oliver Dunk

          Andrew Brown added 1 comment

          File extensions/browser/api/web_request/web_request_proxying_websocket.cc
          Line 87, Patchset 49: /*extension_visible_headers=*/request.headers)),
          Andrea Orru . unresolved

          Are these the extension visible headers? These haven't been merged? Or am I missing something?

          Andrew Brown

          Websocket requests are immune to CORS (at least by my reading of https://developer.mozilla.org/en-US/docs/Web/HTTP/Guides/CORS). This is a huge relief because otherwise I would need to manage their own completely different way of passing User-Agents down through mojo -- see `WebRequestProxyingWebSocket::StartProxying()`, where User-Agent is actually added to the headers there.

          So AFAICT they don't actually need any special `extension_visible_headers` behaviour, because they're safe to put all headers onto the ordinary `headers`, including User-Agent, which they already do, without triggering CORS stuff later on.

          I've added a comment to explain this -- wording suggestions welcome to make sure it's clear.

          Andrew Brown

          Well, I guess, not immune to CORS altogether, but immune to the `access-control-allow-headers` part of CORS, which is the bit I care about here.

          Open in Gerrit

          Related details

          Attention is currently required from:
          • Andrew Brown
          • Kelvin Jiang
          • Oliver Dunk
          Gerrit-Attention: Andrew Brown <m...@ajbrown.au>
          Gerrit-Attention: Oliver Dunk <olive...@chromium.org>
          Gerrit-Comment-Date: Fri, 17 Oct 2025 23:30:22 +0000
          satisfied_requirement
          unsatisfied_requirement
          open
          diffy

          Andrew Brown (Gerrit)

          unread,
          Oct 18, 2025, 1:31:25 AMOct 18
          to Andrea Orru, Kelvin Jiang, Oliver Dunk, Alex Moshchuk, Takashi Toyoshima, Adam Rice, Giovanni Ortuno Urquidi, Clark DuVall, Devlin Cronin, Chromium Metrics Reviews, Takashi Nakayama, Min Qin, Hiroki Nakagawa, James Maclean, James Su, AyeAye, Chromium LUCI CQ, chromium...@chromium.org, Nate Chapin, asvitkine...@chromium.org, devtools-re...@chromium.org, extension...@chromium.org, chromium-a...@chromium.org, mkwst+w...@chromium.org, horo+...@chromium.org, shimazu+se...@chromium.org, kinuko+ser...@chromium.org, servicewor...@chromium.org, antoniosarto...@chromium.org, kenjibah...@chromium.org, jsbell+ser...@chromium.org, arthursonzog...@chromium.org, blink-revie...@chromium.org, alexmo...@chromium.org, yhanad...@chromium.org, tranbaod...@chromium.org, nona+...@chromium.org, creis...@chromium.org, shuche...@chromium.org, jbauma...@chromium.org, navigation...@chromium.org, keithle...@chromium.org, blink-...@chromium.org, blundell+...@chromium.org, gavinp...@chromium.org, kinuko...@chromium.org, loading-re...@chromium.org, loading...@chromium.org, net-r...@chromium.org, network-ser...@chromium.org
          Attention needed from Andrea Orru, Kelvin Jiang and Oliver Dunk

          Andrew Brown added 1 comment

          Patchset-level comments
          File-level comment, Patchset 51 (Latest):
          Andrew Brown . unresolved

          It looks like for some reason something was wrong with shard 2 on android-desktop-x64-rel? If I pull up the logs, I can see 52 tests being run on that shard, and there are 52 corresponding `[ RUN ]` messages in the logs. However, there's also 52 corresponding `[ PASSED ]` messages in the same log, so it looks like the actual chromium code is fine?


          Is it possible that shard just has something wrong with the instrumentation scripts that surround the test had a bug that caused timeouts?


          I'm wary because the failing shard definitely seemed to be doing a bunch of extensions-related stuff, which is within my area. But the logs just don't make sense to me; if all 52 tests printed `[ PASSED ]` then what was actually timing out?

          Open in Gerrit

          Related details

          Attention is currently required from:
          • Andrea Orru
          • Kelvin Jiang
          • Oliver Dunk
          Gerrit-Attention: Oliver Dunk <olive...@chromium.org>
          Gerrit-Attention: Andrea Orru <andre...@chromium.org>
          Gerrit-Comment-Date: Sat, 18 Oct 2025 05:30:48 +0000
          Gerrit-HasComments: Yes
          Gerrit-Has-Labels: No
          satisfied_requirement
          unsatisfied_requirement
          open
          diffy

          Oliver Dunk (Gerrit)

          unread,
          Oct 20, 2025, 4:30:36 AMOct 20
          to Andrew Brown, Andrea Orru, Kelvin Jiang, Alex Moshchuk, Takashi Toyoshima, Adam Rice, Giovanni Ortuno Urquidi, Clark DuVall, Devlin Cronin, Chromium Metrics Reviews, Takashi Nakayama, Min Qin, Hiroki Nakagawa, James Maclean, James Su, AyeAye, Chromium LUCI CQ, chromium...@chromium.org, Nate Chapin, asvitkine...@chromium.org, devtools-re...@chromium.org, extension...@chromium.org, chromium-a...@chromium.org, mkwst+w...@chromium.org, horo+...@chromium.org, shimazu+se...@chromium.org, kinuko+ser...@chromium.org, servicewor...@chromium.org, antoniosarto...@chromium.org, kenjibah...@chromium.org, jsbell+ser...@chromium.org, arthursonzog...@chromium.org, blink-revie...@chromium.org, alexmo...@chromium.org, yhanad...@chromium.org, tranbaod...@chromium.org, nona+...@chromium.org, creis...@chromium.org, shuche...@chromium.org, jbauma...@chromium.org, navigation...@chromium.org, keithle...@chromium.org, blink-...@chromium.org, blundell+...@chromium.org, gavinp...@chromium.org, kinuko...@chromium.org, loading-re...@chromium.org, loading...@chromium.org, net-r...@chromium.org, network-ser...@chromium.org
          Attention needed from Andrea Orru and Kelvin Jiang

          Oliver Dunk added 1 comment

          File chrome/browser/extensions/api/downloads/downloads_api_browsertest.cc
          Devlin Cronin . resolved

          If there's no visible API change for extensions, is this change still needed?

          Andrew Brown

          Hm, true, I guess there technically still is a "visible API change" here, but that's because chromium currently doesn't follow the fetch spec w/r/t User-Agent.

          The extensions Downloads API docs say that additional headers can be provided for the request if XMLHttpRequest allows it. Until now, XMLHttpRequest couldn't set User-Agents, but that's the core bug we're fixing. Technically I guess we're not actually changing the documented behaviour, because the docs rely on XMLHttpRequest, and we're just changing that.

          Do we need an announcement/chromestatus.com entry/whatever for this change, then? I'm not super familiar with the actual "release process" for how this code change actually ships, so there might be steps there that I'm missing.

          Devlin Cronin

          I think I'm okay with this, but I'll defer to @olive...@chromium.org on if he thinks this needs a separate announcement or discussion in the WECG.

          Oliver Dunk

          I don't think this needs separate discussion / an announcement. Thanks for the heads up and checking regardless.

          Open in Gerrit

          Related details

          Attention is currently required from:
          • Andrea Orru
          • Kelvin Jiang
          Gerrit-Attention: Andrea Orru <andre...@chromium.org>
          Gerrit-Comment-Date: Mon, 20 Oct 2025 08:30:21 +0000
          Gerrit-HasComments: Yes
          Gerrit-Has-Labels: No
          satisfied_requirement
          unsatisfied_requirement
          open
          diffy

          Andrea Orru (Gerrit)

          unread,
          Oct 20, 2025, 6:13:08 PMOct 20
          to Andrew Brown, Kelvin Jiang, Oliver Dunk, Alex Moshchuk, Takashi Toyoshima, Adam Rice, Giovanni Ortuno Urquidi, Clark DuVall, Devlin Cronin, Chromium Metrics Reviews, Takashi Nakayama, Min Qin, Hiroki Nakagawa, James Maclean, James Su, AyeAye, Chromium LUCI CQ, chromium...@chromium.org, Nate Chapin, asvitkine...@chromium.org, devtools-re...@chromium.org, extension...@chromium.org, chromium-a...@chromium.org, mkwst+w...@chromium.org, horo+...@chromium.org, shimazu+se...@chromium.org, kinuko+ser...@chromium.org, servicewor...@chromium.org, antoniosarto...@chromium.org, kenjibah...@chromium.org, jsbell+ser...@chromium.org, arthursonzog...@chromium.org, blink-revie...@chromium.org, alexmo...@chromium.org, yhanad...@chromium.org, tranbaod...@chromium.org, nona+...@chromium.org, creis...@chromium.org, shuche...@chromium.org, jbauma...@chromium.org, navigation...@chromium.org, keithle...@chromium.org, blink-...@chromium.org, blundell+...@chromium.org, gavinp...@chromium.org, kinuko...@chromium.org, loading-re...@chromium.org, loading...@chromium.org, net-r...@chromium.org, network-ser...@chromium.org
          Attention needed from Andrew Brown and Kelvin Jiang

          Andrea Orru added 2 comments

          Patchset-level comments
          File-level comment, Patchset 48:
          Andrew Brown . resolved

          Oh also, could someone please put this through the trybots again for me?

          There's a couple of new `DCHECK()`s that I'm not 100% confident in, so it'd be good to send it through the bots to be sure.

          Andrea Orru

          Done

          Andrew Brown . resolved

          It looks like for some reason something was wrong with shard 2 on android-desktop-x64-rel? If I pull up the logs, I can see 52 tests being run on that shard, and there are 52 corresponding `[ RUN ]` messages in the logs. However, there's also 52 corresponding `[ PASSED ]` messages in the same log, so it looks like the actual chromium code is fine?


          Is it possible that shard just has something wrong with the instrumentation scripts that surround the test had a bug that caused timeouts?


          I'm wary because the failing shard definitely seemed to be doing a bunch of extensions-related stuff, which is within my area. But the logs just don't make sense to me; if all 52 tests printed `[ PASSED ]` then what was actually timing out?

          Andrea Orru

          Done

          Open in Gerrit

          Related details

          Attention is currently required from:
          • Andrew Brown
          • Kelvin Jiang
          Gerrit-Attention: Andrew Brown <m...@ajbrown.au>
          Gerrit-Comment-Date: Mon, 20 Oct 2025 22:12:57 +0000
          Gerrit-HasComments: Yes
          Gerrit-Has-Labels: No
          Comment-In-Reply-To: Andrew Brown <m...@ajbrown.au>
          satisfied_requirement
          unsatisfied_requirement
          open
          diffy

          Andrea Orru (Gerrit)

          unread,
          Oct 20, 2025, 6:23:56 PMOct 20
          to Andrew Brown, Kelvin Jiang, Oliver Dunk, Alex Moshchuk, Takashi Toyoshima, Adam Rice, Giovanni Ortuno Urquidi, Clark DuVall, Devlin Cronin, Chromium Metrics Reviews, Takashi Nakayama, Min Qin, Hiroki Nakagawa, James Maclean, James Su, AyeAye, Chromium LUCI CQ, chromium...@chromium.org, Nate Chapin, asvitkine...@chromium.org, devtools-re...@chromium.org, extension...@chromium.org, chromium-a...@chromium.org, mkwst+w...@chromium.org, horo+...@chromium.org, shimazu+se...@chromium.org, kinuko+ser...@chromium.org, servicewor...@chromium.org, antoniosarto...@chromium.org, kenjibah...@chromium.org, jsbell+ser...@chromium.org, arthursonzog...@chromium.org, blink-revie...@chromium.org, alexmo...@chromium.org, yhanad...@chromium.org, tranbaod...@chromium.org, nona+...@chromium.org, creis...@chromium.org, shuche...@chromium.org, jbauma...@chromium.org, navigation...@chromium.org, keithle...@chromium.org, blink-...@chromium.org, blundell+...@chromium.org, gavinp...@chromium.org, kinuko...@chromium.org, loading-re...@chromium.org, loading...@chromium.org, net-r...@chromium.org, network-ser...@chromium.org
          Attention needed from Andrew Brown and Kelvin Jiang

          Andrea Orru added 2 comments

          File extensions/browser/api/web_request/web_request_api_helpers.cc
          Line 1193, Patchset 49: DCHECK(extension_visible_request_headers);
          Andrea Orru . resolved

          Elsewhere you are passing `nullptr` to `OnBeforeSendHeaders` for this parameter. Are you sure we can't end up with a `nullptr` here?

          Andrea Orru

          Looks from the failed tests that we can.

          Andrew Brown

          Yeah, I spotted dcheck failures from the websocket tests.


          My implementation that passed, 2 patchsets ago, handled this by checking `extension_visible_request_headers` every single time it was going to be used, but I figured that's a lot of extra code, so worth switching to dcheck to see if that might not be necessary. (And it wouldn't have been a problem if we'd stayed with the "just pass request headers twice" approach for websockets & webtransport, but I guess that might have had other issues if every action actually was executed twice.)


          Anyway, it seems like we do need to check everywhere. I'll revert that change and reupload, hopefully in the next 15 min or so.

          Andrew Brown

          Hopefully done but needs a new dry run.
          ...so much for 15 minutes, lol.

          Andrea Orru

          Done

          File extensions/browser/api/web_request/web_request_proxying_websocket.cc
          Line 87, Patchset 49: /*extension_visible_headers=*/request.headers)),
          Andrea Orru . resolved

          Are these the extension visible headers? These haven't been merged? Or am I missing something?

          Andrew Brown

          Websocket requests are immune to CORS (at least by my reading of https://developer.mozilla.org/en-US/docs/Web/HTTP/Guides/CORS). This is a huge relief because otherwise I would need to manage their own completely different way of passing User-Agents down through mojo -- see `WebRequestProxyingWebSocket::StartProxying()`, where User-Agent is actually added to the headers there.

          So AFAICT they don't actually need any special `extension_visible_headers` behaviour, because they're safe to put all headers onto the ordinary `headers`, including User-Agent, which they already do, without triggering CORS stuff later on.

          I've added a comment to explain this -- wording suggestions welcome to make sure it's clear.

          Andrew Brown

          Well, I guess, not immune to CORS altogether, but immune to the `access-control-allow-headers` part of CORS, which is the bit I care about here.

          Andrea Orru

          Thanks for adding the comment.

          Gerrit-Comment-Date: Mon, 20 Oct 2025 22:23:43 +0000
          Gerrit-HasComments: Yes
          Gerrit-Has-Labels: No
          Comment-In-Reply-To: Andrew Brown <m...@ajbrown.au>
          Comment-In-Reply-To: Andrea Orru <andre...@chromium.org>
          satisfied_requirement
          unsatisfied_requirement
          open
          diffy

          Andrea Orru (Gerrit)

          unread,
          Oct 20, 2025, 6:28:04 PMOct 20
          to Andrew Brown, Kelvin Jiang, Oliver Dunk, Alex Moshchuk, Takashi Toyoshima, Adam Rice, Giovanni Ortuno Urquidi, Clark DuVall, Devlin Cronin, Chromium Metrics Reviews, Takashi Nakayama, Min Qin, Hiroki Nakagawa, James Maclean, James Su, AyeAye, Chromium LUCI CQ, chromium...@chromium.org, Nate Chapin, asvitkine...@chromium.org, devtools-re...@chromium.org, extension...@chromium.org, chromium-a...@chromium.org, mkwst+w...@chromium.org, horo+...@chromium.org, shimazu+se...@chromium.org, kinuko+ser...@chromium.org, servicewor...@chromium.org, antoniosarto...@chromium.org, kenjibah...@chromium.org, jsbell+ser...@chromium.org, arthursonzog...@chromium.org, blink-revie...@chromium.org, alexmo...@chromium.org, yhanad...@chromium.org, tranbaod...@chromium.org, nona+...@chromium.org, creis...@chromium.org, shuche...@chromium.org, jbauma...@chromium.org, navigation...@chromium.org, keithle...@chromium.org, blink-...@chromium.org, blundell+...@chromium.org, gavinp...@chromium.org, kinuko...@chromium.org, loading-re...@chromium.org, loading...@chromium.org, net-r...@chromium.org, network-ser...@chromium.org
          Attention needed from Andrew Brown and Kelvin Jiang

          Andrea Orru added 1 comment

          File extensions/browser/api/web_request/web_request_proxying_url_loader_factory.cc
          Line 886, Patchset 51 (Latest): std::optional<std::string> extension_modified_user_agent =
          Andrea Orru . unresolved

          Uhm... How do you know this header was actually set by an extension and not by arbitrary JavaScript?

          Gerrit-Comment-Date: Mon, 20 Oct 2025 22:27:53 +0000
          Gerrit-HasComments: Yes
          Gerrit-Has-Labels: No
          satisfied_requirement
          unsatisfied_requirement
          open
          diffy

          Andrew Brown (Gerrit)

          unread,
          Oct 20, 2025, 6:44:02 PMOct 20
          to Andrea Orru, Kelvin Jiang, Oliver Dunk, Alex Moshchuk, Takashi Toyoshima, Adam Rice, Giovanni Ortuno Urquidi, Clark DuVall, Devlin Cronin, Chromium Metrics Reviews, Takashi Nakayama, Min Qin, Hiroki Nakagawa, James Maclean, James Su, AyeAye, Chromium LUCI CQ, chromium...@chromium.org, Nate Chapin, asvitkine...@chromium.org, devtools-re...@chromium.org, extension...@chromium.org, chromium-a...@chromium.org, mkwst+w...@chromium.org, horo+...@chromium.org, shimazu+se...@chromium.org, kinuko+ser...@chromium.org, servicewor...@chromium.org, antoniosarto...@chromium.org, kenjibah...@chromium.org, jsbell+ser...@chromium.org, arthursonzog...@chromium.org, blink-revie...@chromium.org, alexmo...@chromium.org, yhanad...@chromium.org, tranbaod...@chromium.org, nona+...@chromium.org, creis...@chromium.org, shuche...@chromium.org, jbauma...@chromium.org, navigation...@chromium.org, keithle...@chromium.org, blink-...@chromium.org, blundell+...@chromium.org, gavinp...@chromium.org, kinuko...@chromium.org, loading-re...@chromium.org, loading...@chromium.org, net-r...@chromium.org, network-ser...@chromium.org
          Attention needed from Andrea Orru and Kelvin Jiang

          Andrew Brown added 2 comments

          File extensions/browser/api/web_request/web_request_proxying_url_loader_factory.cc
          Line 778, Patchset 49: request_.content_user_agent);
          Andrew Brown . resolved

          I re-added this because I think it was what caused the test failures. I have no idea how or why, but I was able to pass header-modifying tests locally with this line added, and they failed without it.

          Still needs another trybot run to confirm.

          Andrew Brown

          Looks like this was the cause of the test failures, yeah.

          Line 886, Patchset 51 (Latest): std::optional<std::string> extension_modified_user_agent =
          Andrea Orru . unresolved

          Uhm... How do you know this header was actually set by an extension and not by arbitrary JavaScript?

          Andrew Brown

          Ohhhhh. D'oh, yeah, that code is wrong.

          Practically speaking, this depends on whether extensions-given values are CORS exempt (which I never specifically got an answer for, though I strongly suspect they are).

          If they're not I can remove this and go back to the easy approach, but if they are then I need to go back to the drawing board and devise another way to track User-Agent modifications across the webRequest api.

          Open in Gerrit

          Related details

          Attention is currently required from:
          • Andrea Orru
          • Kelvin Jiang
          Gerrit-Attention: Andrea Orru <andre...@chromium.org>
          Gerrit-Comment-Date: Mon, 20 Oct 2025 22:43:24 +0000
          Gerrit-HasComments: Yes
          Gerrit-Has-Labels: No
          satisfied_requirement
          unsatisfied_requirement
          open
          diffy

          Andrew Brown (Gerrit)

          unread,
          Oct 21, 2025, 5:21:20 AMOct 21
          to Andrea Orru, Kelvin Jiang, Oliver Dunk, Alex Moshchuk, Takashi Toyoshima, Adam Rice, Giovanni Ortuno Urquidi, Clark DuVall, Devlin Cronin, Chromium Metrics Reviews, Takashi Nakayama, Min Qin, Hiroki Nakagawa, James Maclean, James Su, AyeAye, Chromium LUCI CQ, chromium...@chromium.org, Nate Chapin, asvitkine...@chromium.org, devtools-re...@chromium.org, extension...@chromium.org, chromium-a...@chromium.org, mkwst+w...@chromium.org, horo+...@chromium.org, shimazu+se...@chromium.org, kinuko+ser...@chromium.org, servicewor...@chromium.org, antoniosarto...@chromium.org, kenjibah...@chromium.org, jsbell+ser...@chromium.org, arthursonzog...@chromium.org, blink-revie...@chromium.org, alexmo...@chromium.org, yhanad...@chromium.org, tranbaod...@chromium.org, nona+...@chromium.org, creis...@chromium.org, shuche...@chromium.org, jbauma...@chromium.org, navigation...@chromium.org, keithle...@chromium.org, blink-...@chromium.org, blundell+...@chromium.org, gavinp...@chromium.org, kinuko...@chromium.org, loading-re...@chromium.org, loading...@chromium.org, net-r...@chromium.org, network-ser...@chromium.org
          Attention needed from Andrea Orru and Kelvin Jiang

          Andrew Brown added 7 comments

          Patchset-level comments
          File-level comment, Patchset 44:
          Andrew Brown . resolved

          Well, I guess now I need +1's from all the different owners -- re-pinged Takashi, as I feel like yourself and Adam should be the first eyes over it, given this is a primarily network-focused change.

          Andrew Brown

          Sorry to be a pest, but re-pinging, as it's been a week.

          I will need reviews from both of you as Network People, eventually, in order to cover all the files (plus this is a complex & large change that can't hurt to have more eyes) so please dw about duplicate reviews. (quoting the "contributing to chromium" guide)

          Takashi Toyoshima

          Sorry for overlooking this pings. It still LGTM.

          Takashi Toyoshima

          By the way, I think you still need a reviewer's approval on Extensions related directory.

          Andrew Brown

          All good, appreciate the vote :)

          Pinging Devlin now for extensions approval -- happy to go bother others if there's specific internal complexity to be looked at (there is a bit of weird stuff in there), but there's no visible API change for extensions anymore.

          Devlin Cronin

          Thanks, Andrew! If there's no API change, I'm okay with this at a high level (though see the one comment I added). I've added @kelvi...@chromium.org for a more thorough review, as an owner of the webRequest API.

          Andrew Brown

          Done

          File-level comment, Patchset 46:
          Kelvin Jiang . resolved

          I have a lot of questions and I might ask more in another pass:

          With respect to extensions that can modify network requests, what happens here?

          1. Before the request is sent, compute the value of `content_user_agent` which will be added to headers later?
          2. Request headers are set, and modifications from extensions are made?
          3. CORS checks happen but don't merge headers yet because `content_user_agent` is exempt?
          4. Now merge `content_user_agent` into headers?

          Andrew Brown

          No worries, thanks for your review! Happy to answer questions, fire away. This might be too granular of a breakdown, or there might be more aspects to ask about, but this is how I'm conceptualising what happens:

          1. Start with a `network::ResourceRequest` with `headers`, `cors_exempt_headers`, and `content_user_agent` which comes from DevTools or FetchContext. (All three of these must be kept separate until after CORS checks.)
          2. Extensions code receives this request.
          3. Extensions code has to invent the `script_exposed_headers`, which is the headers that will be *really* sent on this request, after CORS. This has to be a separate object because again we can't merge them all into the `headers` until after CORS.
          4. Extensions code tells a running extension that the `script_exposed_headers` are the headers for "this request", so the extension sees the "real" final state of the request headers, including `content_user_agent`.
          5. All extensions modifications are applied to *both* the real `headers` and the user-visible `script_exposed_headers`. This keeps the `script_exposed_headers` that the user can see in-sync with the real `headers` but enables us to make sure they stay separate.
          6. After all extensions have done modifications/looked at things/etc, toss away the `script_exposed_headers`. We go back to having a `network::ResourceRequest` with `headers`, `cors_exempt_headers`, and `content_user_agent`, all separate, but with all the extensions modifications applied to `headers` as requested.
          7. CORS checks happen on `headers`. A CORS preflight may be sent for User-Agent here if the request has a User-Agent specified on the `headers`, as it must have come from an untrusted source.
          8. After CORS, if the preflight said it's fine, then we can use the `headers` User-Agent. If it's not fine, or if there wasn't one, we can merge the `content_user_agent` onto the headers to actually make the request.

          Andrew Brown

          Done

          File-level comment, Patchset 52 (Latest):
          Andrew Brown . unresolved

          Alright, well. Two months of trying to understand webRequest code and I think this approach should actually be much nicer (and is also ~200 lines shorter). Sorry for all the work you put in to understand the original system :(


          The new idea is just that we can put the `content_user_agent` onto the headers, and then right at the end, before we actually `CreateLoaderAndStart()` to pass the request back to the network, we remove the header again. This is also substantially less involved of a change, because we only do fiddling of the User-Agent and only when necessary.


          The only mildly dodgy thing is I had to add a `mutable bool` to `WebRequestInfo` to track whether the User-Agent was modified by an extension.


          I've run this through a few bits of `browser_tests` and `extensions_unittests` locally but a full dryrun might still pick up other issues.

          File extensions/browser/api/web_request/extension_web_request_event_router.h
          Line 191, Patchset 48: net::HttpRequestHeaders* request_headers,
          net::HttpRequestHeaders* exposed_headers);
          Kelvin Jiang . unresolved

          What do you think is cleaner and more readable? having two header objects like now or wrapping these in a struct since I see many places where these two are side by side? Also we can add struct methods that when called once, will modify both set of headers!

          Also, I assume we need to use a `net::HttpRequestHeaders*` for headers that need to skip CORS and get applied afterwards because extensions should be able to modify these?

          Andrew Brown

          Hmm, not sure. I don't think there is much benefit to combining them because most functions will still need to do things with one or the other individually (i.e. it's not like we do `foo(both)` which calls `bar(both)` which calls `baz(both)` that splits them up, where `foo` and `bar` never need to go inside the `both` struct -- basically every level will need to go inside the `both` struct. The only super-relevant benefit will be that last level doesn't need to do two `headers->SetHeader(key, val)`, it can do a special `SetBoth(both, key, val)`, but I think that's maybe less clear than just doing two SetHeaders. Also, there are a lot of places (e.g. WebRequestInfo) that only have the `exposed_headers` still, and implicitly receive the `headers` via access to the ResourceRequest or similar. So none of those places would benefit from some sort of `TwoHeaders` struct.

          If you would prefer to combine the two into some struct I'm happy to do that, but my thought is probably that keeping them separate looks better. You're the owner who'll have to deal with things long-term though, so please override me if you want.

          ---

          I'm not sure what you mean about headers that skip CORS and get applied afterwards. Are you talking about cases where the extensions modifies "Not-Cors-Exempt: x" to be "Not-Cors-Exempt: y", and this modification would go onto `headers` and cause a CORS check?

          This doesn't need special handling (as of right now) because these headers are all on the list in `net/http/http_util.cc`, and headers from that list are assumed to always be CORS-safe no matter where they are. This is because javascript APIs do not allow setting values for any of those headers, so if they have a value set, it must have come from somewhere else. This CL will not change any of that behaviour, except for User-Agent.

          Does this mean, then, that extensions-set User-Agent values should be exempt from CORS checks? If so, we need special logic to ensure that if extensions modifies User-Agent, that change is reflected in the `content_user_agent` value, not just set onto `headers`, because values of `user_agent` on the `headers` will trigger CORS.

          Andrew Brown

          I've assumed an extensions-set User-Agent is immune to CORS, as that's the current behaviour.

          File extensions/browser/api/web_request/extension_web_request_event_router.cc
          Line 592, Patchset 46: // User-Agent.
          Kelvin Jiang . resolved

          by this you mean the CORS exempt user agent that should be merged into request headers later?

          Andrew Brown

          If the headers already have a User-Agent it will be that, e.g. if this request comes from someone doing `fetch('foo.com' {headers: {"User-Agent": "baz"}});`, then the exposed_headers will have "User-Agent: baz". The content_user_agent shouldn't override any other User-Agent.

          So it's not guaranteed that these headers have the CORS exempt User-Agent, just that they have *a* User-Agent.

          Andrew Brown

          I've updated this comment, hopefully it's clearer now?

          Andrew Brown

          Done

          File extensions/browser/api/web_request/web_request_proxying_url_loader_factory.h
          Line 220, Patchset 46: // that has to happen in the network stack (after CORS checks).
          Kelvin Jiang . resolved

          dumb question: merging before would fail CORS checks?

          Andrew Brown

          Unfortunately yeah, because this all happens before the CORS checks, if we put a User-Agent on the `headers`, it triggers a CORS preflight. (Currently CORS ignores "User-Agent" because it's on the "banned" list in `net/http/http_util.cc` but this is the actual bug we're fixing -- it shouldn't be there.)

          Lots of websites aren't expecting to receive a CORS preflight for "User-Agent" (because it's already on every request ever!), so they tell CORS "no User-Agent please" and then the request fails when it shouldn't.

          Andrew Brown

          Done

          File extensions/browser/api/web_request/web_request_proxying_url_loader_factory.cc
          Line 886, Patchset 51: std::optional<std::string> extension_modified_user_agent =
          Andrea Orru . resolved

          Uhm... How do you know this header was actually set by an extension and not by arbitrary JavaScript?

          Andrew Brown

          Ohhhhh. D'oh, yeah, that code is wrong.

          Practically speaking, this depends on whether extensions-given values are CORS exempt (which I never specifically got an answer for, though I strongly suspect they are).

          If they're not I can remove this and go back to the easy approach, but if they are then I need to go back to the drawing board and devise another way to track User-Agent modifications across the webRequest api.

          Andrew Brown

          "back to the drawing board" indeed

          Open in Gerrit

          Related details

          Attention is currently required from:
          • Andrea Orru
          • Kelvin Jiang
          Submit Requirements:
          • requirement satisfiedCode-Coverage
          • requirement is not satisfiedCode-Owners
          • requirement is not satisfiedCode-Review
          • requirement is not satisfiedNo-Unresolved-Comments
          • requirement is not satisfiedReview-Enforcement
          Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
          Gerrit-MessageType: comment
          Gerrit-Project: chromium/src
          Gerrit-Branch: main
          Gerrit-Change-Id: Icf56620f99f371ea2f128e6a3194d6096b0d62cd
          Gerrit-Change-Number: 5273743
          Gerrit-PatchSet: 52
          Gerrit-Owner: Andrew Brown <m...@ajbrown.au>
          Gerrit-Reviewer: Adam Rice <ri...@chromium.org>
          Gerrit-Reviewer: Alex Moshchuk <ale...@chromium.org>
          Gerrit-Reviewer: Andrea Orru <andre...@chromium.org>
          Gerrit-Reviewer: Andrew Brown <m...@ajbrown.au>
          Gerrit-Reviewer: Devlin Cronin <rdevlin...@chromium.org>
          Gerrit-Reviewer: Kelvin Jiang <kelvi...@chromium.org>
          Gerrit-Reviewer: Min Qin <qin...@chromium.org>
          Gerrit-Reviewer: Oliver Dunk <olive...@chromium.org>
          Gerrit-Reviewer: Takashi Toyoshima <toyo...@chromium.org>
          Gerrit-CC: Chromium Metrics Reviews <chromium-met...@google.com>
          Gerrit-CC: Clark DuVall <cdu...@chromium.org>
          Gerrit-CC: Giovanni Ortuno Urquidi <ort...@chromium.org>
          Gerrit-CC: Hiroki Nakagawa <nhi...@chromium.org>
          Gerrit-CC: James Maclean <wjma...@chromium.org>
          Gerrit-CC: James Su <su...@chromium.org>
          Gerrit-CC: Name of user not set #4416269
          Gerrit-CC: Nate Chapin <jap...@chromium.org>
          Gerrit-CC: Takashi Nakayama <tn...@chromium.org>
          Gerrit-Attention: Kelvin Jiang <kelvi...@chromium.org>
          Gerrit-Attention: Andrea Orru <andre...@chromium.org>
          Gerrit-Comment-Date: Tue, 21 Oct 2025 09:20:48 +0000
          Gerrit-HasComments: Yes
          Gerrit-Has-Labels: No
          Comment-In-Reply-To: Devlin Cronin <rdevlin...@chromium.org>
          Comment-In-Reply-To: Takashi Toyoshima <toyo...@chromium.org>
          Comment-In-Reply-To: Kelvin Jiang <kelvi...@chromium.org>
          satisfied_requirement
          unsatisfied_requirement
          open
          diffy

          Kelvin Jiang (Gerrit)

          unread,
          Oct 21, 2025, 7:34:31 PMOct 21
          to Andrew Brown, Andrea Orru, Oliver Dunk, Alex Moshchuk, Takashi Toyoshima, Adam Rice, Clark DuVall, Devlin Cronin, Chromium Metrics Reviews, Takashi Nakayama, Min Qin, Hiroki Nakagawa, James Maclean, James Su, AyeAye, Chromium LUCI CQ, chromium...@chromium.org, Nate Chapin, asvitkine...@chromium.org, devtools-re...@chromium.org, extension...@chromium.org, chromium-a...@chromium.org, mkwst+w...@chromium.org, horo+...@chromium.org, shimazu+se...@chromium.org, kinuko+ser...@chromium.org, servicewor...@chromium.org, antoniosarto...@chromium.org, kenjibah...@chromium.org, jsbell+ser...@chromium.org, arthursonzog...@chromium.org, blink-revie...@chromium.org, alexmo...@chromium.org, yhanad...@chromium.org, tranbaod...@chromium.org, nona+...@chromium.org, creis...@chromium.org, shuche...@chromium.org, jbauma...@chromium.org, navigation...@chromium.org, keithle...@chromium.org, blink-...@chromium.org, blundell+...@chromium.org, gavinp...@chromium.org, kinuko...@chromium.org, loading-re...@chromium.org, loading...@chromium.org, net-r...@chromium.org, network-ser...@chromium.org
          Attention needed from Andrea Orru and Andrew Brown

          Kelvin Jiang added 4 comments

          Patchset-level comments
          Andrew Brown . unresolved

          Alright, well. Two months of trying to understand webRequest code and I think this approach should actually be much nicer (and is also ~200 lines shorter). Sorry for all the work you put in to understand the original system :(


          The new idea is just that we can put the `content_user_agent` onto the headers, and then right at the end, before we actually `CreateLoaderAndStart()` to pass the request back to the network, we remove the header again. This is also substantially less involved of a change, because we only do fiddling of the User-Agent and only when necessary.


          The only mildly dodgy thing is I had to add a `mutable bool` to `WebRequestInfo` to track whether the User-Agent was modified by an extension.


          I've run this through a few bits of `browser_tests` and `extensions_unittests` locally but a full dryrun might still pick up other issues.

          Kelvin Jiang

          So: let the extension modify the content user agent as needed but remove it after the request goes through extensions WebRequest to make sure we don't trigger a CORS preflight unintentionally?

          I assume this should work the same (pipe the user agent down with the request but only apply it when the time is right) if there are no webRequest extensions that would modify the request?

          Kelvin Jiang . resolved

          Can we add a WebRequest browser test for this? i.e. make sure that an extension can modify the user-agent but it won't cause a CORS preflght?

          File extensions/browser/api/web_request/web_request_proxying_url_loader_factory.h
          Line 251, Patchset 52 (Latest): // `request_.content_user_agent` -- if so, it has to be cleared before the
          Kelvin Jiang . unresolved

          optional nit: pipes for consistency with `|has_any_extra_headers_listeners_|` below

          Line 250, Patchset 52 (Latest): // Whether this request had it's User-Agent temporarily set based on the
          Kelvin Jiang . unresolved

          its

          Open in Gerrit

          Related details

          Attention is currently required from:
          • Andrea Orru
          • Andrew Brown
          Gerrit-CC: Hiroki Nakagawa <nhi...@chromium.org>
          Gerrit-CC: James Maclean <wjma...@chromium.org>
          Gerrit-CC: James Su <su...@chromium.org>
          Gerrit-CC: Name of user not set #4416269
          Gerrit-CC: Nate Chapin <jap...@chromium.org>
          Gerrit-CC: Takashi Nakayama <tn...@chromium.org>
          Gerrit-Attention: Andrew Brown <m...@ajbrown.au>
          Gerrit-Attention: Andrea Orru <andre...@chromium.org>
          Gerrit-Comment-Date: Tue, 21 Oct 2025 23:34:20 +0000
          Gerrit-HasComments: Yes
          Gerrit-Has-Labels: No
          Comment-In-Reply-To: Andrew Brown <m...@ajbrown.au>
          satisfied_requirement
          unsatisfied_requirement
          open
          diffy

          Andrew Brown (Gerrit)

          unread,
          Oct 21, 2025, 8:15:45 PMOct 21
          to Kelvin Jiang, Andrea Orru, Oliver Dunk, Alex Moshchuk, Takashi Toyoshima, Adam Rice, Clark DuVall, Devlin Cronin, Chromium Metrics Reviews, Takashi Nakayama, Min Qin, Hiroki Nakagawa, James Maclean, James Su, AyeAye, Chromium LUCI CQ, chromium...@chromium.org, Nate Chapin, asvitkine...@chromium.org, devtools-re...@chromium.org, extension...@chromium.org, chromium-a...@chromium.org, mkwst+w...@chromium.org, horo+...@chromium.org, shimazu+se...@chromium.org, kinuko+ser...@chromium.org, servicewor...@chromium.org, antoniosarto...@chromium.org, kenjibah...@chromium.org, jsbell+ser...@chromium.org, arthursonzog...@chromium.org, blink-revie...@chromium.org, alexmo...@chromium.org, yhanad...@chromium.org, tranbaod...@chromium.org, nona+...@chromium.org, creis...@chromium.org, shuche...@chromium.org, jbauma...@chromium.org, navigation...@chromium.org, keithle...@chromium.org, blink-...@chromium.org, blundell+...@chromium.org, gavinp...@chromium.org, kinuko...@chromium.org, loading-re...@chromium.org, loading...@chromium.org, net-r...@chromium.org, network-ser...@chromium.org
          Attention needed from Andrea Orru and Kelvin Jiang

          Andrew Brown added 2 comments

          Patchset-level comments
          Andrew Brown . unresolved

          Alright, well. Two months of trying to understand webRequest code and I think this approach should actually be much nicer (and is also ~200 lines shorter). Sorry for all the work you put in to understand the original system :(


          The new idea is just that we can put the `content_user_agent` onto the headers, and then right at the end, before we actually `CreateLoaderAndStart()` to pass the request back to the network, we remove the header again. This is also substantially less involved of a change, because we only do fiddling of the User-Agent and only when necessary.


          The only mildly dodgy thing is I had to add a `mutable bool` to `WebRequestInfo` to track whether the User-Agent was modified by an extension.


          I've run this through a few bits of `browser_tests` and `extensions_unittests` locally but a full dryrun might still pick up other issues.

          Kelvin Jiang

          So: let the extension modify the content user agent as needed but remove it after the request goes through extensions WebRequest to make sure we don't trigger a CORS preflight unintentionally?

          I assume this should work the same (pipe the user agent down with the request but only apply it when the time is right) if there are no webRequest extensions that would modify the request?

          Andrew Brown

          Yeah pretty much. Move the `content_user_agent` over to the `headers` for extensions to modify, then move it back to the `content_user_agent` if needed.


          If there are no extensions then this code doesn't trigger at all (I think?).

          If there are extensions, but they don't modify the headers, then in `web_request_proxying_url_loader_factory.cc` line 767, we add the headers and set our `user_agent_added_for_extensions_` flag, then on line 886 the flag will trigger removal of the User-Agent again. The other flag for "extensions have modified these headers" will never be set so we won't move the value back over, we'll just get rid of it.


          At the end, we should only have a `User-Agent` in the `headers` if it was there to begin with (i.e. `fetch(... {headers: {"user-agent": "foo"}});`), *and* no extension changed this value.

          Andrew Brown . unresolved

          Test failures look like `ContinueToStartRequest` is already "too late" to avoid CORS checks, I'll look for a new spot to move the User-Agent back to `content_user_agent`.

          Open in Gerrit

          Related details

          Attention is currently required from:
          • Andrea Orru
          • Kelvin Jiang
          Gerrit-Attention: Kelvin Jiang <kelvi...@chromium.org>
          Gerrit-Attention: Andrea Orru <andre...@chromium.org>
          Gerrit-Comment-Date: Wed, 22 Oct 2025 00:15:07 +0000
          Gerrit-HasComments: Yes
          Gerrit-Has-Labels: No
          satisfied_requirement
          unsatisfied_requirement
          open
          diffy

          Andrew Brown (Gerrit)

          unread,
          Oct 21, 2025, 9:53:43 PMOct 21
          to Kelvin Jiang, Andrea Orru, Oliver Dunk, Alex Moshchuk, Takashi Toyoshima, Adam Rice, Clark DuVall, Devlin Cronin, Chromium Metrics Reviews, Takashi Nakayama, Min Qin, Hiroki Nakagawa, James Maclean, James Su, AyeAye, Chromium LUCI CQ, chromium...@chromium.org, Nate Chapin, asvitkine...@chromium.org, devtools-re...@chromium.org, extension...@chromium.org, chromium-a...@chromium.org, mkwst+w...@chromium.org, horo+...@chromium.org, shimazu+se...@chromium.org, kinuko+ser...@chromium.org, servicewor...@chromium.org, antoniosarto...@chromium.org, kenjibah...@chromium.org, jsbell+ser...@chromium.org, arthursonzog...@chromium.org, blink-revie...@chromium.org, alexmo...@chromium.org, yhanad...@chromium.org, tranbaod...@chromium.org, nona+...@chromium.org, creis...@chromium.org, shuche...@chromium.org, jbauma...@chromium.org, navigation...@chromium.org, keithle...@chromium.org, blink-...@chromium.org, blundell+...@chromium.org, gavinp...@chromium.org, kinuko...@chromium.org, loading-re...@chromium.org, loading...@chromium.org, net-r...@chromium.org, network-ser...@chromium.org
          Attention needed from Andrea Orru and Kelvin Jiang

          Andrew Brown added 4 comments

          Patchset-level comments
          File-level comment, Patchset 52:
          Kelvin Jiang . unresolved

          Can we add a WebRequest browser test for this? i.e. make sure that an extension can modify the user-agent but it won't cause a CORS preflght?

          Andrew Brown

          That sounds like a good idea. If the current code all works then I'll look into it.

          File-level comment, Patchset 52:
          Andrew Brown . resolved

          Test failures look like `ContinueToStartRequest` is already "too late" to avoid CORS checks, I'll look for a new spot to move the User-Agent back to `content_user_agent`.

          Andrew Brown

          ...my logic was just wrong, now (hopefully) fixed.


          I did move the user-agent fiddling block *slightly* earlier in `ContinueToStartRequest` as it appears there are a few blockers that get removed before `CreateLoaderAndStart()` gets called, and I don't want race conditions.

          File extensions/browser/api/web_request/web_request_proxying_url_loader_factory.h
          Line 251, Patchset 52: // `request_.content_user_agent` -- if so, it has to be cleared before the
          Kelvin Jiang . resolved

          optional nit: pipes for consistency with `|has_any_extra_headers_listeners_|` below

          Andrew Brown

          Done

          Line 250, Patchset 52: // Whether this request had it's User-Agent temporarily set based on the
          Kelvin Jiang . resolved

          its

          Andrew Brown

          Done

          Open in Gerrit

          Related details

          Attention is currently required from:
          • Andrea Orru
          • Kelvin Jiang
          Submit Requirements:
          • requirement satisfiedCode-Coverage
          • requirement is not satisfiedCode-Owners
          • requirement is not satisfiedCode-Review
          • requirement is not satisfiedNo-Unresolved-Comments
          • requirement is not satisfiedReview-Enforcement
          Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
          Gerrit-MessageType: comment
          Gerrit-Project: chromium/src
          Gerrit-Branch: main
          Gerrit-Change-Id: Icf56620f99f371ea2f128e6a3194d6096b0d62cd
          Gerrit-Change-Number: 5273743
          Gerrit-PatchSet: 53
          Gerrit-Owner: Andrew Brown <m...@ajbrown.au>
          Gerrit-Reviewer: Adam Rice <ri...@chromium.org>
          Gerrit-Reviewer: Alex Moshchuk <ale...@chromium.org>
          Gerrit-Reviewer: Andrea Orru <andre...@chromium.org>
          Gerrit-Reviewer: Andrew Brown <m...@ajbrown.au>
          Gerrit-Reviewer: Devlin Cronin <rdevlin...@chromium.org>
          Gerrit-Reviewer: Kelvin Jiang <kelvi...@chromium.org>
          Gerrit-Reviewer: Min Qin <qin...@chromium.org>
          Gerrit-Reviewer: Oliver Dunk <olive...@chromium.org>
          Gerrit-Reviewer: Takashi Toyoshima <toyo...@chromium.org>
          Gerrit-CC: Chromium Metrics Reviews <chromium-met...@google.com>
          Gerrit-CC: Clark DuVall <cdu...@chromium.org>
          Gerrit-CC: Hiroki Nakagawa <nhi...@chromium.org>
          Gerrit-CC: James Maclean <wjma...@chromium.org>
          Gerrit-CC: James Su <su...@chromium.org>
          Gerrit-CC: Name of user not set #4416269
          Gerrit-CC: Nate Chapin <jap...@chromium.org>
          Gerrit-CC: Takashi Nakayama <tn...@chromium.org>
          Gerrit-Attention: Kelvin Jiang <kelvi...@chromium.org>
          Gerrit-Attention: Andrea Orru <andre...@chromium.org>
          Gerrit-Comment-Date: Wed, 22 Oct 2025 01:53:03 +0000
          satisfied_requirement
          unsatisfied_requirement
          open
          diffy

          Kelvin Jiang (Gerrit)

          unread,
          Oct 22, 2025, 4:26:19 PMOct 22
          to Andrew Brown, Andrea Orru, Oliver Dunk, Alex Moshchuk, Takashi Toyoshima, Adam Rice, Clark DuVall, Devlin Cronin, Chromium Metrics Reviews, Takashi Nakayama, Min Qin, Hiroki Nakagawa, James Maclean, James Su, AyeAye, Chromium LUCI CQ, chromium...@chromium.org, Nate Chapin, asvitkine...@chromium.org, devtools-re...@chromium.org, extension...@chromium.org, chromium-a...@chromium.org, mkwst+w...@chromium.org, horo+...@chromium.org, shimazu+se...@chromium.org, kinuko+ser...@chromium.org, servicewor...@chromium.org, antoniosarto...@chromium.org, kenjibah...@chromium.org, jsbell+ser...@chromium.org, arthursonzog...@chromium.org, blink-revie...@chromium.org, alexmo...@chromium.org, yhanad...@chromium.org, tranbaod...@chromium.org, nona+...@chromium.org, creis...@chromium.org, shuche...@chromium.org, jbauma...@chromium.org, navigation...@chromium.org, keithle...@chromium.org, blink-...@chromium.org, blundell+...@chromium.org, gavinp...@chromium.org, kinuko...@chromium.org, loading-re...@chromium.org, loading...@chromium.org, net-r...@chromium.org, network-ser...@chromium.org
          Attention needed from Andrea Orru, Andrew Brown and Kelvin Jiang

          Kelvin Jiang voted and added 1 comment

          Votes added by Kelvin Jiang

          Commit-Queue+1

          1 comment

          Patchset-level comments
          File-level comment, Patchset 53 (Latest):
          Kelvin Jiang . resolved

          oh yeah could you rebase and resolve merge conflicts before we see if it passes the dry run?

          Open in Gerrit

          Related details

          Attention is currently required from:
          • Andrea Orru
          • Andrew Brown
          • Kelvin Jiang
          Gerrit-Attention: Andrew Brown <m...@ajbrown.au>
          Gerrit-Attention: Andrea Orru <andre...@chromium.org>
          Gerrit-Comment-Date: Wed, 22 Oct 2025 20:26:09 +0000
          Gerrit-HasComments: Yes
          Gerrit-Has-Labels: Yes
          satisfied_requirement
          unsatisfied_requirement
          open
          diffy

          Andrew Brown (Gerrit)

          unread,
          Oct 22, 2025, 7:55:42 PMOct 22
          to Kelvin Jiang, Andrea Orru, Oliver Dunk, Alex Moshchuk, Takashi Toyoshima, Adam Rice, Clark DuVall, Devlin Cronin, Chromium Metrics Reviews, Takashi Nakayama, Min Qin, Hiroki Nakagawa, James Maclean, James Su, AyeAye, Chromium LUCI CQ, chromium...@chromium.org, Nate Chapin, asvitkine...@chromium.org, devtools-re...@chromium.org, extension...@chromium.org, chromium-a...@chromium.org, mkwst+w...@chromium.org, horo+...@chromium.org, shimazu+se...@chromium.org, kinuko+ser...@chromium.org, servicewor...@chromium.org, antoniosarto...@chromium.org, kenjibah...@chromium.org, jsbell+ser...@chromium.org, arthursonzog...@chromium.org, blink-revie...@chromium.org, alexmo...@chromium.org, yhanad...@chromium.org, tranbaod...@chromium.org, nona+...@chromium.org, creis...@chromium.org, shuche...@chromium.org, jbauma...@chromium.org, navigation...@chromium.org, keithle...@chromium.org, blink-...@chromium.org, blundell+...@chromium.org, gavinp...@chromium.org, kinuko...@chromium.org, loading-re...@chromium.org, loading...@chromium.org, net-r...@chromium.org, network-ser...@chromium.org
          Attention needed from Andrea Orru and Kelvin Jiang

          Andrew Brown added 1 comment

          Patchset-level comments
          Kelvin Jiang . resolved

          oh yeah could you rebase and resolve merge conflicts before we see if it passes the dry run?

          Andrew Brown

          Ah, oops, forgot about conflicts. Done.

          Open in Gerrit

          Related details

          Attention is currently required from:
          • Andrea Orru
          • Kelvin Jiang
          Submit Requirements:
          • requirement satisfiedCode-Coverage
          • requirement is not satisfiedCode-Owners
          • requirement is not satisfiedCode-Review
          • requirement is not satisfiedNo-Unresolved-Comments
          • requirement is not satisfiedReview-Enforcement
          Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
          Gerrit-MessageType: comment
          Gerrit-Project: chromium/src
          Gerrit-Branch: main
          Gerrit-Change-Id: Icf56620f99f371ea2f128e6a3194d6096b0d62cd
          Gerrit-Change-Number: 5273743
          Gerrit-PatchSet: 54
          Gerrit-Owner: Andrew Brown <m...@ajbrown.au>
          Gerrit-Reviewer: Adam Rice <ri...@chromium.org>
          Gerrit-Reviewer: Alex Moshchuk <ale...@chromium.org>
          Gerrit-Reviewer: Andrea Orru <andre...@chromium.org>
          Gerrit-Reviewer: Andrew Brown <m...@ajbrown.au>
          Gerrit-Reviewer: Devlin Cronin <rdevlin...@chromium.org>
          Gerrit-Reviewer: Kelvin Jiang <kelvi...@chromium.org>
          Gerrit-Reviewer: Min Qin <qin...@chromium.org>
          Gerrit-Reviewer: Oliver Dunk <olive...@chromium.org>
          Gerrit-Reviewer: Takashi Toyoshima <toyo...@chromium.org>
          Gerrit-CC: Chromium Metrics Reviews <chromium-met...@google.com>
          Gerrit-CC: Clark DuVall <cdu...@chromium.org>
          Gerrit-CC: Hiroki Nakagawa <nhi...@chromium.org>
          Gerrit-CC: James Maclean <wjma...@chromium.org>
          Gerrit-CC: James Su <su...@chromium.org>
          Gerrit-CC: Name of user not set #4416269
          Gerrit-CC: Nate Chapin <jap...@chromium.org>
          Gerrit-CC: Takashi Nakayama <tn...@chromium.org>
          Gerrit-Attention: Kelvin Jiang <kelvi...@chromium.org>
          Gerrit-Attention: Andrea Orru <andre...@chromium.org>
          Gerrit-Comment-Date: Wed, 22 Oct 2025 23:55:04 +0000
          satisfied_requirement
          unsatisfied_requirement
          open
          diffy

          Andrew Brown (Gerrit)

          unread,
          Oct 22, 2025, 9:20:11 PMOct 22
          to Andrea Orru, Kelvin Jiang, Oliver Dunk, Alex Moshchuk, Takashi Toyoshima, Adam Rice, Clark DuVall, Devlin Cronin, Chromium Metrics Reviews, Takashi Nakayama, Min Qin, Hiroki Nakagawa, James Maclean, James Su, AyeAye, Chromium LUCI CQ, chromium...@chromium.org, Nate Chapin, asvitkine...@chromium.org, devtools-re...@chromium.org, extension...@chromium.org, chromium-a...@chromium.org, mkwst+w...@chromium.org, horo+...@chromium.org, shimazu+se...@chromium.org, kinuko+ser...@chromium.org, servicewor...@chromium.org, antoniosarto...@chromium.org, kenjibah...@chromium.org, jsbell+ser...@chromium.org, arthursonzog...@chromium.org, blink-revie...@chromium.org, alexmo...@chromium.org, yhanad...@chromium.org, tranbaod...@chromium.org, nona+...@chromium.org, creis...@chromium.org, shuche...@chromium.org, jbauma...@chromium.org, navigation...@chromium.org, keithle...@chromium.org, blink-...@chromium.org, blundell+...@chromium.org, gavinp...@chromium.org, kinuko...@chromium.org, loading-re...@chromium.org, loading...@chromium.org, net-r...@chromium.org, network-ser...@chromium.org
          Attention needed from Andrea Orru and Kelvin Jiang

          Andrew Brown added 1 comment

          Patchset-level comments
          File-level comment, Patchset 54 (Latest):
          Andrew Brown . resolved

          I'm actually quite impressed ASAN picked that up, that's a rather nifty system.


          My money is that some part of the bottom of `ExecuteDeltas()` triggers the `WebRequestProxyingURLLoader()` to continue, which for a failed request, will then race on and free the `WebRequestInfo` *before* the new code sets the `user_agent_modified_by_extension` flag, making it a UAF. I'm recompiling to check this locally now.

          Gerrit-Comment-Date: Thu, 23 Oct 2025 01:19:33 +0000
          Gerrit-HasComments: Yes
          Gerrit-Has-Labels: No
          satisfied_requirement
          unsatisfied_requirement
          open
          diffy

          Andrew Brown (Gerrit)

          unread,
          Oct 27, 2025, 5:47:47 AMOct 27
          to Andrea Orru, Kelvin Jiang, Oliver Dunk, Alex Moshchuk, Takashi Toyoshima, Adam Rice, Clark DuVall, Devlin Cronin, Chromium Metrics Reviews, Takashi Nakayama, Min Qin, Hiroki Nakagawa, James Maclean, James Su, AyeAye, Chromium LUCI CQ, chromium...@chromium.org, Nate Chapin, asvitkine...@chromium.org, devtools-re...@chromium.org, extension...@chromium.org, chromium-a...@chromium.org, mkwst+w...@chromium.org, horo+...@chromium.org, shimazu+se...@chromium.org, kinuko+ser...@chromium.org, servicewor...@chromium.org, antoniosarto...@chromium.org, kenjibah...@chromium.org, jsbell+ser...@chromium.org, arthursonzog...@chromium.org, blink-revie...@chromium.org, alexmo...@chromium.org, yhanad...@chromium.org, tranbaod...@chromium.org, nona+...@chromium.org, creis...@chromium.org, shuche...@chromium.org, jbauma...@chromium.org, navigation...@chromium.org, keithle...@chromium.org, blink-...@chromium.org, blundell+...@chromium.org, gavinp...@chromium.org, kinuko...@chromium.org, loading-re...@chromium.org, loading...@chromium.org, net-r...@chromium.org, network-ser...@chromium.org
          Attention needed from Andrea Orru and Kelvin Jiang

          Andrew Brown added 1 comment

          Patchset-level comments
          File-level comment, Patchset 55 (Latest):
          Andrew Brown . unresolved

          I'll get back to this next week, apologies -- my thesis is due Friday.

          Open in Gerrit

          Related details

          Attention is currently required from:
          • Andrea Orru
          • Kelvin Jiang
          Submit Requirements:
          • requirement satisfiedCode-Coverage
          • requirement is not satisfiedCode-Owners
          • requirement is not satisfiedCode-Review
          • requirement is not satisfiedNo-Unresolved-Comments
          • requirement is not satisfiedReview-Enforcement
          Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
          Gerrit-MessageType: comment
          Gerrit-Project: chromium/src
          Gerrit-Branch: main
          Gerrit-Change-Id: Icf56620f99f371ea2f128e6a3194d6096b0d62cd
          Gerrit-Change-Number: 5273743
          Gerrit-PatchSet: 55
          Gerrit-Owner: Andrew Brown <m...@ajbrown.au>
          Gerrit-Reviewer: Adam Rice <ri...@chromium.org>
          Gerrit-Reviewer: Alex Moshchuk <ale...@chromium.org>
          Gerrit-Reviewer: Andrea Orru <andre...@chromium.org>
          Gerrit-Reviewer: Andrew Brown <m...@ajbrown.au>
          Gerrit-Reviewer: Devlin Cronin <rdevlin...@chromium.org>
          Gerrit-Reviewer: Kelvin Jiang <kelvi...@chromium.org>
          Gerrit-Reviewer: Min Qin <qin...@chromium.org>
          Gerrit-Reviewer: Oliver Dunk <olive...@chromium.org>
          Gerrit-Reviewer: Takashi Toyoshima <toyo...@chromium.org>
          Gerrit-CC: Chromium Metrics Reviews <chromium-met...@google.com>
          Gerrit-CC: Clark DuVall <cdu...@chromium.org>
          Gerrit-CC: Hiroki Nakagawa <nhi...@chromium.org>
          Gerrit-CC: James Maclean <wjma...@chromium.org>
          Gerrit-CC: James Su <su...@chromium.org>
          Gerrit-CC: Name of user not set #4416269
          Gerrit-CC: Nate Chapin <jap...@chromium.org>
          Gerrit-CC: Takashi Nakayama <tn...@chromium.org>
          Gerrit-Attention: Kelvin Jiang <kelvi...@chromium.org>
          Gerrit-Attention: Andrea Orru <andre...@chromium.org>
          Gerrit-Comment-Date: Mon, 27 Oct 2025 09:47:23 +0000
          Gerrit-HasComments: Yes
          Gerrit-Has-Labels: No
          satisfied_requirement
          unsatisfied_requirement
          open
          diffy

          Andrea Orru (Gerrit)

          unread,
          Oct 27, 2025, 12:57:31 PMOct 27
          to Andrew Brown, Kelvin Jiang, Oliver Dunk, Alex Moshchuk, Takashi Toyoshima, Adam Rice, Clark DuVall, Devlin Cronin, Chromium Metrics Reviews, Takashi Nakayama, Min Qin, Hiroki Nakagawa, James Maclean, James Su, AyeAye, Chromium LUCI CQ, chromium...@chromium.org, Nate Chapin, asvitkine...@chromium.org, devtools-re...@chromium.org, extension...@chromium.org, chromium-a...@chromium.org, mkwst+w...@chromium.org, horo+...@chromium.org, shimazu+se...@chromium.org, kinuko+ser...@chromium.org, servicewor...@chromium.org, antoniosarto...@chromium.org, kenjibah...@chromium.org, jsbell+ser...@chromium.org, arthursonzog...@chromium.org, blink-revie...@chromium.org, alexmo...@chromium.org, yhanad...@chromium.org, tranbaod...@chromium.org, nona+...@chromium.org, creis...@chromium.org, shuche...@chromium.org, jbauma...@chromium.org, navigation...@chromium.org, keithle...@chromium.org, blink-...@chromium.org, blundell+...@chromium.org, gavinp...@chromium.org, kinuko...@chromium.org, loading-re...@chromium.org, loading...@chromium.org, net-r...@chromium.org, network-ser...@chromium.org
          Attention needed from Andrew Brown and Kelvin Jiang

          Andrea Orru added 1 comment

          Patchset-level comments
          Andrew Brown . unresolved

          I'll get back to this next week, apologies -- my thesis is due Friday.

          Andrea Orru

          No worries. Thank you for your work and good luck with the thesis!

          Open in Gerrit

          Related details

          Attention is currently required from:
          • Andrew Brown
          • Kelvin Jiang
          Gerrit-Attention: Andrew Brown <m...@ajbrown.au>
          Gerrit-Comment-Date: Mon, 27 Oct 2025 16:57:21 +0000
          Gerrit-HasComments: Yes
          Gerrit-Has-Labels: No
          Comment-In-Reply-To: Andrew Brown <m...@ajbrown.au>
          satisfied_requirement
          unsatisfied_requirement
          open
          diffy

          Andrew Brown (Gerrit)

          unread,
          Nov 9, 2025, 6:38:30 PMNov 9
          to Andrea Orru, Kelvin Jiang, Oliver Dunk, Alex Moshchuk, Takashi Toyoshima, Adam Rice, Clark DuVall, Devlin Cronin, Chromium Metrics Reviews, Takashi Nakayama, Min Qin, Hiroki Nakagawa, James Maclean, James Su, AyeAye, Chromium LUCI CQ, chromium...@chromium.org, Nate Chapin, asvitkine...@chromium.org, devtools-re...@chromium.org, extension...@chromium.org, chromium-a...@chromium.org, mkwst+w...@chromium.org, horo+...@chromium.org, shimazu+se...@chromium.org, kinuko+ser...@chromium.org, servicewor...@chromium.org, antoniosarto...@chromium.org, kenjibah...@chromium.org, jsbell+ser...@chromium.org, arthursonzog...@chromium.org, blink-revie...@chromium.org, alexmo...@chromium.org, yhanad...@chromium.org, tranbaod...@chromium.org, nona+...@chromium.org, creis...@chromium.org, shuche...@chromium.org, jbauma...@chromium.org, navigation...@chromium.org, keithle...@chromium.org, blink-...@chromium.org, blundell+...@chromium.org, gavinp...@chromium.org, kinuko...@chromium.org, loading-re...@chromium.org, loading...@chromium.org, net-r...@chromium.org, network-ser...@chromium.org
          Attention needed from Kelvin Jiang

          Andrew Brown added 3 comments

          Patchset-level comments
          Kelvin Jiang . unresolved

          Can we add a WebRequest browser test for this? i.e. make sure that an extension can modify the user-agent but it won't cause a CORS preflght?

          Andrew Brown

          That sounds like a good idea. If the current code all works then I'll look into it.

          Andrew Brown

          Looking at this now. Is there a preference for whether I make a new "series" of extension tests (i.e. add a new folder & testing-extension `c/t/d/e/api_test/webrequest/test_user_agent_cors` or something) to test this, or should I just tack some new user-agent tests onto the end of `c/t/d/e/api_test/webrequest/test_cors/test_cors.js`?


          I'm probably leaning towards the former, but better to check your preference too.

          Andrew Brown . resolved

          I'll get back to this next week, apologies -- my thesis is due Friday.

          Andrea Orru

          No worries. Thank you for your work and good luck with the thesis!

          Andrew Brown

          Done -- phew!

          File extensions/browser/api/web_request/extension_web_request_event_router.h
          Line 191, Patchset 48: net::HttpRequestHeaders* request_headers,
          net::HttpRequestHeaders* exposed_headers);
          Kelvin Jiang . resolved

          What do you think is cleaner and more readable? having two header objects like now or wrapping these in a struct since I see many places where these two are side by side? Also we can add struct methods that when called once, will modify both set of headers!

          Also, I assume we need to use a `net::HttpRequestHeaders*` for headers that need to skip CORS and get applied afterwards because extensions should be able to modify these?

          Andrew Brown

          Hmm, not sure. I don't think there is much benefit to combining them because most functions will still need to do things with one or the other individually (i.e. it's not like we do `foo(both)` which calls `bar(both)` which calls `baz(both)` that splits them up, where `foo` and `bar` never need to go inside the `both` struct -- basically every level will need to go inside the `both` struct. The only super-relevant benefit will be that last level doesn't need to do two `headers->SetHeader(key, val)`, it can do a special `SetBoth(both, key, val)`, but I think that's maybe less clear than just doing two SetHeaders. Also, there are a lot of places (e.g. WebRequestInfo) that only have the `exposed_headers` still, and implicitly receive the `headers` via access to the ResourceRequest or similar. So none of those places would benefit from some sort of `TwoHeaders` struct.

          If you would prefer to combine the two into some struct I'm happy to do that, but my thought is probably that keeping them separate looks better. You're the owner who'll have to deal with things long-term though, so please override me if you want.

          ---

          I'm not sure what you mean about headers that skip CORS and get applied afterwards. Are you talking about cases where the extensions modifies "Not-Cors-Exempt: x" to be "Not-Cors-Exempt: y", and this modification would go onto `headers` and cause a CORS check?

          This doesn't need special handling (as of right now) because these headers are all on the list in `net/http/http_util.cc`, and headers from that list are assumed to always be CORS-safe no matter where they are. This is because javascript APIs do not allow setting values for any of those headers, so if they have a value set, it must have come from somewhere else. This CL will not change any of that behaviour, except for User-Agent.

          Does this mean, then, that extensions-set User-Agent values should be exempt from CORS checks? If so, we need special logic to ensure that if extensions modifies User-Agent, that change is reflected in the `content_user_agent` value, not just set onto `headers`, because values of `user_agent` on the `headers` will trigger CORS.

          Andrew Brown

          I've assumed an extensions-set User-Agent is immune to CORS, as that's the current behaviour.

          Andrew Brown

          Done, and will ensure this behaviour is included in the new test(s).

          Open in Gerrit

          Related details

          Attention is currently required from:
          • Kelvin Jiang
          Gerrit-Comment-Date: Sun, 09 Nov 2025 23:38:20 +0000
          Gerrit-HasComments: Yes
          Gerrit-Has-Labels: No
          Comment-In-Reply-To: Kelvin Jiang <kelvi...@chromium.org>
          Comment-In-Reply-To: Andrew Brown <m...@ajbrown.au>
          Comment-In-Reply-To: Andrea Orru <andre...@chromium.org>
          satisfied_requirement
          unsatisfied_requirement
          open
          diffy

          Kelvin Jiang (Gerrit)

          unread,
          Nov 11, 2025, 8:34:36 PMNov 11
          to Andrew Brown, Andrea Orru, Oliver Dunk, Alex Moshchuk, Takashi Toyoshima, Adam Rice, Clark DuVall, Devlin Cronin, Chromium Metrics Reviews, Takashi Nakayama, Min Qin, Hiroki Nakagawa, James Maclean, James Su, AyeAye, Chromium LUCI CQ, chromium...@chromium.org, Nate Chapin, asvitkine...@chromium.org, devtools-re...@chromium.org, extension...@chromium.org, chromium-a...@chromium.org, mkwst+w...@chromium.org, horo+...@chromium.org, shimazu+se...@chromium.org, kinuko+ser...@chromium.org, servicewor...@chromium.org, antoniosarto...@chromium.org, kenjibah...@chromium.org, jsbell+ser...@chromium.org, arthursonzog...@chromium.org, blink-revie...@chromium.org, alexmo...@chromium.org, yhanad...@chromium.org, tranbaod...@chromium.org, nona+...@chromium.org, creis...@chromium.org, shuche...@chromium.org, jbauma...@chromium.org, navigation...@chromium.org, keithle...@chromium.org, blink-...@chromium.org, blundell+...@chromium.org, gavinp...@chromium.org, kinuko...@chromium.org, loading-re...@chromium.org, loading...@chromium.org, net-r...@chromium.org, network-ser...@chromium.org
          Attention needed from Andrew Brown

          Kelvin Jiang voted and added 7 comments

          Votes added by Kelvin Jiang

          Commit-Queue+1

          7 comments

          Patchset-level comments
          Kelvin Jiang . unresolved

          Can we add a WebRequest browser test for this? i.e. make sure that an extension can modify the user-agent but it won't cause a CORS preflght?

          Andrew Brown

          That sounds like a good idea. If the current code all works then I'll look into it.

          Andrew Brown

          Looking at this now. Is there a preference for whether I make a new "series" of extension tests (i.e. add a new folder & testing-extension `c/t/d/e/api_test/webrequest/test_user_agent_cors` or something) to test this, or should I just tack some new user-agent tests onto the end of `c/t/d/e/api_test/webrequest/test_cors/test_cors.js`?


          I'm probably leaning towards the former, but better to check your preference too.

          Kelvin Jiang

          would prefer a series of new tests to prevent test extension bloat, also some extension tests carry state between one test to the next so if we can move away from that too it'd be great :)

          Kelvin Jiang . resolved

          thanks Andrew! Some questions

          File extensions/browser/api/web_request/web_request_proxying_url_loader_factory.h
          Line 251, Patchset 55 (Latest): // |request_.content_user_agent| -- if so, it has to be cleared before the
          Kelvin Jiang . unresolved

          is this AI?

          nit: `user_agent|. If so ...` (just use a period)

          File extensions/browser/api/web_request/web_request_proxying_url_loader_factory.cc
          Line 770, Patchset 55 (Latest): !(request_.headers.HasHeader(net::HttpRequestHeaders::kUserAgent));
          Kelvin Jiang . unresolved

          nit: extra parentheses?

          Line 840, Patchset 55 (Latest): std::optional<std::string> extension_modified_user_agent =
          request_.headers.GetHeader(net::HttpRequestHeaders::kUserAgent);
          Kelvin Jiang . unresolved

          nit: rename to user_agent since this may not have been actually modified by the extension (we'll know if it is in the below if statement)

          Line 845, Patchset 55 (Latest): request_.content_user_agent = *extension_modified_user_agent;
          Kelvin Jiang . unresolved

          I'm going to assume that `extension_modified_user_agent` should always be populated if `info_->user_agent_modified_by_extension` is true right? if so we can probably just `request_.content_user_agent = request_.headers.GetHeader(net::HttpRequestHeaders::kUserAgent);`

          (and yeah add a `CHECK(request_.headers.GetHeader(net::HttpRequestHeaders::kUserAgent));` here too)

          Line 850, Patchset 55 (Latest): if (user_agent_added_for_extensions_) {
          Kelvin Jiang . unresolved

          For my understanding: what's the difference between this and `info_->user_agent_modified_by_extension` ? This reads a bit confusing

          Open in Gerrit

          Related details

          Attention is currently required from:
          • Andrew Brown
          Gerrit-Attention: Andrew Brown <m...@ajbrown.au>
          Gerrit-Comment-Date: Wed, 12 Nov 2025 01:34:25 +0000
          Gerrit-HasComments: Yes
          Gerrit-Has-Labels: Yes
          satisfied_requirement
          unsatisfied_requirement
          open
          diffy

          Andrew Brown (Gerrit)

          unread,
          Nov 15, 2025, 5:40:27 AMNov 15
          to Kelvin Jiang, Andrea Orru, Oliver Dunk, Alex Moshchuk, Takashi Toyoshima, Adam Rice, Clark DuVall, Devlin Cronin, Chromium Metrics Reviews, Takashi Nakayama, Min Qin, Hiroki Nakagawa, James Maclean, James Su, AyeAye, Chromium LUCI CQ, chromium...@chromium.org, Nate Chapin, asvitkine...@chromium.org, devtools-re...@chromium.org, extension...@chromium.org, chromium-a...@chromium.org, mkwst+w...@chromium.org, horo+...@chromium.org, shimazu+se...@chromium.org, kinuko+ser...@chromium.org, servicewor...@chromium.org, antoniosarto...@chromium.org, kenjibah...@chromium.org, jsbell+ser...@chromium.org, arthursonzog...@chromium.org, blink-revie...@chromium.org, alexmo...@chromium.org, yhanad...@chromium.org, tranbaod...@chromium.org, nona+...@chromium.org, creis...@chromium.org, shuche...@chromium.org, jbauma...@chromium.org, navigation...@chromium.org, keithle...@chromium.org, blink-...@chromium.org, blundell+...@chromium.org, gavinp...@chromium.org, kinuko...@chromium.org, loading-re...@chromium.org, loading...@chromium.org, net-r...@chromium.org, network-ser...@chromium.org
          Attention needed from Kelvin Jiang

          Andrew Brown added 6 comments

          Patchset-level comments
          Kelvin Jiang . unresolved

          Can we add a WebRequest browser test for this? i.e. make sure that an extension can modify the user-agent but it won't cause a CORS preflght?

          Andrew Brown

          That sounds like a good idea. If the current code all works then I'll look into it.

          Andrew Brown

          Looking at this now. Is there a preference for whether I make a new "series" of extension tests (i.e. add a new folder & testing-extension `c/t/d/e/api_test/webrequest/test_user_agent_cors` or something) to test this, or should I just tack some new user-agent tests onto the end of `c/t/d/e/api_test/webrequest/test_cors/test_cors.js`?


          I'm probably leaning towards the former, but better to check your preference too.

          Kelvin Jiang

          would prefer a series of new tests to prevent test extension bloat, also some extension tests carry state between one test to the next so if we can move away from that too it'd be great :)

          Andrew Brown

          Alright, can do.


          I'm struggling a bit with some rather frustrating `Media load rejected by URL safety check` problem that seems to just be an inconsistent flake caused by blink? It's hitting me every time I run my new test locally, so I'll have to work out what's making the new test trigger that system. (Not uploaded yet, because I'm not confident it works at all.)

          File extensions/browser/api/web_request/web_request_proxying_url_loader_factory.h
          Line 251, Patchset 55: // |request_.content_user_agent| -- if so, it has to be cleared before the
          Kelvin Jiang . resolved

          is this AI?

          nit: `user_agent|. If so ...` (just use a period)

          Andrew Brown

          Hah, nah, I used em-dashes before it was cool :( Happy to switch to a full stop.

          File extensions/browser/api/web_request/web_request_proxying_url_loader_factory.cc
          Line 770, Patchset 55: !(request_.headers.HasHeader(net::HttpRequestHeaders::kUserAgent));
          Kelvin Jiang . resolved

          nit: extra parentheses?

          Andrew Brown

          Done

          Line 840, Patchset 55: std::optional<std::string> extension_modified_user_agent =
          request_.headers.GetHeader(net::HttpRequestHeaders::kUserAgent);
          Kelvin Jiang . resolved

          nit: rename to user_agent since this may not have been actually modified by the extension (we'll know if it is in the below if statement)

          Andrew Brown

          Done

          Line 845, Patchset 55: request_.content_user_agent = *extension_modified_user_agent;
          Kelvin Jiang . unresolved

          I'm going to assume that `extension_modified_user_agent` should always be populated if `info_->user_agent_modified_by_extension` is true right? if so we can probably just `request_.content_user_agent = request_.headers.GetHeader(net::HttpRequestHeaders::kUserAgent);`

          (and yeah add a `CHECK(request_.headers.GetHeader(net::HttpRequestHeaders::kUserAgent));` here too)

          Andrew Brown

          In theory an extension could remove the user-agent altogether, in which case we shouldn't clear the `request_.content_user_agent`, because the request should still go out with some user-agent on it. So we still need to check it, we can't just assume it's set.

          Line 850, Patchset 55: if (user_agent_added_for_extensions_) {
          Kelvin Jiang . unresolved

          For my understanding: what's the difference between this and `info_->user_agent_modified_by_extension` ? This reads a bit confusing

          Andrew Brown

          The `info_->user_agent_modified_by_extension` flag tracks whether an extension has actually changed the User-Agent (so we move the value over to the `content_user_agent`). Basically, "an extension touched this, so we need to make sure it stays CORS-exempt".


          The `user_agent_added_for_extensions_` flag tracks whether we placed the `content_user_agent` onto the `request_.headers` before anything happened, so we should remove it so it's not visible to CORS. Basically, "we put the `User-Agent` on the non-CORS-exempt headers, so we need to take it back off again".

          Open in Gerrit

          Related details

          Attention is currently required from:
          • Kelvin Jiang
          Submit Requirements:
          • requirement satisfiedCode-Coverage
          • requirement is not satisfiedCode-Owners
          • requirement is not satisfiedCode-Review
          • requirement is not satisfiedNo-Unresolved-Comments
          • requirement is not satisfiedReview-Enforcement
          Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
          Gerrit-MessageType: comment
          Gerrit-Project: chromium/src
          Gerrit-Branch: main
          Gerrit-Change-Id: Icf56620f99f371ea2f128e6a3194d6096b0d62cd
          Gerrit-Change-Number: 5273743
          Gerrit-PatchSet: 56
          Gerrit-Owner: Andrew Brown <m...@ajbrown.au>
          Gerrit-Reviewer: Adam Rice <ri...@chromium.org>
          Gerrit-Reviewer: Alex Moshchuk <ale...@chromium.org>
          Gerrit-Reviewer: Andrea Orru <andre...@chromium.org>
          Gerrit-Reviewer: Andrew Brown <m...@ajbrown.au>
          Gerrit-Reviewer: Devlin Cronin <rdevlin...@chromium.org>
          Gerrit-Reviewer: Kelvin Jiang <kelvi...@chromium.org>
          Gerrit-Reviewer: Min Qin <qin...@chromium.org>
          Gerrit-Reviewer: Oliver Dunk <olive...@chromium.org>
          Gerrit-Reviewer: Takashi Toyoshima <toyo...@chromium.org>
          Gerrit-CC: Chromium Metrics Reviews <chromium-met...@google.com>
          Gerrit-CC: Clark DuVall <cdu...@chromium.org>
          Gerrit-CC: Hiroki Nakagawa <nhi...@chromium.org>
          Gerrit-CC: James Maclean <wjma...@chromium.org>
          Gerrit-CC: James Su <su...@chromium.org>
          Gerrit-CC: Name of user not set #4416269
          Gerrit-CC: Nate Chapin <jap...@chromium.org>
          Gerrit-CC: Takashi Nakayama <tn...@chromium.org>
          Gerrit-Attention: Kelvin Jiang <kelvi...@chromium.org>
          Gerrit-Comment-Date: Sat, 15 Nov 2025 10:39:46 +0000
          Gerrit-HasComments: Yes
          Gerrit-Has-Labels: No
          satisfied_requirement
          unsatisfied_requirement
          open
          diffy

          Raymund Ico

          unread,
          Nov 15, 2025, 5:55:57 AMNov 15
          to devtools...@chromium.org, Kelvin Jiang, Andrea Orru, Oliver Dunk, Alex Moshchuk, Takashi Toyoshima, Adam Rice, Clark DuVall, Devlin Cronin, Chromium Metrics Reviews, Takashi Nakayama, Min Qin, Hiroki Nakagawa, James Maclean, James Su, AyeAye, Chromium LUCI CQ, chromium...@chromium.org, Nate Chapin, asvitkine...@chromium.org, devtools-re...@chromium.org, extension...@chromium.org, chromium-a...@chromium.org, mkwst+w...@chromium.org, horo+...@chromium.org, shimazu+se...@chromium.org, kinuko+ser...@chromium.org, servicewor...@chromium.org, antoniosarto...@chromium.org, kenjibah...@chromium.org, jsbell+ser...@chromium.org, arthursonzog...@chromium.org, blink-revie...@chromium.org, alexmo...@chromium.org, yhanad...@chromium.org, tranbaod...@chromium.org, nona+...@chromium.org, creis...@chromium.org, shuche...@chromium.org, jbauma...@chromium.org, navigation...@chromium.org, keithle...@chromium.org, blink-...@chromium.org, blundell+...@chromium.org, gavinp...@chromium.org, kinuko...@chromium.org, loading-re...@chromium.org, loading...@chromium.org, net-r...@chromium.org, network-ser...@chromium.org
          Good day everyone your getting enjoy after I open the system who are you people you inserted me to this activity without my knowledge...  Anyways I denied the access it's lock you use my Gerrit API-to-Go this Gerrit API-to-Go is available on GitHub get it there 

          To unsubscribe from this group and stop receiving emails from it, send an email to devtools-revie...@chromium.org.
          1000020440.jpg
          unsatisfied_requirement
          unsatisfied_requirement
          satisfied_requirement
          1000020439.jpg
          1000020438.jpg
          1000020430.png
          unsatisfied_requirement
          diffy
          open
          open
          unsatisfied_requirement

          Ko Phalychan (Gerrit)

          unread,
          Nov 16, 2025, 9:31:39 PMNov 16
          to Andrew Brown, Kelvin Jiang, Andrea Orru, Oliver Dunk, Alex Moshchuk, Takashi Toyoshima, Adam Rice, Clark DuVall, Devlin Cronin, Chromium Metrics Reviews, Takashi Nakayama, Min Qin, Hiroki Nakagawa, James Maclean, James Su, AyeAye, Chromium LUCI CQ, chromium...@chromium.org, Nate Chapin, asvitkine...@chromium.org, devtools-re...@chromium.org, extension...@chromium.org, chromium-a...@chromium.org, mkwst+w...@chromium.org, horo+...@chromium.org, shimazu+se...@chromium.org, kinuko+ser...@chromium.org, servicewor...@chromium.org, antoniosarto...@chromium.org, kenjibah...@chromium.org, jsbell+ser...@chromium.org, arthursonzog...@chromium.org, blink-revie...@chromium.org, alexmo...@chromium.org, yhanad...@chromium.org, tranbaod...@chromium.org, nona+...@chromium.org, creis...@chromium.org, shuche...@chromium.org, jbauma...@chromium.org, navigation...@chromium.org, keithle...@chromium.org, blink-...@chromium.org, blundell+...@chromium.org, gavinp...@chromium.org, kinuko...@chromium.org, loading-re...@chromium.org, loading...@chromium.org, net-r...@chromium.org, network-ser...@chromium.org
          Attention needed from Andrew Brown and Kelvin Jiang

          Ko Phalychan added 1 comment

          Attention is currently required from:
          • Andrew Brown
          • Kelvin Jiang
          Gerrit-CC: Ko Phalychan <kophal...@gmail.com>
          Gerrit-CC: Name of user not set #4416269
          Gerrit-CC: Nate Chapin <jap...@chromium.org>
          Gerrit-CC: Takashi Nakayama <tn...@chromium.org>
          Gerrit-Attention: Kelvin Jiang <kelvi...@chromium.org>
          Gerrit-Attention: Andrew Brown <m...@ajbrown.au>
          Gerrit-Comment-Date: Mon, 17 Nov 2025 02:31:04 +0000
          Gerrit-HasComments: Yes
          Gerrit-Has-Labels: No
          satisfied_requirement
          unsatisfied_requirement
          open
          diffy

          Kelvin Jiang (Gerrit)

          unread,
          Nov 17, 2025, 6:12:15 PM (14 days ago) Nov 17
          to Andrew Brown, Ko Phalychan, Andrea Orru, Oliver Dunk, Alex Moshchuk, Takashi Toyoshima, Adam Rice, Clark DuVall, Devlin Cronin, Chromium Metrics Reviews, Takashi Nakayama, Min Qin, Hiroki Nakagawa, James Maclean, James Su, AyeAye, Chromium LUCI CQ, chromium...@chromium.org, Nate Chapin, asvitkine...@chromium.org, devtools-re...@chromium.org, extension...@chromium.org, chromium-a...@chromium.org, mkwst+w...@chromium.org, horo+...@chromium.org, shimazu+se...@chromium.org, kinuko+ser...@chromium.org, servicewor...@chromium.org, antoniosarto...@chromium.org, kenjibah...@chromium.org, jsbell+ser...@chromium.org, arthursonzog...@chromium.org, blink-revie...@chromium.org, alexmo...@chromium.org, yhanad...@chromium.org, tranbaod...@chromium.org, nona+...@chromium.org, creis...@chromium.org, shuche...@chromium.org, jbauma...@chromium.org, navigation...@chromium.org, keithle...@chromium.org, blink-...@chromium.org, blundell+...@chromium.org, gavinp...@chromium.org, kinuko...@chromium.org, loading-re...@chromium.org, loading...@chromium.org, net-r...@chromium.org, network-ser...@chromium.org
          Attention needed from Andrew Brown

          Kelvin Jiang voted and added 4 comments

          Votes added by Kelvin Jiang

          Commit-Queue+1

          4 comments

          Patchset-level comments
          Kelvin Jiang . unresolved

          Can we add a WebRequest browser test for this? i.e. make sure that an extension can modify the user-agent but it won't cause a CORS preflght?

          Andrew Brown

          That sounds like a good idea. If the current code all works then I'll look into it.

          Andrew Brown

          Looking at this now. Is there a preference for whether I make a new "series" of extension tests (i.e. add a new folder & testing-extension `c/t/d/e/api_test/webrequest/test_user_agent_cors` or something) to test this, or should I just tack some new user-agent tests onto the end of `c/t/d/e/api_test/webrequest/test_cors/test_cors.js`?


          I'm probably leaning towards the former, but better to check your preference too.

          Kelvin Jiang

          would prefer a series of new tests to prevent test extension bloat, also some extension tests carry state between one test to the next so if we can move away from that too it'd be great :)

          Andrew Brown

          Alright, can do.


          I'm struggling a bit with some rather frustrating `Media load rejected by URL safety check` problem that seems to just be an inconsistent flake caused by blink? It's hitting me every time I run my new test locally, so I'll have to work out what's making the new test trigger that system. (Not uploaded yet, because I'm not confident it works at all.)

          Kelvin Jiang

          Acknowledged

          Kelvin Jiang . resolved

          thanks Andrew! will wait for the new test

          File extensions/browser/api/web_request/web_request_proxying_url_loader_factory.cc
          Line 845, Patchset 55: request_.content_user_agent = *extension_modified_user_agent;
          Kelvin Jiang . unresolved

          I'm going to assume that `extension_modified_user_agent` should always be populated if `info_->user_agent_modified_by_extension` is true right? if so we can probably just `request_.content_user_agent = request_.headers.GetHeader(net::HttpRequestHeaders::kUserAgent);`

          (and yeah add a `CHECK(request_.headers.GetHeader(net::HttpRequestHeaders::kUserAgent));` here too)

          Andrew Brown

          In theory an extension could remove the user-agent altogether, in which case we shouldn't clear the `request_.content_user_agent`, because the request should still go out with some user-agent on it. So we still need to check it, we can't just assume it's set.

          Kelvin Jiang

          oh forgot about that, noted! (a small test case here would be great too)

          but I assume the "user agent" is not actually removed only if it's `request_.content_user_agent` ?

          Line 850, Patchset 55: if (user_agent_added_for_extensions_) {
          Kelvin Jiang . unresolved

          For my understanding: what's the difference between this and `info_->user_agent_modified_by_extension` ? This reads a bit confusing

          Andrew Brown

          The `info_->user_agent_modified_by_extension` flag tracks whether an extension has actually changed the User-Agent (so we move the value over to the `content_user_agent`). Basically, "an extension touched this, so we need to make sure it stays CORS-exempt".


          The `user_agent_added_for_extensions_` flag tracks whether we placed the `content_user_agent` onto the `request_.headers` before anything happened, so we should remove it so it's not visible to CORS. Basically, "we put the `User-Agent` on the non-CORS-exempt headers, so we need to take it back off again".

          Kelvin Jiang

          in that case should we rename `user_agent_added_for_extensions_` to something else: maybe something that reflects more about why it was set (based on your comment above?)

          Open in Gerrit

          Related details

          Attention is currently required from:
          • Andrew Brown
          Submit Requirements:
          • requirement satisfiedCode-Coverage
          • requirement is not satisfiedCode-Owners
          • requirement is not satisfiedCode-Review
          • requirement is not satisfiedNo-Unresolved-Comments
          • requirement is not satisfiedReview-Enforcement
          Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
          Gerrit-MessageType: comment
          Gerrit-Project: chromium/src
          Gerrit-Branch: main
          Gerrit-Change-Id: Icf56620f99f371ea2f128e6a3194d6096b0d62cd
          Gerrit-Change-Number: 5273743
          Gerrit-PatchSet: 56
          Gerrit-Owner: Andrew Brown <m...@ajbrown.au>
          Gerrit-Reviewer: Adam Rice <ri...@chromium.org>
          Gerrit-Reviewer: Alex Moshchuk <ale...@chromium.org>
          Gerrit-Reviewer: Andrea Orru <andre...@chromium.org>
          Gerrit-Reviewer: Andrew Brown <m...@ajbrown.au>
          Gerrit-Reviewer: Devlin Cronin <rdevlin...@chromium.org>
          Gerrit-Reviewer: Kelvin Jiang <kelvi...@chromium.org>
          Gerrit-Reviewer: Min Qin <qin...@chromium.org>
          Gerrit-Reviewer: Name of user not set #4212261
          Gerrit-Reviewer: Oliver Dunk <olive...@chromium.org>
          Gerrit-Reviewer: Takashi Toyoshima <toyo...@chromium.org>
          Gerrit-CC: Chromium Metrics Reviews <chromium-met...@google.com>
          Gerrit-CC: Clark DuVall <cdu...@chromium.org>
          Gerrit-CC: Hiroki Nakagawa <nhi...@chromium.org>
          Gerrit-CC: James Maclean <wjma...@chromium.org>
          Gerrit-CC: James Su <su...@chromium.org>
          Gerrit-CC: Ko Phalychan <kophal...@gmail.com>
          Gerrit-CC: Name of user not set #4416269
          Gerrit-CC: Nate Chapin <jap...@chromium.org>
          Gerrit-CC: Takashi Nakayama <tn...@chromium.org>
          Gerrit-Attention: Andrew Brown <m...@ajbrown.au>
          Gerrit-Comment-Date: Mon, 17 Nov 2025 23:12:05 +0000
          Gerrit-HasComments: Yes
          Gerrit-Has-Labels: Yes
          satisfied_requirement
          unsatisfied_requirement
          open
          diffy

          Andrew Brown (Gerrit)

          unread,
          Nov 17, 2025, 8:27:52 PM (14 days ago) Nov 17
          to Kelvin Jiang, Ko Phalychan, Andrea Orru, Oliver Dunk, Alex Moshchuk, Takashi Toyoshima, Adam Rice, Clark DuVall, Devlin Cronin, Chromium Metrics Reviews, Takashi Nakayama, Min Qin, Hiroki Nakagawa, James Maclean, James Su, AyeAye, Chromium LUCI CQ, chromium...@chromium.org, Nate Chapin, asvitkine...@chromium.org, devtools-re...@chromium.org, extension...@chromium.org, chromium-a...@chromium.org, mkwst+w...@chromium.org, horo+...@chromium.org, shimazu+se...@chromium.org, kinuko+ser...@chromium.org, servicewor...@chromium.org, antoniosarto...@chromium.org, kenjibah...@chromium.org, jsbell+ser...@chromium.org, arthursonzog...@chromium.org, blink-revie...@chromium.org, alexmo...@chromium.org, yhanad...@chromium.org, tranbaod...@chromium.org, nona+...@chromium.org, creis...@chromium.org, shuche...@chromium.org, jbauma...@chromium.org, navigation...@chromium.org, keithle...@chromium.org, blink-...@chromium.org, blundell+...@chromium.org, gavinp...@chromium.org, kinuko...@chromium.org, loading-re...@chromium.org, loading...@chromium.org, net-r...@chromium.org, network-ser...@chromium.org
          Attention needed from Kelvin Jiang

          Andrew Brown added 3 comments

          Patchset-level comments
          Kelvin Jiang . unresolved

          Can we add a WebRequest browser test for this? i.e. make sure that an extension can modify the user-agent but it won't cause a CORS preflght?

          Andrew Brown

          That sounds like a good idea. If the current code all works then I'll look into it.

          Andrew Brown

          Looking at this now. Is there a preference for whether I make a new "series" of extension tests (i.e. add a new folder & testing-extension `c/t/d/e/api_test/webrequest/test_user_agent_cors` or something) to test this, or should I just tack some new user-agent tests onto the end of `c/t/d/e/api_test/webrequest/test_cors/test_cors.js`?


          I'm probably leaning towards the former, but better to check your preference too.

          Kelvin Jiang

          would prefer a series of new tests to prevent test extension bloat, also some extension tests carry state between one test to the next so if we can move away from that too it'd be great :)

          Andrew Brown

          Alright, can do.


          I'm struggling a bit with some rather frustrating `Media load rejected by URL safety check` problem that seems to just be an inconsistent flake caused by blink? It's hitting me every time I run my new test locally, so I'll have to work out what's making the new test trigger that system. (Not uploaded yet, because I'm not confident it works at all.)

          Kelvin Jiang

          Acknowledged

          Andrew Brown

          Update: I think I've worked that issue out. Some of the behaviour is still a bit weird (e.g. the extension isn't actually setting the user-agent, even though I've copied code from `test_extra_headers`, which passes this CL...), so I'm rebasing my test onto main now in order to check what's *supposed* to happen.

          Is it a problem that basically every extensions test uses the deprecated manifest V2 APIs? I tried using manifest V3 for this new test but I need access to the `framework.js` script (the one that `test_cors` and `test_extra_headers` uses), and it uses a few V2-only APIs.

          File extensions/browser/api/web_request/web_request_proxying_url_loader_factory.cc
          Line 845, Patchset 55: request_.content_user_agent = *extension_modified_user_agent;
          Kelvin Jiang . unresolved

          I'm going to assume that `extension_modified_user_agent` should always be populated if `info_->user_agent_modified_by_extension` is true right? if so we can probably just `request_.content_user_agent = request_.headers.GetHeader(net::HttpRequestHeaders::kUserAgent);`

          (and yeah add a `CHECK(request_.headers.GetHeader(net::HttpRequestHeaders::kUserAgent));` here too)

          Andrew Brown

          In theory an extension could remove the user-agent altogether, in which case we shouldn't clear the `request_.content_user_agent`, because the request should still go out with some user-agent on it. So we still need to check it, we can't just assume it's set.

          Kelvin Jiang

          oh forgot about that, noted! (a small test case here would be great too)

          but I assume the "user agent" is not actually removed only if it's `request_.content_user_agent` ?

          Andrew Brown

          The flow we have to be careful about is:

          • we place a user-agent onto the `request_.headers`, `user_agent_added_for_extensions_` is true
          • an extension "modifies" this by removing it, `info_->user_agent_modified_by_extension` is also true
          • line 845 triggers, and moves the non-existent `extension_modified_user_agent` back to the `content_user_agent` (so `request_.content_user_agent` is null)
          • then line 851 also triggers (because `user_agent_added_for_extensions_` is still true) and removes the user agent from the `request_.headers` also

          If this happens we have a request going through with no user-agent at all.

          I have experienced that there is another fallback somewhere deep in the net// internals that will still add the default-user-agent back to the request, if it somehow gets that far and doesn't have one. But the problem is Devtools may have set an override, which is reflected in `content_user_agent`, but not in this very-last-fallback in net//.

          So the super obnoxious edge case is:

          • devtools sets a global user-agent override
          • extension removes user-agent
          • this code moves "no user agent" back to the request, clobbering the devtools override
          • request is sent with the browser default user-agent instead of the devtools override

          I'll add a test to check that extensions removing a UA doesn't cause problems. I'm not sure about testing this specific flow because it involves devtools setting an override and that's somewhat out-of-scope for an extensions test, but I'll look into it.

          Line 850, Patchset 55: if (user_agent_added_for_extensions_) {
          Kelvin Jiang . unresolved

          For my understanding: what's the difference between this and `info_->user_agent_modified_by_extension` ? This reads a bit confusing

          Andrew Brown

          The `info_->user_agent_modified_by_extension` flag tracks whether an extension has actually changed the User-Agent (so we move the value over to the `content_user_agent`). Basically, "an extension touched this, so we need to make sure it stays CORS-exempt".


          The `user_agent_added_for_extensions_` flag tracks whether we placed the `content_user_agent` onto the `request_.headers` before anything happened, so we should remove it so it's not visible to CORS. Basically, "we put the `User-Agent` on the non-CORS-exempt headers, so we need to take it back off again".

          Kelvin Jiang

          in that case should we rename `user_agent_added_for_extensions_` to something else: maybe something that reflects more about why it was set (based on your comment above?)

          Andrew Brown

          Sounds good, though I'm not exactly sure how I'd express that in a different way than the current name. `added_extension_visible_user_agent_`?

          Open in Gerrit

          Related details

          Attention is currently required from:
          • Kelvin Jiang
          Gerrit-Attention: Kelvin Jiang <kelvi...@chromium.org>
          Gerrit-Comment-Date: Tue, 18 Nov 2025 01:27:13 +0000
          Gerrit-HasComments: Yes
          Gerrit-Has-Labels: No
          satisfied_requirement
          unsatisfied_requirement
          open
          diffy

          Raymund Ico

          unread,
          Nov 18, 2025, 3:32:37 AM (13 days ago) Nov 18
          to devtools...@chromium.org, Kelvin Jiang, Ko Phalychan, Andrea Orru, Oliver Dunk, Alex Moshchuk, Takashi Toyoshima, Adam Rice, Clark DuVall, Devlin Cronin, Chromium Metrics Reviews, Takashi Nakayama, Min Qin, Hiroki Nakagawa, James Maclean, James Su, AyeAye, Chromium LUCI CQ, chromium...@chromium.org, Nate Chapin, asvitkine...@chromium.org, devtools-re...@chromium.org, extension...@chromium.org, chromium-a...@chromium.org, mkwst+w...@chromium.org, horo+...@chromium.org, shimazu+se...@chromium.org, kinuko+ser...@chromium.org, servicewor...@chromium.org, antoniosarto...@chromium.org, kenjibah...@chromium.org, jsbell+ser...@chromium.org, arthursonzog...@chromium.org, blink-revie...@chromium.org, alexmo...@chromium.org, yhanad...@chromium.org, tranbaod...@chromium.org, nona+...@chromium.org, creis...@chromium.org, shuche...@chromium.org, jbauma...@chromium.org, navigation...@chromium.org, keithle...@chromium.org, blink-...@chromium.org, blundell+...@chromium.org, gavinp...@chromium.org, kinuko...@chromium.org, loading-re...@chromium.org, loading...@chromium.org, net-r...@chromium.org, network-ser...@chromium.org
          I can't execute internal data entry I see it but the response column and also the execution button. To much buttons...
          I've only enter what I like to do with this Gerrit API-to-Go there's a instructions box put what you want videos image pdf anything then save then the system will do all your instructions example if i want to denied access all of your patches where I can't see then only V8V8 main I activate blink of an eye the Gerrit API-to-Go will do base on instructions by Apps operator 

          To unsubscribe from this group and stop receiving emails from it, send an email to devtools-revie...@chromium.org.
          unsatisfied_requirement
          diffy
          unsatisfied_requirement
          unsatisfied_requirement
          open
          open
          unsatisfied_requirement
          satisfied_requirement
          It is loading more messages.
          0 new messages