Commit 4e85d9f0 authored by Sergey Ulanov's avatar Sergey Ulanov Committed by Commit Bot

[Fuchsia] Workaround netstack bug in RemoteDebuggingPort test

The test is trying to verify that WebEngine closes devtools port as
expected. It was using URLFetcher to make an HTTP request to devtools.
Due to a netstack bug (fxb/49779) sometimes that request was hanging
indefinitely, so the test was timing out. Updated the tests to connect
raw socket, which allows to verify that the port is closed without
hitting that netstack bug.

Bug: 1067727
Change-Id: Id07eefe490ca4e25cf6d9143636802f8115cd0db
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2143380Reviewed-by: default avatarFabrice de Gans-Riberi <fdegans@chromium.org>
Commit-Queue: Sergey Ulanov <sergeyu@chromium.org>
Auto-Submit: Sergey Ulanov <sergeyu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#757920}
parent 7138e8de
...@@ -27,7 +27,9 @@ ...@@ -27,7 +27,9 @@
#include "fuchsia/base/test_navigation_listener.h" #include "fuchsia/base/test_navigation_listener.h"
#include "media/base/media_switches.h" #include "media/base/media_switches.h"
#include "media/fuchsia/audio/fake_audio_consumer.h" #include "media/fuchsia/audio/fake_audio_consumer.h"
#include "net/base/test_completion_callback.h"
#include "net/http/http_request_headers.h" #include "net/http/http_request_headers.h"
#include "net/socket/tcp_client_socket.h"
#include "net/test/embedded_test_server/default_handlers.h" #include "net/test/embedded_test_server/default_handlers.h"
#include "net/test/embedded_test_server/embedded_test_server.h" #include "net/test/embedded_test_server/embedded_test_server.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
...@@ -263,8 +265,7 @@ TEST_F(WebEngineIntegrationTest, InvalidUserAgent) { ...@@ -263,8 +265,7 @@ TEST_F(WebEngineIntegrationTest, InvalidUserAgent) {
// Check that if the CreateContextParams has |remote_debugging_port| set then: // Check that if the CreateContextParams has |remote_debugging_port| set then:
// - DevTools becomes available when the first debuggable Frame is created. // - DevTools becomes available when the first debuggable Frame is created.
// - DevTools closes when the last debuggable Frame is closed. // - DevTools closes when the last debuggable Frame is closed.
// Test is flaky. http://crbug.com/1067727 TEST_F(WebEngineIntegrationTest, RemoteDebuggingPort) {
TEST_F(WebEngineIntegrationTest, DISABLED_RemoteDebuggingPort) {
StartWebEngine(); StartWebEngine();
// Create a Context with remote debugging enabled via an ephemeral port. // Create a Context with remote debugging enabled via an ephemeral port.
...@@ -356,8 +357,32 @@ TEST_F(WebEngineIntegrationTest, DISABLED_RemoteDebuggingPort) { ...@@ -356,8 +357,32 @@ TEST_F(WebEngineIntegrationTest, DISABLED_RemoteDebuggingPort) {
// handled the Frame tear down. // handled the Frame tear down.
controller_run_loop.Run(); controller_run_loop.Run();
devtools_list = cr_fuchsia::GetDevToolsListFromPort(remote_debugging_port); // Verify that devtools server is shut down properly. WebEngine may shutdown
EXPECT_TRUE(devtools_list.is_none()); // the socket after shutting down the Frame, so make several attempts to
// connect until it fails. Don't try to read or write from/to the socket to
// avoid fxb/49779.
bool failed_to_connect = false;
for (int i = 0; i < 10; ++i) {
net::TestCompletionCallback connect_callback;
net::TCPClientSocket connecting_socket(
net::AddressList(net::IPEndPoint(net::IPAddress::IPv4Localhost(),
remote_debugging_port)),
nullptr, nullptr, net::NetLogSource());
int connect_result = connecting_socket.Connect(connect_callback.callback());
connect_result = connect_callback.GetResult(connect_result);
if (connect_result == net::OK) {
// If Connect() succeeded then try again a bit later.
base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(10));
continue;
}
EXPECT_EQ(connect_result, net::ERR_CONNECTION_REFUSED);
failed_to_connect = true;
break;
}
EXPECT_TRUE(failed_to_connect);
} }
// Check that remote debugging requests for Frames in non-debuggable Contexts // Check that remote debugging requests for Frames in non-debuggable Contexts
......
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