Commit c813923e authored by Clark DuVall's avatar Clark DuVall Committed by Commit Bot

Fix WebApkIntegrationTests with network service on Android

These tests use MockCertVerifier, but due to the way WebApk activities
are launched, the setup is done before the network process is created,
and it would be very complicated to try to insert the MockCertVerifier
setup between when the network process is created and when the WebApk is
launched. Allowing the default_result for the MockCertVerifier to be set
with a flag lets the network process pick up the value when it gets
created.

Bug: 917467
Change-Id: I694247a189eacb5b4a290b9f78c9b6d60b689441
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1635198Reviewed-by: default avatarJohn Abd-El-Malek <jam@chromium.org>
Commit-Queue: Clark DuVall <cduvall@chromium.org>
Cr-Commit-Position: refs/heads/master@{#664333}
parent b52d7cf5
...@@ -398,6 +398,7 @@ bool UtilityProcessHost::StartProcess() { ...@@ -398,6 +398,7 @@ bool UtilityProcessHost::StartProcess() {
switches::kUseFakeMjpegDecodeAccelerator, switches::kUseFakeMjpegDecodeAccelerator,
switches::kUseFileForFakeVideoCapture, switches::kUseFileForFakeVideoCapture,
switches::kUseMockCertVerifierForTesting, switches::kUseMockCertVerifierForTesting,
switches::kMockCertVerifierDefaultResultForTesting,
switches::kUtilityStartupDialog, switches::kUtilityStartupDialog,
switches::kUseGL, switches::kUseGL,
switches::kV, switches::kV,
......
...@@ -576,6 +576,10 @@ const char kMaxUntiledLayerWidth[] = "max-untiled-layer-width"; ...@@ -576,6 +576,10 @@ const char kMaxUntiledLayerWidth[] = "max-untiled-layer-width";
// Indicates the utility process should run with a message loop type of UI. // Indicates the utility process should run with a message loop type of UI.
const char kMessageLoopTypeUi[] = "message-loop-type-ui"; const char kMessageLoopTypeUi[] = "message-loop-type-ui";
// Set the default result for MockCertVerifier. This only works in test code.
const char kMockCertVerifierDefaultResultForTesting[] =
"mock-cert-verifier-default-result-for-testing";
// Use a Mojo-based LocalStorage implementation. // Use a Mojo-based LocalStorage implementation.
const char kMojoLocalStorage[] = "mojo-local-storage"; const char kMojoLocalStorage[] = "mojo-local-storage";
......
...@@ -176,6 +176,7 @@ CONTENT_EXPORT extern const char kMessageLoopTypeUi[]; ...@@ -176,6 +176,7 @@ CONTENT_EXPORT extern const char kMessageLoopTypeUi[];
CONTENT_EXPORT extern const char kMHTMLGeneratorOption[]; CONTENT_EXPORT extern const char kMHTMLGeneratorOption[];
CONTENT_EXPORT extern const char kMHTMLSkipNostoreMain[]; CONTENT_EXPORT extern const char kMHTMLSkipNostoreMain[];
CONTENT_EXPORT extern const char kMHTMLSkipNostoreAll[]; CONTENT_EXPORT extern const char kMHTMLSkipNostoreAll[];
CONTENT_EXPORT extern const char kMockCertVerifierDefaultResultForTesting[];
CONTENT_EXPORT extern const char kMojoLocalStorage[]; CONTENT_EXPORT extern const char kMojoLocalStorage[];
CONTENT_EXPORT extern const char kNetworkQuietTimeout[]; CONTENT_EXPORT extern const char kNetworkQuietTimeout[];
CONTENT_EXPORT extern const char kNoZygote[]; CONTENT_EXPORT extern const char kNoZygote[];
......
...@@ -28,6 +28,13 @@ void ContentMockCertVerifier::CertVerifier::set_default_result( ...@@ -28,6 +28,13 @@ void ContentMockCertVerifier::CertVerifier::set_default_result(
int default_result) { int default_result) {
verifier_->set_default_result(default_result); verifier_->set_default_result(default_result);
// Set the default result as a flag in case the FeatureList has not been
// initialized yet and we don't know if network service will run out of
// process.
base::CommandLine::ForCurrentProcess()->AppendSwitchASCII(
switches::kMockCertVerifierDefaultResultForTesting,
base::NumberToString(default_result));
if (!base::FeatureList::IsEnabled(network::features::kNetworkService) || if (!base::FeatureList::IsEnabled(network::features::kNetworkService) ||
IsInProcessNetworkService()) { IsInProcessNetworkService()) {
return; return;
...@@ -82,13 +89,6 @@ ContentMockCertVerifier::~ContentMockCertVerifier() {} ...@@ -82,13 +89,6 @@ ContentMockCertVerifier::~ContentMockCertVerifier() {}
void ContentMockCertVerifier::SetUpCommandLine( void ContentMockCertVerifier::SetUpCommandLine(
base::CommandLine* command_line) { base::CommandLine* command_line) {
// Check here instead of the constructor since some tests may set the feature
// flag in their constructor.
if (!base::FeatureList::IsEnabled(network::features::kNetworkService) ||
IsInProcessNetworkService()) {
return;
}
// Enable the MockCertVerifier in the network process via a switch. This is // Enable the MockCertVerifier in the network process via a switch. This is
// because it's too early to call the service manager at this point (it's not // because it's too early to call the service manager at this point (it's not
// created yet), and by the time we can call the service manager in // created yet), and by the time we can call the service manager in
......
...@@ -81,6 +81,16 @@ class NetworkServiceTestHelper::NetworkServiceTestImpl ...@@ -81,6 +81,16 @@ class NetworkServiceTestHelper::NetworkServiceTestImpl
mock_cert_verifier_ = std::make_unique<net::MockCertVerifier>(); mock_cert_verifier_ = std::make_unique<net::MockCertVerifier>();
network::NetworkContext::SetCertVerifierForTesting( network::NetworkContext::SetCertVerifierForTesting(
mock_cert_verifier_.get()); mock_cert_verifier_.get());
// The default result may be set using a command line flag.
std::string default_result =
base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
switches::kMockCertVerifierDefaultResultForTesting);
int default_result_int = 0;
if (!default_result.empty() &&
base::StringToInt(default_result, &default_result_int)) {
mock_cert_verifier_->set_default_result(default_result_int);
}
} }
} }
......
...@@ -8,9 +8,3 @@ ...@@ -8,9 +8,3 @@
-org.chromium.chrome.browser.FeaturesAnnotationsTest.testFeaturesAddToExistingFlags -org.chromium.chrome.browser.FeaturesAnnotationsTest.testFeaturesAddToExistingFlags
-org.chromium.chrome.browser.FeaturesAnnotationsTest.testFeaturesDoNotRemoveExistingFlags -org.chromium.chrome.browser.FeaturesAnnotationsTest.testFeaturesDoNotRemoveExistingFlags
-org.chromium.chrome.browser.FeaturesAnnotationsTest.testFeaturesSetExistingFlags -org.chromium.chrome.browser.FeaturesAnnotationsTest.testFeaturesSetExistingFlags
# http://crbug.com/917467
-org.chromium.chrome.browser.webapps.WebApkIntegrationTest.testActivateWebApk
-org.chromium.chrome.browser.webapps.WebApkIntegrationTest.testLaunchAndNavigateOffOrigin
-org.chromium.chrome.browser.webapps.WebApkIntegrationTest.testLaunchAndNavigationInNewWindowOffandInOrigin
-org.chromium.chrome.browser.webapps.WebApkIntegrationTest.testLaunchAndOpenNewWindowInOrigin
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment