| 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..f43cce32517ecd76131caeab1cc5d81dfc5b6653 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");
|
| +
|
| + // Set kTopDocumentIsolationModeParam to TopDocumentIsolationMode::CrossSite.
|
| + // 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::CrossSite)));
|
| +}
|
| +
|
| void ResetSchemesAndOriginsWhitelist() {
|
| url::Shutdown();
|
| RegisterContentSchemes(false);
|
|
|