| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // Browser tests targeted at the RenderView that run in browser context. | 5 // Browser tests targeted at the RenderView that run in browser context. |
| 6 // Note that these tests rely on single-process mode, and hence may be | 6 // Note that these tests rely on single-process mode, and hence may be |
| 7 // disabled in some configurations (check gyp files). | 7 // disabled in some configurations (check gyp files). |
| 8 | 8 |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 203 | 203 |
| 204 // Reload same URL after forcing an error from the the network layer; | 204 // Reload same URL after forcing an error from the the network layer; |
| 205 // confirm that the error page is told the cached copy exists. | 205 // confirm that the error page is told the cached copy exists. |
| 206 int renderer_id = | 206 int renderer_id = |
| 207 shell()->web_contents()->GetMainFrame()->GetProcess()->GetID(); | 207 shell()->web_contents()->GetMainFrame()->GetProcess()->GetID(); |
| 208 scoped_refptr<net::URLRequestContextGetter> url_request_context_getter = | 208 scoped_refptr<net::URLRequestContextGetter> url_request_context_getter = |
| 209 ShellContentBrowserClient::Get()->browser_context()-> | 209 ShellContentBrowserClient::Get()->browser_context()-> |
| 210 GetRequestContextForRenderProcess(renderer_id); | 210 GetRequestContextForRenderProcess(renderer_id); |
| 211 BrowserThread::PostTask( | 211 BrowserThread::PostTask( |
| 212 BrowserThread::IO, FROM_HERE, | 212 BrowserThread::IO, FROM_HERE, |
| 213 base::Bind(&InterceptNetworkTransactions, url_request_context_getter, | 213 base::Bind(&InterceptNetworkTransactions, |
| 214 base::RetainedRef(url_request_context_getter), |
| 214 net::ERR_FAILED)); | 215 net::ERR_FAILED)); |
| 215 | 216 |
| 216 // An error results in one completed navigation. | 217 // An error results in one completed navigation. |
| 217 NavigateToURLBlockUntilNavigationsComplete(shell(), test_url, 1); | 218 NavigateToURLBlockUntilNavigationsComplete(shell(), test_url, 1); |
| 218 int error_code = net::OK; | 219 int error_code = net::OK; |
| 219 bool stale_cache_entry_present = false; | 220 bool stale_cache_entry_present = false; |
| 220 ASSERT_TRUE(GetLatestErrorFromRendererClient( | 221 ASSERT_TRUE(GetLatestErrorFromRendererClient( |
| 221 &error_code, &stale_cache_entry_present)); | 222 &error_code, &stale_cache_entry_present)); |
| 222 EXPECT_EQ(net::ERR_FAILED, error_code); | 223 EXPECT_EQ(net::ERR_FAILED, error_code); |
| 223 EXPECT_TRUE(stale_cache_entry_present); | 224 EXPECT_TRUE(stale_cache_entry_present); |
| 224 | 225 |
| 225 // Clear the cache and repeat; confirm lack of entry in cache reported. | 226 // Clear the cache and repeat; confirm lack of entry in cache reported. |
| 226 scoped_refptr<MessageLoopRunner> runner = new MessageLoopRunner; | 227 scoped_refptr<MessageLoopRunner> runner = new MessageLoopRunner; |
| 227 BrowserThread::PostTask( | 228 BrowserThread::PostTask( |
| 228 BrowserThread::IO, FROM_HERE, | 229 BrowserThread::IO, FROM_HERE, |
| 229 base::Bind(&ClearCache, url_request_context_getter, | 230 base::Bind(&ClearCache, base::RetainedRef(url_request_context_getter), |
| 230 runner->QuitClosure())); | 231 runner->QuitClosure())); |
| 231 runner->Run(); | 232 runner->Run(); |
| 232 | 233 |
| 233 content::NavigateToURLBlockUntilNavigationsComplete(shell(), test_url, 1); | 234 content::NavigateToURLBlockUntilNavigationsComplete(shell(), test_url, 1); |
| 234 | 235 |
| 235 error_code = net::OK; | 236 error_code = net::OK; |
| 236 stale_cache_entry_present = true; | 237 stale_cache_entry_present = true; |
| 237 ASSERT_TRUE(GetLatestErrorFromRendererClient( | 238 ASSERT_TRUE(GetLatestErrorFromRendererClient( |
| 238 &error_code, &stale_cache_entry_present)); | 239 &error_code, &stale_cache_entry_present)); |
| 239 EXPECT_EQ(net::ERR_FAILED, error_code); | 240 EXPECT_EQ(net::ERR_FAILED, error_code); |
| 240 EXPECT_FALSE(stale_cache_entry_present); | 241 EXPECT_FALSE(stale_cache_entry_present); |
| 241 } | 242 } |
| 242 | 243 |
| 243 } // namespace content | 244 } // namespace content |
| OLD | NEW |