Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(137)

Side by Side Diff: content/browser/cross_site_transfer_browsertest.cc

Issue 1208143002: Move existing kSitePerProcess checks to a policy-oracle object (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@swapped_out_cmdline_checks
Patch Set: Partial fixes to Nasko's comments. Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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" 12 #include "content/public/common/site_isolation_policy.h"
13 #include "content/public/test/browser_test_utils.h" 13 #include "content/public/test/browser_test_utils.h"
14 #include "content/public/test/content_browser_test.h" 14 #include "content/public/test/content_browser_test.h"
15 #include "content/public/test/content_browser_test_utils.h" 15 #include "content/public/test/content_browser_test_utils.h"
16 #include "content/public/test/test_navigation_observer.h" 16 #include "content/public/test/test_navigation_observer.h"
17 #include "content/shell/browser/shell.h" 17 #include "content/shell/browser/shell.h"
18 #include "content/shell/browser/shell_content_browser_client.h" 18 #include "content/shell/browser/shell_content_browser_client.h"
19 #include "content/shell/browser/shell_resource_dispatcher_host_delegate.h" 19 #include "content/shell/browser/shell_resource_dispatcher_host_delegate.h"
20 #include "net/base/escape.h" 20 #include "net/base/escape.h"
21 #include "net/dns/mock_host_resolver.h" 21 #include "net/dns/mock_host_resolver.h"
22 #include "net/test/embedded_test_server/embedded_test_server.h" 22 #include "net/test/embedded_test_server/embedded_test_server.h"
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 else 202 else
203 script = base::StringPrintf("location.href = '%s'", url.spec().c_str()); 203 script = base::StringPrintf("location.href = '%s'", url.spec().c_str());
204 TestNavigationObserver load_observer(shell()->web_contents(), 1); 204 TestNavigationObserver load_observer(shell()->web_contents(), 1);
205 bool result = ExecuteScript(window->web_contents(), script); 205 bool result = ExecuteScript(window->web_contents(), script);
206 EXPECT_TRUE(result); 206 EXPECT_TRUE(result);
207 if (should_wait_for_navigation) 207 if (should_wait_for_navigation)
208 load_observer.Wait(); 208 load_observer.Wait();
209 } 209 }
210 210
211 void SetUpCommandLine(base::CommandLine* command_line) override { 211 void SetUpCommandLine(base::CommandLine* command_line) override {
212 // Use --site-per-process to force process swaps for cross-site transfers. 212 SiteIsolationPolicy::IsolateAllSitesForTesting(command_line);
213 command_line->AppendSwitch(switches::kSitePerProcess);
214 } 213 }
215 214
216 void InjectResourceDisptcherHostDelegate() { 215 void InjectResourceDisptcherHostDelegate() {
217 DCHECK_CURRENTLY_ON(BrowserThread::IO); 216 DCHECK_CURRENTLY_ON(BrowserThread::IO);
218 old_delegate_ = ResourceDispatcherHostImpl::Get()->delegate(); 217 old_delegate_ = ResourceDispatcherHostImpl::Get()->delegate();
219 ResourceDispatcherHostImpl::Get()->SetDelegate(&tracking_delegate_); 218 ResourceDispatcherHostImpl::Get()->SetDelegate(&tracking_delegate_);
220 } 219 }
221 220
222 void RestoreResourceDisptcherHostDelegate() { 221 void RestoreResourceDisptcherHostDelegate() {
223 DCHECK_CURRENTLY_ON(BrowserThread::IO); 222 DCHECK_CURRENTLY_ON(BrowserThread::IO);
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
427 EXPECT_EQ(0, controller.GetCurrentEntryIndex()); 426 EXPECT_EQ(0, controller.GetCurrentEntryIndex());
428 EXPECT_EQ(url1, controller.GetEntryAtIndex(0)->GetURL()); 427 EXPECT_EQ(url1, controller.GetEntryAtIndex(0)->GetURL());
429 428
430 // Make sure the request for url2 did not complete. 429 // Make sure the request for url2 did not complete.
431 EXPECT_FALSE(tracking_delegate().WaitForTrackedURLAndGetCompleted()); 430 EXPECT_FALSE(tracking_delegate().WaitForTrackedURLAndGetCompleted());
432 431
433 shell()->web_contents()->SetDelegate(old_delegate); 432 shell()->web_contents()->SetDelegate(old_delegate);
434 } 433 }
435 434
436 } // namespace content 435 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698