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

Side by Side Diff: content/public/test/test_utils.cc

Issue 2946113002: Use FrameIsAd to decide whether to isolate a frame in TopDocumentIsolation mode. (Closed)
Patch Set: Rebasing... Created 3 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 "content/public/test/test_utils.h" 5 #include "content/public/test/test_utils.h"
6 6
7 #include <string>
7 #include <utility> 8 #include <utility>
8 9
10 #include "base/base_switches.h"
9 #include "base/bind.h" 11 #include "base/bind.h"
10 #include "base/command_line.h" 12 #include "base/command_line.h"
11 #include "base/location.h" 13 #include "base/location.h"
12 #include "base/macros.h" 14 #include "base/macros.h"
13 #include "base/message_loop/message_loop.h" 15 #include "base/message_loop/message_loop.h"
14 #include "base/run_loop.h" 16 #include "base/run_loop.h"
15 #include "base/single_thread_task_runner.h" 17 #include "base/single_thread_task_runner.h"
16 #include "base/strings/utf_string_conversions.h" 18 #include "base/strings/utf_string_conversions.h"
17 #include "base/task_scheduler/task_scheduler.h" 19 #include "base/task_scheduler/task_scheduler.h"
18 #include "base/threading/sequenced_worker_pool.h" 20 #include "base/threading/sequenced_worker_pool.h"
19 #include "base/threading/thread_task_runner_handle.h" 21 #include "base/threading/thread_task_runner_handle.h"
20 #include "base/values.h" 22 #include "base/values.h"
21 #include "build/build_config.h" 23 #include "build/build_config.h"
24 #include "components/variations/variations_switches.h"
22 #include "content/common/site_isolation_policy.h" 25 #include "content/common/site_isolation_policy.h"
23 #include "content/common/url_schemes.h" 26 #include "content/common/url_schemes.h"
24 #include "content/public/browser/browser_child_process_host_iterator.h" 27 #include "content/public/browser/browser_child_process_host_iterator.h"
25 #include "content/public/browser/notification_service.h" 28 #include "content/public/browser/notification_service.h"
26 #include "content/public/browser/render_frame_host.h" 29 #include "content/public/browser/render_frame_host.h"
27 #include "content/public/browser/render_process_host.h" 30 #include "content/public/browser/render_process_host.h"
28 #include "content/public/browser/web_contents.h" 31 #include "content/public/browser/web_contents.h"
29 #include "content/public/common/content_switches.h" 32 #include "content/public/common/content_switches.h"
30 #include "content/public/common/process_type.h" 33 #include "content/public/common/process_type.h"
31 #include "content/public/test/test_launcher.h" 34 #include "content/public/test/test_launcher.h"
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 202
200 bool AreAllSitesIsolatedForTesting() { 203 bool AreAllSitesIsolatedForTesting() {
201 return base::CommandLine::ForCurrentProcess()->HasSwitch( 204 return base::CommandLine::ForCurrentProcess()->HasSwitch(
202 switches::kSitePerProcess); 205 switches::kSitePerProcess);
203 } 206 }
204 207
205 void IsolateAllSitesForTesting(base::CommandLine* command_line) { 208 void IsolateAllSitesForTesting(base::CommandLine* command_line) {
206 command_line->AppendSwitch(switches::kSitePerProcess); 209 command_line->AppendSwitch(switches::kSitePerProcess);
207 } 210 }
208 211
212 void EnableTopDocumentIsolationForTesting(base::CommandLine* command_line) {
213 // Enable top-document-isolation feature (features::kTopDocumentIsolation)
214 // and associate it with a fake "TopDocumentIsolation" trial.
215 command_line->AppendSwitchASCII(
216 switches::kEnableFeatures, "top-document-isolation<TopDocumentIsolation");
217
218 // Register a fake TopDocumentIsolation/BrowserTests study group.
219 command_line->AppendSwitchASCII(switches::kForceFieldTrials,
220 "TopDocumentIsolation/BrowserTests");
221
222 // Set kTopDocumentIsolationModeParam to TopDocumentIsolationMode::Xsite.
223 // This is not really needed for content_browsertests (which will go through
224 // ShellContentBrowserClient::ShouldIsolateFrameFromMainContent), but is
225 // needed for browser_tests and other tests that use
226 // ChromeContentBrowserClient::ShouldIsolateFrameFromMainContent.
227 command_line->AppendSwitchASCII(variations::switches::kForceFieldTrialParams,
228 "TopDocumentIsolation.BrowserTests:mode/1");
229 }
230
209 void ResetSchemesAndOriginsWhitelist() { 231 void ResetSchemesAndOriginsWhitelist() {
210 url::Shutdown(); 232 url::Shutdown();
211 RegisterContentSchemes(false); 233 RegisterContentSchemes(false);
212 url::Initialize(); 234 url::Initialize();
213 } 235 }
214 236
215 #if defined(OS_ANDROID) 237 #if defined(OS_ANDROID)
216 // Registers content/browser and mojo JNI bindings necessary for some types of 238 // Registers content/browser and mojo JNI bindings necessary for some types of
217 // tests. 239 // tests.
218 bool RegisterJniForTesting(JNIEnv* env) { 240 bool RegisterJniForTesting(JNIEnv* env) {
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
401 423
402 void WebContentsDestroyedWatcher::Wait() { 424 void WebContentsDestroyedWatcher::Wait() {
403 run_loop_.Run(); 425 run_loop_.Run();
404 } 426 }
405 427
406 void WebContentsDestroyedWatcher::WebContentsDestroyed() { 428 void WebContentsDestroyedWatcher::WebContentsDestroyed() {
407 run_loop_.Quit(); 429 run_loop_.Quit();
408 } 430 }
409 431
410 } // namespace content 432 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698