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..c93ba68c886a41a85d8a8623fb531c7a8cbfdf28 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" |
@@ -26,6 +29,7 @@ |
#include "content/public/browser/render_frame_host.h" |
#include "content/public/browser/render_process_host.h" |
#include "content/public/browser/web_contents.h" |
+#include "content/public/common/content_features.h" |
#include "content/public/common/content_switches.h" |
#include "content/public/common/process_type.h" |
#include "content/public/test/test_launcher.h" |
@@ -206,6 +210,31 @@ 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, |
+ std::string(features::kTopDocumentIsolation.name) + |
+ "<TopDocumentIsolation"); |
+ |
+ // Register a fake TopDocumentIsolation/BrowserTests study group. |
+ command_line->AppendSwitchASCII(switches::kForceFieldTrials, |
+ "TopDocumentIsolation/BrowserTests"); |
Łukasz Anforowicz
2017/06/30 16:50:20
I think it is okay to hardcode "TopDocumentIsolati
Charlie Reis
2017/06/30 23:28:49
I think this may be more of a question for the Fea
Łukasz Anforowicz
2017/07/01 00:10:53
Ok.
|
+ |
+ // 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:" + |
+ std::string(features::kTopDocumentIsolationModeParam) + "/" + |
+ std::to_string( |
+ static_cast<int>(features::TopDocumentIsolationMode::Xsite))); |
Łukasz Anforowicz
2017/06/30 16:50:20
In the latest patchset, I am not hardcoding a "1"
|
+} |
+ |
void ResetSchemesAndOriginsWhitelist() { |
url::Shutdown(); |
RegisterContentSchemes(false); |