Commit d4da56f1 authored by John Abd-El-Malek's avatar John Abd-El-Malek Committed by Commit Bot

Add a regression test for r632725, which fixes renderer hangs if the network...

Add a regression test for r632725, which fixes renderer hangs if the network process crashes during a cookie request.

Bug: 932305
Change-Id: If809f1e3d5fe2fec9d33daef2d5f627db92952a8
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1539178Reviewed-by: default avatarMin Qin <qinmin@chromium.org>
Reviewed-by: default avatarNasko Oskov <nasko@chromium.org>
Commit-Queue: John Abd-El-Malek <jam@chromium.org>
Cr-Commit-Position: refs/heads/master@{#644508}
parent a99adead
...@@ -424,6 +424,23 @@ IN_PROC_BROWSER_TEST_F(NetworkServiceBrowserTest, SyncXHROnCrash) { ...@@ -424,6 +424,23 @@ IN_PROC_BROWSER_TEST_F(NetworkServiceBrowserTest, SyncXHROnCrash) {
// If the renderer is hung the test will hang. // If the renderer is hung the test will hang.
} }
// Verifies that sync cookie calls don't hang if the network service crashes.
IN_PROC_BROWSER_TEST_F(NetworkServiceBrowserTest, SyncCookieGetOnCrash) {
if (IsInProcessNetworkService())
return;
network::mojom::NetworkServiceTestPtr network_service_test;
ServiceManagerConnection::GetForProcess()->GetConnector()->BindInterface(
mojom::kNetworkServiceName, &network_service_test);
network_service_test->CrashOnGetCookieList();
NavigateToURL(shell(), embedded_test_server()->GetURL("/empty.html"));
ASSERT_TRUE(
content::ExecuteScript(shell()->web_contents(), "document.cookie"));
// If the renderer is hung the test will hang.
}
class NetworkServiceInProcessBrowserTest : public ContentBrowserTest { class NetworkServiceInProcessBrowserTest : public ContentBrowserTest {
public: public:
NetworkServiceInProcessBrowserTest() { NetworkServiceInProcessBrowserTest() {
......
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
#include "net/test/embedded_test_server/embedded_test_server.h" #include "net/test/embedded_test_server/embedded_test_server.h"
#include "net/test/spawned_test_server/spawned_test_server.h" #include "net/test/spawned_test_server/spawned_test_server.h"
#include "net/test/test_data_directory.h" #include "net/test/test_data_directory.h"
#include "services/network/cookie_manager.h"
#include "services/network/host_resolver.h" #include "services/network/host_resolver.h"
#include "services/network/network_context.h" #include "services/network/network_context.h"
#include "services/network/network_service.h" #include "services/network/network_service.h"
...@@ -183,6 +184,10 @@ class NetworkServiceTestHelper::NetworkServiceTestImpl ...@@ -183,6 +184,10 @@ class NetworkServiceTestHelper::NetworkServiceTestImpl
base::BindRepeating(CrashResolveHost, host)); base::BindRepeating(CrashResolveHost, host));
} }
void CrashOnGetCookieList() override {
network::CookieManager::CrashOnGetCookieList();
}
void GetLatestMemoryPressureLevel( void GetLatestMemoryPressureLevel(
GetLatestMemoryPressureLevelCallback callback) override { GetLatestMemoryPressureLevelCallback callback) override {
std::move(callback).Run(latest_memory_pressure_level_); std::move(callback).Run(latest_memory_pressure_level_);
......
...@@ -7,6 +7,8 @@ ...@@ -7,6 +7,8 @@
#include <utility> #include <utility>
#include "base/bind.h" #include "base/bind.h"
#include "base/process/process.h"
#include "build/build_config.h"
#include "components/content_settings/core/common/content_settings_pattern.h" #include "components/content_settings/core/common/content_settings_pattern.h"
#include "net/base/registry_controlled_domains/registry_controlled_domain.h" #include "net/base/registry_controlled_domains/registry_controlled_domain.h"
#include "net/cookies/canonical_cookie.h" #include "net/cookies/canonical_cookie.h"
...@@ -23,6 +25,12 @@ using CookieDeleteSessionControl = net::CookieDeletionInfo::SessionControl; ...@@ -23,6 +25,12 @@ using CookieDeleteSessionControl = net::CookieDeletionInfo::SessionControl;
namespace network { namespace network {
namespace {
bool g_crash_on_get_cookie_list = false;
} // namespace
CookieManager::ListenerRegistration::ListenerRegistration() {} CookieManager::ListenerRegistration::ListenerRegistration() {}
CookieManager::ListenerRegistration::~ListenerRegistration() {} CookieManager::ListenerRegistration::~ListenerRegistration() {}
...@@ -71,6 +79,11 @@ void CookieManager::GetAllCookies(GetAllCookiesCallback callback) { ...@@ -71,6 +79,11 @@ void CookieManager::GetAllCookies(GetAllCookiesCallback callback) {
void CookieManager::GetCookieList(const GURL& url, void CookieManager::GetCookieList(const GURL& url,
const net::CookieOptions& cookie_options, const net::CookieOptions& cookie_options,
GetCookieListCallback callback) { GetCookieListCallback callback) {
#if !defined(OS_IOS)
if (g_crash_on_get_cookie_list)
base::Process::TerminateCurrentProcessImmediately(1);
#endif
cookie_store_->GetCookieListWithOptionsAsync( cookie_store_->GetCookieListWithOptionsAsync(
url, cookie_options, url, cookie_options,
net::cookie_util::IgnoreCookieStatusList(std::move(callback))); net::cookie_util::IgnoreCookieStatusList(std::move(callback)));
...@@ -203,6 +216,10 @@ void CookieManager::BlockThirdPartyCookies(bool block) { ...@@ -203,6 +216,10 @@ void CookieManager::BlockThirdPartyCookies(bool block) {
cookie_settings_.set_block_third_party_cookies(block); cookie_settings_.set_block_third_party_cookies(block);
} }
void CookieManager::CrashOnGetCookieList() {
g_crash_on_get_cookie_list = true;
}
CookieDeletionInfo DeletionFilterToInfo(mojom::CookieDeletionFilterPtr filter) { CookieDeletionInfo DeletionFilterToInfo(mojom::CookieDeletionFilterPtr filter) {
CookieDeletionInfo delete_info; CookieDeletionInfo delete_info;
......
...@@ -84,6 +84,9 @@ class COMPONENT_EXPORT(NETWORK_SERVICE) CookieManager ...@@ -84,6 +84,9 @@ class COMPONENT_EXPORT(NETWORK_SERVICE) CookieManager
void SetForceKeepSessionState() override; void SetForceKeepSessionState() override;
void BlockThirdPartyCookies(bool block) override; void BlockThirdPartyCookies(bool block) override;
// Causes the next call to GetCookieList to crash the process.
static void CrashOnGetCookieList();
private: private:
// State associated with a CookieChangeListener. // State associated with a CookieChangeListener.
struct ListenerRegistration { struct ListenerRegistration {
......
...@@ -75,6 +75,9 @@ interface NetworkServiceTest { ...@@ -75,6 +75,9 @@ interface NetworkServiceTest {
// Causes the next host resolve to the given hostname to crash the process. // Causes the next host resolve to the given hostname to crash the process.
CrashOnResolveHost(string host); CrashOnResolveHost(string host);
// Causes the next CookieManager::GetCookieList call to crash.
CrashOnGetCookieList();
// Gets the latest memory pressure level reported by the // Gets the latest memory pressure level reported by the
// MemoryPressureListener. // MemoryPressureListener.
[Sync] [Sync]
......
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