fix: derive Chromium User-Agent from actual browser version
The hardcoded DefaultChromiumUserAgent said Chrome/131 while the installed Chromium was v136. Chromium's sec-ch-ua header is generated from the real engine version, so sites comparing User-Agent against sec-ch-ua detected the mismatch as bot traffic and returned 403. Now the User-Agent is built after browser launch using browser.Version(), keeping the Chrome/N token in sync with sec-ch-ua's Chromium;v="N". Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -420,6 +420,23 @@ func TestDefaultChromiumUserAgent_Content(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestChromiumUserAgent_MatchesVersion(t *testing.T) {
|
||||
ua := chromiumUserAgent("136.0.7103.25")
|
||||
if !strings.Contains(ua, "Chrome/136.0.0.0") {
|
||||
t.Fatalf("expected Chrome/136.0.0.0 in UA, got %s", ua)
|
||||
}
|
||||
if strings.Contains(ua, "131") {
|
||||
t.Fatalf("UA must not contain old hardcoded version 131: %s", ua)
|
||||
}
|
||||
}
|
||||
|
||||
func TestChromiumUserAgent_MajorOnly(t *testing.T) {
|
||||
ua := chromiumUserAgent("140")
|
||||
if !strings.Contains(ua, "Chrome/140.0.0.0") {
|
||||
t.Fatalf("expected Chrome/140.0.0.0 in UA, got %s", ua)
|
||||
}
|
||||
}
|
||||
|
||||
// --- Viewport and UA defaults via mergeOptions ---
|
||||
|
||||
func TestMergeOptions_DefaultViewport(t *testing.T) {
|
||||
|
||||
Reference in New Issue
Block a user