Commit 6b5662c4 authored by Colin Blundell's avatar Colin Blundell Committed by Commit Bot

[Android] Alter ExternalNavigationHandlerTest's overriding of feature

Currently ExternalNavigationHandlerTest overrides the value of a
feature in ChromeFeatureList.java via the functionality that the latter
supports for enabling features in test contexts. However, we will be
porting the feature in question to be defined via a //components-level
ExternalIntentsFeatureList.java that will be as minimal as possible
(see crbug.com/1060097 for context); in particular, we do not want to
have to port over the functionality that supports enabling the feature
in a test. Thus, this CL changes the test to enable the production
functionality in question via an explicit testing API on
ExternalNavigationHandler.java.

Note that all of this will go away if/once the functionality is enabled
by default and the feature is removed altogether, which is work under
development (see crbug.com/839751).

Bug: 1031465
Change-Id: Ibcdf9e0e72b7c7564ee067625af7e0f4bb663d69
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2093607
Commit-Queue: Colin Blundell <blundell@chromium.org>
Reviewed-by: default avatarMichael Thiessen <mthiesse@chromium.org>
Cr-Commit-Position: refs/heads/master@{#749097}
parent eb30effd
......@@ -358,6 +358,13 @@ public class ExternalNavigationHandler {
return false;
}
/** Wrapper of check against the feature to support overriding for testing. */
@VisibleForTesting
boolean blockExternalFormRedirectsWithoutGesture() {
return ChromeFeatureList.isEnabled(
ChromeFeatureList.INTENT_BLOCK_EXTERNAL_FORM_REDIRECT_NO_GESTURE);
}
/**
* http://crbug.com/149218: We want to show the intent picker for ordinary links, providing
* the link is not an incoming intent from another application, unless it's a redirect.
......@@ -383,8 +390,7 @@ public class ExternalNavigationHandler {
// TODO(tedchoc): Remove the ChromeFeatureList check once we verify this change does
// not break the world.
if (isRedirectFromFormSubmit && !incomingIntentRedirect && !params.hasUserGesture()
&& ChromeFeatureList.isEnabled(
ChromeFeatureList.INTENT_BLOCK_EXTERNAL_FORM_REDIRECT_NO_GESTURE)) {
&& blockExternalFormRedirectsWithoutGesture()) {
if (DEBUG) {
Log.i(TAG,
"Incoming form intent attempting to redirect without "
......
......@@ -59,8 +59,7 @@ import java.util.regex.Pattern;
// clang-format off
@DisableIf.Build(message = "Flaky on K - see https://crbug.com/851444",
sdk_is_less_than = Build.VERSION_CODES.LOLLIPOP)
@Features.EnableFeatures({ChromeFeatureList.CCT_EXTERNAL_LINK_HANDLING,
ChromeFeatureList.INTENT_BLOCK_EXTERNAL_FORM_REDIRECT_NO_GESTURE})
@Features.EnableFeatures({ChromeFeatureList.CCT_EXTERNAL_LINK_HANDLING})
public class ExternalNavigationHandlerTest {
// clang-format on
@Rule
......@@ -140,7 +139,12 @@ public class ExternalNavigationHandlerTest {
public ExternalNavigationHandlerTest() {
mDelegate = new TestExternalNavigationDelegate();
mUrlHandler = new ExternalNavigationHandler(mDelegate);
mUrlHandler = new ExternalNavigationHandler(mDelegate) {
@Override
boolean blockExternalFormRedirectsWithoutGesture() {
return true;
}
};
}
@Before
......
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