Commit 2c6e31c7 authored by Matt Menke's avatar Matt Menke Committed by Commit Bot

Fix a potential race in CookieSettings tests.

These tests were set cookie settings on a CookieManager interface, and
then sending out a network request on a URLLoaderFactory interface.
Since Mojo events aren't ordered, there's no guarantee that the request
will be sent after the new settings are set.

This CL fixes that issue by flushing the CookieManager interface after
updating the cookie settings.

Bug: None
Change-Id: I1d355a81f935f40a8e1270ca49234bc6b5eb4a86
Reviewed-on: https://chromium-review.googlesource.com/1159192Reviewed-by: default avatarClark DuVall <cduvall@chromium.org>
Reviewed-by: default avatarJohn Abd-El-Malek <jam@chromium.org>
Commit-Queue: Matt Menke <mmenke@chromium.org>
Cr-Commit-Position: refs/heads/master@{#580128}
parent e1e19180
...@@ -1135,6 +1135,7 @@ IN_PROC_BROWSER_TEST_P(NetworkContextConfigurationBrowserTest, ...@@ -1135,6 +1135,7 @@ IN_PROC_BROWSER_TEST_P(NetworkContextConfigurationBrowserTest,
CookieSettingsFactory::GetForProfile(browser()->profile()) CookieSettingsFactory::GetForProfile(browser()->profile())
->SetDefaultCookieSetting(CONTENT_SETTING_BLOCK); ->SetDefaultCookieSetting(CONTENT_SETTING_BLOCK);
FlushNetworkInterface();
SetCookie(CookieType::kFirstParty, CookiePersistenceType::kSession); SetCookie(CookieType::kFirstParty, CookiePersistenceType::kSession);
EXPECT_TRUE(GetCookies(embedded_test_server()->base_url()).empty()); EXPECT_TRUE(GetCookies(embedded_test_server()->base_url()).empty());
...@@ -1157,6 +1158,7 @@ IN_PROC_BROWSER_TEST_P(NetworkContextConfigurationBrowserTest, CookieSettings) { ...@@ -1157,6 +1158,7 @@ IN_PROC_BROWSER_TEST_P(NetworkContextConfigurationBrowserTest, CookieSettings) {
// Set default setting to allow, cookies should be set now. // Set default setting to allow, cookies should be set now.
CookieSettingsFactory::GetForProfile(browser()->profile()) CookieSettingsFactory::GetForProfile(browser()->profile())
->SetDefaultCookieSetting(CONTENT_SETTING_ALLOW); ->SetDefaultCookieSetting(CONTENT_SETTING_ALLOW);
FlushNetworkInterface();
SetCookie(CookieType::kFirstParty, CookiePersistenceType::kSession); SetCookie(CookieType::kFirstParty, CookiePersistenceType::kSession);
EXPECT_FALSE(GetCookies(embedded_test_server()->base_url()).empty()); EXPECT_FALSE(GetCookies(embedded_test_server()->base_url()).empty());
......
...@@ -1215,6 +1215,8 @@ void StoragePartitionImpl::FlushNetworkInterfaceForTesting() { ...@@ -1215,6 +1215,8 @@ void StoragePartitionImpl::FlushNetworkInterfaceForTesting() {
network_context_.FlushForTesting(); network_context_.FlushForTesting();
if (url_loader_factory_for_browser_process_) if (url_loader_factory_for_browser_process_)
url_loader_factory_for_browser_process_.FlushForTesting(); url_loader_factory_for_browser_process_.FlushForTesting();
if (cookie_manager_for_browser_process_)
cookie_manager_for_browser_process_.FlushForTesting();
} }
void StoragePartitionImpl::WaitForDeletionTasksForTesting() { void StoragePartitionImpl::WaitForDeletionTasksForTesting() {
......
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