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

Unified 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 side-by-side diff with in-line comments
Download patch
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) {
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
+ // 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);

Powered by Google App Engine
This is Rietveld 408576698