From 685af593818425e6b2b3b879212f50d0a7bee56f Mon Sep 17 00:00:00 2001 From: "eroman@chromium.org" Date: Tue, 11 May 2010 19:31:24 +0000 Subject: Bypass the DNS cache when the LOAD_VALIDATE_CACHE load flag is set. This fixes problem where cached negative DNS entries were being used on a regular page refresh. BUG=34737 TEST=HttpNetworkTransactionTest.BypassHostCacheOnRefresh* Review URL: http://codereview.chromium.org/2051006 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@46951 0039d316-1c4b-4281-b951-d872f2087c98 --- net/http/http_network_transaction_unittest.cc | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) (limited to 'net/http/http_network_transaction_unittest.cc') diff --git a/net/http/http_network_transaction_unittest.cc b/net/http/http_network_transaction_unittest.cc index 6581201..8464442 100644 --- a/net/http/http_network_transaction_unittest.cc +++ b/net/http/http_network_transaction_unittest.cc @@ -4053,9 +4053,9 @@ TEST_F(HttpNetworkTransactionTest, ResolveMadeWithReferrer) { EXPECT_TRUE(resolution_observer.did_complete_with_expected_referrer()); } -// Make sure that when the load flags contain LOAD_BYPASS_CACHE, the resolver's -// host cache is bypassed. -TEST_F(HttpNetworkTransactionTest, BypassHostCacheOnRefresh) { +// Base test to make sure that when the load flags for a request specify to +// bypass the cache, the DNS cache is not used. +void BypassHostCacheOnRefreshHelper(int load_flags) { SessionDependencies session_deps; // Select a host resolver that does caching. @@ -4094,7 +4094,7 @@ TEST_F(HttpNetworkTransactionTest, BypassHostCacheOnRefresh) { // Issue a request, asking to bypass the cache(s). HttpRequestInfo request; request.method = "GET"; - request.load_flags = LOAD_BYPASS_CACHE; + request.load_flags = load_flags; request.url = GURL("http://www.google.com/"); // Run the request. @@ -4108,6 +4108,20 @@ TEST_F(HttpNetworkTransactionTest, BypassHostCacheOnRefresh) { EXPECT_EQ(ERR_NAME_NOT_RESOLVED, rv); } +// There are multiple load flags that should trigger the host cache bypass. +// Test each in isolation: +TEST_F(HttpNetworkTransactionTest, BypassHostCacheOnRefresh1) { + BypassHostCacheOnRefreshHelper(LOAD_BYPASS_CACHE); +} + +TEST_F(HttpNetworkTransactionTest, BypassHostCacheOnRefresh2) { + BypassHostCacheOnRefreshHelper(LOAD_VALIDATE_CACHE); +} + +TEST_F(HttpNetworkTransactionTest, BypassHostCacheOnRefresh3) { + BypassHostCacheOnRefreshHelper(LOAD_DISABLE_CACHE); +} + // Make sure we can handle an error when writing the request. TEST_F(HttpNetworkTransactionTest, RequestWriteError) { SessionDependencies session_deps; -- cgit v1.1