OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #include "base/command_line.h" | 5 #include "base/command_line.h" |
6 #include "base/strings/stringprintf.h" | 6 #include "base/strings/stringprintf.h" |
7 #include "content/browser/loader/resource_dispatcher_host_impl.h" | 7 #include "content/browser/loader/resource_dispatcher_host_impl.h" |
8 #include "content/public/browser/navigation_entry.h" | 8 #include "content/public/browser/navigation_entry.h" |
9 #include "content/public/browser/resource_dispatcher_host_delegate.h" | 9 #include "content/public/browser/resource_dispatcher_host_delegate.h" |
10 #include "content/public/browser/resource_throttle.h" | 10 #include "content/public/browser/resource_throttle.h" |
11 #include "content/public/browser/web_contents.h" | 11 #include "content/public/browser/web_contents.h" |
12 #include "content/public/common/content_switches.h" | |
13 #include "content/public/test/browser_test_utils.h" | 12 #include "content/public/test/browser_test_utils.h" |
14 #include "content/public/test/content_browser_test.h" | 13 #include "content/public/test/content_browser_test.h" |
15 #include "content/public/test/content_browser_test_utils.h" | 14 #include "content/public/test/content_browser_test_utils.h" |
16 #include "content/public/test/test_navigation_observer.h" | 15 #include "content/public/test/test_navigation_observer.h" |
17 #include "content/shell/browser/shell.h" | 16 #include "content/shell/browser/shell.h" |
18 #include "content/shell/browser/shell_content_browser_client.h" | 17 #include "content/shell/browser/shell_content_browser_client.h" |
19 #include "content/shell/browser/shell_resource_dispatcher_host_delegate.h" | 18 #include "content/shell/browser/shell_resource_dispatcher_host_delegate.h" |
20 #include "net/base/escape.h" | 19 #include "net/base/escape.h" |
21 #include "net/dns/mock_host_resolver.h" | 20 #include "net/dns/mock_host_resolver.h" |
22 #include "net/test/embedded_test_server/embedded_test_server.h" | 21 #include "net/test/embedded_test_server/embedded_test_server.h" |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
202 else | 201 else |
203 script = base::StringPrintf("location.href = '%s'", url.spec().c_str()); | 202 script = base::StringPrintf("location.href = '%s'", url.spec().c_str()); |
204 TestNavigationObserver load_observer(shell()->web_contents(), 1); | 203 TestNavigationObserver load_observer(shell()->web_contents(), 1); |
205 bool result = ExecuteScript(window->web_contents(), script); | 204 bool result = ExecuteScript(window->web_contents(), script); |
206 EXPECT_TRUE(result); | 205 EXPECT_TRUE(result); |
207 if (should_wait_for_navigation) | 206 if (should_wait_for_navigation) |
208 load_observer.Wait(); | 207 load_observer.Wait(); |
209 } | 208 } |
210 | 209 |
211 void SetUpCommandLine(base::CommandLine* command_line) override { | 210 void SetUpCommandLine(base::CommandLine* command_line) override { |
212 // Use --site-per-process to force process swaps for cross-site transfers. | 211 IsolateAllSitesForTesting(command_line); |
213 command_line->AppendSwitch(switches::kSitePerProcess); | |
214 } | 212 } |
215 | 213 |
216 void InjectResourceDisptcherHostDelegate() { | 214 void InjectResourceDisptcherHostDelegate() { |
217 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 215 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
218 old_delegate_ = ResourceDispatcherHostImpl::Get()->delegate(); | 216 old_delegate_ = ResourceDispatcherHostImpl::Get()->delegate(); |
219 ResourceDispatcherHostImpl::Get()->SetDelegate(&tracking_delegate_); | 217 ResourceDispatcherHostImpl::Get()->SetDelegate(&tracking_delegate_); |
220 } | 218 } |
221 | 219 |
222 void RestoreResourceDisptcherHostDelegate() { | 220 void RestoreResourceDisptcherHostDelegate() { |
223 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 221 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
427 EXPECT_EQ(0, controller.GetCurrentEntryIndex()); | 425 EXPECT_EQ(0, controller.GetCurrentEntryIndex()); |
428 EXPECT_EQ(url1, controller.GetEntryAtIndex(0)->GetURL()); | 426 EXPECT_EQ(url1, controller.GetEntryAtIndex(0)->GetURL()); |
429 | 427 |
430 // Make sure the request for url2 did not complete. | 428 // Make sure the request for url2 did not complete. |
431 EXPECT_FALSE(tracking_delegate().WaitForTrackedURLAndGetCompleted()); | 429 EXPECT_FALSE(tracking_delegate().WaitForTrackedURLAndGetCompleted()); |
432 | 430 |
433 shell()->web_contents()->SetDelegate(old_delegate); | 431 shell()->web_contents()->SetDelegate(old_delegate); |
434 } | 432 } |
435 | 433 |
436 } // namespace content | 434 } // namespace content |
OLD | NEW |