0

Correct ipv6 parsing bug in remote-debugging-address

Fixes a bug where ipv6 addresses are not accepted for the
remote-debugger-address option.

Before this change, neither --remote-debugging-address=::1 nor
--remote-debugging-address=[::1] are accepted.
The reason is that the address was parsed expecting a bracketed address
but then is later wrapped in brackets again, resulting in invalid
addresses such as [[::1]].
This change updates parsing so that the non-bracketed ip literal is
accepted.

It also adds integ tests to verify the chromedriver/devtools
interaction when ip literals are specified.

Bug: 1112509
Change-Id: I82756add5f576f3303a84cd3edcc84956c65a75e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2424035
Commit-Queue: Satsuki Ueno <satsukiu@google.com>
Reviewed-by: Shengfa Lin <shengfa@google.com>
Reviewed-by: John Chen <johnchen@chromium.org>
Reviewed-by: Eric Seckler <eseckler@chromium.org>
Cr-Commit-Position: refs/heads/master@{#810281}
This commit is contained in:
Satsuki Ueno
2020-09-24 19:50:41 +00:00
committed by Commit Bot
parent 14275fb17d
commit 6e88c372ec
2 changed files with 46 additions and 1 deletions
chrome/test/chromedriver/test
headless/app

@ -98,6 +98,7 @@ _OS_SPECIFIC_FILTER['win'] = [
'ChromeDownloadDirTest.testFileDownloadAfterTabHeadless',
'ChromeDownloadDirTest.testFileDownloadWithClickHeadless',
'ChromeDownloadDirTest.testFileDownloadWithGetHeadless',
'RemoteBrowserTest.testConnectToRemoteBrowserLiteralAddressHeadless',
# HeadlessInvalidCertificateTest is sometimes flaky.
'HeadlessInvalidCertificateTest.*',
# Similar issues with HeadlessChromeDriverTest.
@ -4283,6 +4284,50 @@ class RemoteBrowserTest(ChromeDriverBaseTest):
else: # Else clause gets invoked if "break" never happens.
raise # This re-raises the most recent exception.
def testConnectToRemoteBrowserLiteralAddressHeadless(self):
debug_addrs = ['127.0.0.1', '::1']
debug_url_addrs = ['127.0.0.1', '[::1]']
for (debug_addr, debug_url_addr) in zip(debug_addrs, debug_url_addrs):
# Must use retries since there is an inherent race condition in port
# selection.
ports_generator = util.FindProbableFreePorts()
for _ in range(3):
port = ports_generator.next()
temp_dir = util.MakeTempDir()
print 'temp dir is ' + temp_dir
cmd = [_CHROME_BINARY,
'--headless',
'--remote-debugging-address=%s' % debug_addr,
'--remote-debugging-port=%d' % port,
'--user-data-dir=%s' % temp_dir,
'--use-mock-keychain']
process = subprocess.Popen(cmd)
try:
driver = self.CreateDriver(
debugger_address='%s:%d' % (debug_url_addr, port))
driver.ExecuteScript(
'console.info("%s")' % 'connecting at %d!' % port)
driver.Quit()
except:
continue
finally:
if process.poll() is None:
process.terminate()
# Wait for Chrome to exit here to prevent a race with Chrome to
# delete/modify the temporary user-data-dir.
# Maximum wait ~1 second.
for _ in range(20):
if process.poll() is not None:
break
print 'continuing to wait for Chrome to exit'
time.sleep(.05)
else:
process.kill()
break
else: # Else clause gets invoked if "break" never happens.
raise # This re-raises the most recent exception.
class LaunchDesktopTest(ChromeDriverBaseTest):
"""Tests that launching desktop Chrome works."""

@ -715,7 +715,7 @@ int HeadlessShellMain(int argc, const char** argv) {
address =
command_line.GetSwitchValueASCII(switches::kRemoteDebuggingAddress);
net::IPAddress parsed_address;
if (!net::ParseURLHostnameToAddress(address, &parsed_address)) {
if (!parsed_address.AssignFromIPLiteral(address)) {
LOG(ERROR) << "Invalid devtools server address";
return EXIT_FAILURE;
}