Commit ff10e3dd authored by Satsuki Ueno's avatar Satsuki Ueno Committed by Commit Bot

Support IPv6 addresses in debuggerAddress

Updates the host:port parsing logic in chromedriver so that the
debuggerAddress option can accept ipv6 addresses. This change does not
support ipv6 addresses containing a zone id as the underlying url
libraries will not parse them.

Bug: 1112509
Change-Id: I2adb13b5788fc88a5ce4c415f680e2e3f93d6c64
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2412811Reviewed-by: default avatarShengfa Lin <shengfa@google.com>
Commit-Queue: Satsuki Ueno <satsukiu@google.com>
Cr-Commit-Position: refs/heads/master@{#809024}
parent 14ab0224
......@@ -410,8 +410,23 @@ Status ParseNetAddress(NetAddress* to_set,
if (!option.GetAsString(&server_addr))
return Status(kInvalidArgument, "must be 'host:port'");
std::vector<std::string> values = base::SplitString(
server_addr, ":", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL);
std::vector<std::string> values;
if (base::StartsWith(server_addr, "[")) {
size_t ipv6_terminator_pos = server_addr.find(']');
if (ipv6_terminator_pos == std::string::npos) {
return Status(kInvalidArgument,
"ipv6 address must be terminated with ']'");
}
values.push_back(server_addr.substr(0, ipv6_terminator_pos + 1));
std::vector<std::string> remaining =
base::SplitString(server_addr.substr(ipv6_terminator_pos + 1), ":",
base::TRIM_WHITESPACE, base::SPLIT_WANT_NONEMPTY);
values.insert(values.end(), remaining.begin(), remaining.end());
} else {
values = base::SplitString(server_addr, ":", base::TRIM_WHITESPACE,
base::SPLIT_WANT_ALL);
}
if (values.size() != 2)
return Status(kInvalidArgument, "must be 'host:port'");
......
......@@ -513,7 +513,7 @@ TEST(ParseCapabilities, ExcludeSwitches) {
ASSERT_TRUE(base::Contains(switches, "switch2"));
}
TEST(ParseCapabilities, UseRemoteBrowser) {
TEST(ParseCapabilities, UseRemoteBrowserHostName) {
Capabilities capabilities;
base::DictionaryValue caps;
caps.SetString("goog:chromeOptions.debuggerAddress", "abc:123");
......@@ -524,6 +524,30 @@ TEST(ParseCapabilities, UseRemoteBrowser) {
ASSERT_EQ(123, capabilities.debugger_address.port());
}
TEST(ParseCapabilities, UseRemoteBrowserIpv4) {
Capabilities capabilities;
base::DictionaryValue caps;
caps.SetString("goog:chromeOptions.debuggerAddress", "127.0.0.1:456");
Status status = capabilities.Parse(caps);
ASSERT_TRUE(status.IsOk());
ASSERT_TRUE(capabilities.IsRemoteBrowser());
ASSERT_EQ("127.0.0.1", capabilities.debugger_address.host());
ASSERT_EQ(456, capabilities.debugger_address.port());
}
TEST(ParseCapabilities, UseRemoteBrowserIpv6) {
Capabilities capabilities;
base::DictionaryValue caps;
caps.SetString("goog:chromeOptions.debuggerAddress",
"[fe80::f2ef:86ff:fe69:cafe]:789");
Status status = capabilities.Parse(caps);
ASSERT_TRUE(status.IsOk());
ASSERT_TRUE(capabilities.IsRemoteBrowser());
ASSERT_EQ("[fe80::f2ef:86ff:fe69:cafe]",
capabilities.debugger_address.host());
ASSERT_EQ(789, capabilities.debugger_address.port());
}
TEST(ParseCapabilities, MobileEmulationUserAgent) {
Capabilities capabilities;
base::DictionaryValue mobile_emulation;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment