Fix flaky BraveExtensionsManifestV2InstallerBrowserTest.InstallExtension (#33837)

The test was intermittently failing with SSL handshake errors and
"Failed to download extension." because the kHostResolverRules used
MAP *:443 which routed ALL HTTPS traffic to the test server. Other
browser subsystems (Safe Browsing, sync, etc.) would also connect to
the test server, causing spurious SSL handshake failures that could
interfere with the extension CRX download.

Narrow the host resolver rule to MAP a.test:443 so only the test
domain is routed to the HTTPS test server. Also move the
host_resolver()->AddRule() call to the beginning of SetUpOnMainThread()
to ensure DNS resolution is configured before the server starts
accepting connections.

Resolves https://github.com/brave/brave-browser/issues/52732
This commit is contained in:
Netzenbot
2026-02-10 17:25:09 -05:00
committed by GitHub
parent 6fc5acb51f
commit 4d074f7a47
@@ -231,6 +231,8 @@ class BraveExtensionsManifestV2InstallerBrowserTest
}
void SetUpOnMainThread() override {
host_resolver()->AddRule("*", "127.0.0.1");
auto get_extension = [](const net::test_server::HttpRequest& request)
-> std::unique_ptr<net::test_server::HttpResponse> {
if (request.GetURL().path() != "/extensions") {
@@ -248,7 +250,6 @@ class BraveExtensionsManifestV2InstallerBrowserTest
https_server_.ServeFilesFromDirectory(
base::PathService::CheckedGet(brave::DIR_TEST_DATA));
https_server_.StartAcceptingConnections();
host_resolver()->AddRule("*", "127.0.0.1");
}
void SetUpCommandLine(base::CommandLine* command_line) override {
@@ -258,7 +259,7 @@ class BraveExtensionsManifestV2InstallerBrowserTest
"url-source=https://a.test/extensions");
command_line->AppendSwitchASCII(
network::switches::kHostResolverRules,
"MAP *:443 " + https_server_.host_port_pair().ToString());
"MAP a.test:443 " + https_server_.host_port_pair().ToString());
}
void TearDown() override {