Index: content/public/test/test_utils.cc |
diff --git a/content/public/test/test_utils.cc b/content/public/test/test_utils.cc |
index a50cc6cda21fed1742c92b5c79c1137dfa4b24fb..e4d90b8748ca8e53f327382173b713933df4a3ca 100644 |
--- a/content/public/test/test_utils.cc |
+++ b/content/public/test/test_utils.cc |
@@ -4,8 +4,10 @@ |
#include "content/public/test/test_utils.h" |
+#include <string> |
#include <utility> |
+#include "base/base_switches.h" |
#include "base/bind.h" |
#include "base/command_line.h" |
#include "base/location.h" |
@@ -19,6 +21,7 @@ |
#include "base/threading/thread_task_runner_handle.h" |
#include "base/values.h" |
#include "build/build_config.h" |
+#include "components/variations/variations_switches.h" |
#include "content/common/site_isolation_policy.h" |
#include "content/common/url_schemes.h" |
#include "content/public/browser/browser_child_process_host_iterator.h" |
@@ -206,6 +209,25 @@ void IsolateAllSitesForTesting(base::CommandLine* command_line) { |
command_line->AppendSwitch(switches::kSitePerProcess); |
} |
+void EnableTopDocumentIsolationForTesting(base::CommandLine* command_line) { |
+ // Enable top-document-isolation feature (features::kTopDocumentIsolation) |
+ // and associate it with a fake "TopDocumentIsolation" trial. |
+ command_line->AppendSwitchASCII( |
+ switches::kEnableFeatures, "top-document-isolation<TopDocumentIsolation"); |
+ |
+ // Register a fake TopDocumentIsolation/BrowserTests study group. |
+ command_line->AppendSwitchASCII(switches::kForceFieldTrials, |
+ "TopDocumentIsolation/BrowserTests"); |
+ |
+ // Set kTopDocumentIsolationModeParam to TopDocumentIsolationMode::Xsite. |
+ // This is not really needed for content_browsertests (which will go through |
+ // ShellContentBrowserClient::ShouldIsolateFrameFromMainContent), but is |
+ // needed for browser_tests and other tests that use |
+ // ChromeContentBrowserClient::ShouldIsolateFrameFromMainContent. |
+ command_line->AppendSwitchASCII(variations::switches::kForceFieldTrialParams, |
+ "TopDocumentIsolation.BrowserTests:mode/1"); |
+} |
+ |
void ResetSchemesAndOriginsWhitelist() { |
url::Shutdown(); |
RegisterContentSchemes(false); |