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

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: Doh... need to also change s/Default/Unspecified/ in chrome_content_browser_client.cc 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"
32 #include "content/public/common/content_features.h"
29 #include "content/public/common/content_switches.h" 33 #include "content/public/common/content_switches.h"
30 #include "content/public/common/process_type.h" 34 #include "content/public/common/process_type.h"
31 #include "content/public/test/test_launcher.h" 35 #include "content/public/test/test_launcher.h"
32 #include "content/public/test/test_service_manager_context.h" 36 #include "content/public/test/test_service_manager_context.h"
33 #include "testing/gtest/include/gtest/gtest.h" 37 #include "testing/gtest/include/gtest/gtest.h"
34 #include "url/url_util.h" 38 #include "url/url_util.h"
35 39
36 #if defined(OS_ANDROID) 40 #if defined(OS_ANDROID)
37 #include "content/browser/android/browser_jni_registrar.h" 41 #include "content/browser/android/browser_jni_registrar.h"
38 #include "mojo/android/system/mojo_jni_registrar.h" 42 #include "mojo/android/system/mojo_jni_registrar.h"
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 203
200 bool AreAllSitesIsolatedForTesting() { 204 bool AreAllSitesIsolatedForTesting() {
201 return base::CommandLine::ForCurrentProcess()->HasSwitch( 205 return base::CommandLine::ForCurrentProcess()->HasSwitch(
202 switches::kSitePerProcess); 206 switches::kSitePerProcess);
203 } 207 }
204 208
205 void IsolateAllSitesForTesting(base::CommandLine* command_line) { 209 void IsolateAllSitesForTesting(base::CommandLine* command_line) {
206 command_line->AppendSwitch(switches::kSitePerProcess); 210 command_line->AppendSwitch(switches::kSitePerProcess);
207 } 211 }
208 212
213 void EnableTopDocumentIsolationForTesting(base::CommandLine* command_line) {
Alexei Svitkine (slow) 2017/07/07 16:55:06 Can you use VariationsParamManager here instead?
Łukasz Anforowicz 2017/07/07 20:41:42 Thank you very much for this suggestion - this loo
Alexei Svitkine (slow) 2017/07/10 18:46:24 The above check indicates there's already a FieldT
Łukasz Anforowicz 2017/07/10 22:17:39 I've opened https://crbug.com/740701 to track crea
214 // Enable top-document-isolation feature (features::kTopDocumentIsolation)
215 // and associate it with a fake "TopDocumentIsolation" trial.
216 command_line->AppendSwitchASCII(
217 switches::kEnableFeatures,
218 std::string(features::kTopDocumentIsolation.name) +
219 "<TopDocumentIsolation");
220
221 // Register a fake TopDocumentIsolation/BrowserTests study group.
222 command_line->AppendSwitchASCII(switches::kForceFieldTrials,
223 "TopDocumentIsolation/BrowserTests");
224
225 // Set kTopDocumentIsolationModeParam to TopDocumentIsolationMode::CrossSite.
226 // This is not really needed for content_browsertests (which will go through
227 // ShellContentBrowserClient::ShouldIsolateFrameFromMainContent), but is
228 // needed for browser_tests and other tests that use
229 // ChromeContentBrowserClient::ShouldIsolateFrameFromMainContent.
230 command_line->AppendSwitchASCII(
231 variations::switches::kForceFieldTrialParams,
232 "TopDocumentIsolation.BrowserTests:" +
233 std::string(features::kTopDocumentIsolationModeParam) + "/" +
234 std::to_string(
235 static_cast<int>(features::TopDocumentIsolationMode::CrossSite)));
236 }
237
209 void ResetSchemesAndOriginsWhitelist() { 238 void ResetSchemesAndOriginsWhitelist() {
210 url::Shutdown(); 239 url::Shutdown();
211 RegisterContentSchemes(false); 240 RegisterContentSchemes(false);
212 url::Initialize(); 241 url::Initialize();
213 } 242 }
214 243
215 #if defined(OS_ANDROID) 244 #if defined(OS_ANDROID)
216 // Registers content/browser and mojo JNI bindings necessary for some types of 245 // Registers content/browser and mojo JNI bindings necessary for some types of
217 // tests. 246 // tests.
218 bool RegisterJniForTesting(JNIEnv* env) { 247 bool RegisterJniForTesting(JNIEnv* env) {
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
401 430
402 void WebContentsDestroyedWatcher::Wait() { 431 void WebContentsDestroyedWatcher::Wait() {
403 run_loop_.Run(); 432 run_loop_.Run();
404 } 433 }
405 434
406 void WebContentsDestroyedWatcher::WebContentsDestroyed() { 435 void WebContentsDestroyedWatcher::WebContentsDestroyed() {
407 run_loop_.Quit(); 436 run_loop_.Quit();
408 } 437 }
409 438
410 } // namespace content 439 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698