Commit 845a36ef authored by Doug Arnett's avatar Doug Arnett Committed by Commit Bot

Enabled NoScript Preview feature by default on Android

This is in conjunction with launching NoScript Preview
to Stable channel via Finch.

Bug: 876778
Change-Id: Ibc5f559b4c4b36555fc04966c8c44a4cccdb381d
Reviewed-on: https://chromium-review.googlesource.com/1185369
Commit-Queue: Doug Arnett <dougarnett@chromium.org>
Reviewed-by: default avatarRyan Sturm <ryansturm@chromium.org>
Cr-Commit-Position: refs/heads/master@{#585490}
parent be51aadb
......@@ -16,6 +16,7 @@
#include "base/single_thread_task_runner.h"
#include "base/test/scoped_feature_list.h"
#include "base/time/default_clock.h"
#include "build/build_config.h"
#include "components/blacklist/opt_out_blacklist/opt_out_blacklist_data.h"
#include "components/data_reduction_proxy/core/common/data_reduction_proxy_features.h"
#include "components/previews/content/previews_decider_impl.h"
......@@ -187,8 +188,12 @@ TEST_F(PreviewsServiceTest, TestLitePageProxyDecidesTransform) {
}
TEST_F(PreviewsServiceTest, TestNoScriptPreviewsEnabledByFeature) {
#if !defined(OS_ANDROID)
// For non-android, default is disabled.
EXPECT_FALSE(previews_decider_impl()->IsPreviewEnabled(
previews::PreviewsType::NOSCRIPT));
#endif // defined(OS_ANDROID)
base::test::ScopedFeatureList scoped_feature_list;
scoped_feature_list.InitAndEnableFeature(
previews::features::kNoScriptPreviews);
......
......@@ -223,7 +223,8 @@ TEST_F(PreviewsContentUtilTest, DetermineCommittedClientPreviewsState) {
TEST_F(PreviewsContentUtilTest,
DetermineCommittedClientPreviewsStateNoScriptCheckIfStillAllowed) {
base::test::ScopedFeatureList scoped_feature_list;
scoped_feature_list.InitFromCommandLine("Previews,ClientLoFi", std::string());
scoped_feature_list.InitFromCommandLine("Previews,ClientLoFi",
"NoScriptPreviews");
// NoScript not allowed at commit time so Client LoFi chosen:
EXPECT_EQ(content::PREVIEWS_OFF,
previews::DetermineCommittedClientPreviewsState(
......
......@@ -27,6 +27,7 @@
#include "base/threading/thread_task_runner_handle.h"
#include "base/time/default_clock.h"
#include "base/time/time.h"
#include "build/build_config.h"
#include "components/blacklist/opt_out_blacklist/opt_out_blacklist_data.h"
#include "components/blacklist/opt_out_blacklist/opt_out_blacklist_delegate.h"
#include "components/blacklist/opt_out_blacklist/opt_out_blacklist_item.h"
......@@ -836,7 +837,7 @@ TEST_F(PreviewsDeciderImplTest, ClientLoFiObeysHostBlackListFromServer) {
}
}
TEST_F(PreviewsDeciderImplTest, NoScriptDisallowedByDefault) {
TEST_F(PreviewsDeciderImplTest, NoScriptFeatureDefaultBehavior) {
base::test::ScopedFeatureList scoped_feature_list;
scoped_feature_list.InitAndEnableFeature(features::kPreviews);
InitializeUIService();
......@@ -850,13 +851,25 @@ TEST_F(PreviewsDeciderImplTest, NoScriptDisallowedByDefault) {
previews::params::GetECTThresholdForPreview(
previews::PreviewsType::NOSCRIPT),
std::vector<std::string>(), false));
#if defined(OS_ANDROID)
// Enabled by default on Android but no server whitelist.
histogram_tester.ExpectTotalCount("Previews.EligibilityReason.NoScript", 1);
histogram_tester.ExpectUniqueSample(
"Previews.EligibilityReason.NoScript",
static_cast<int>(
PreviewsEligibilityReason::HOST_NOT_WHITELISTED_BY_SERVER),
1);
#else // !defined(OS_ANDROID)
// Disabled by default on non-Android.
histogram_tester.ExpectTotalCount("Previews.EligibilityReason.NoScript", 0);
#endif // defined(OS_ANDROID)
}
TEST_F(PreviewsDeciderImplTest, NoScriptAllowedByFeature) {
base::test::ScopedFeatureList scoped_feature_list;
scoped_feature_list.InitWithFeatures(
{features::kPreviews, features::kNoScriptPreviews}, {});
{features::kPreviews, features::kNoScriptPreviews},
{features::kOptimizationHints});
InitializeUIService();
const struct {
......@@ -999,7 +1012,8 @@ TEST_F(PreviewsDeciderImplTest,
ResourceLoadingHintsDisallowedWithoutOptimizationHints) {
base::test::ScopedFeatureList scoped_feature_list;
scoped_feature_list.InitWithFeatures(
{features::kPreviews, features::kResourceLoadingHints}, {});
{features::kPreviews, features::kResourceLoadingHints},
{features::kOptimizationHints});
InitializeUIService();
network_quality_estimator()->set_effective_connection_type(
......@@ -1314,7 +1328,8 @@ TEST_F(PreviewsDeciderImplTest, LogDecisionMadeBlacklistStatusesDefault) {
TEST_F(PreviewsDeciderImplTest, IsURLAllowedForPreviewBlacklistStatuses) {
base::test::ScopedFeatureList scoped_feature_list;
scoped_feature_list.InitWithFeatures(
{features::kPreviews, features::kNoScriptPreviews}, {});
{features::kPreviews, features::kNoScriptPreviews},
{features::kOptimizationHints});
InitializeUIService();
auto expected_type = PreviewsType::NOSCRIPT;
......
......@@ -37,8 +37,14 @@ const base::Feature kClientLoFi {
};
// Enables the NoScript previews for Android.
const base::Feature kNoScriptPreviews{"NoScriptPreviews",
base::FEATURE_DISABLED_BY_DEFAULT};
const base::Feature kNoScriptPreviews {
"NoScriptPreviews",
#if defined(OS_ANDROID)
base::FEATURE_ENABLED_BY_DEFAULT
#else // !defined(OS_ANDROID)
base::FEATURE_DISABLED_BY_DEFAULT
#endif // defined(OS_ANDROID)
};
// Enables the Stale Previews timestamp on Previews infobars.
const base::Feature kStalePreviewsTimestamp{"StalePreviewsTimestamp",
......@@ -46,8 +52,14 @@ const base::Feature kStalePreviewsTimestamp{"StalePreviewsTimestamp",
// Enables the syncing of the Optimization Hints component, which provides
// hints for what Previews can be applied on a page load.
const base::Feature kOptimizationHints{"OptimizationHints",
base::FEATURE_DISABLED_BY_DEFAULT};
const base::Feature kOptimizationHints {
"OptimizationHints",
#if defined(OS_ANDROID)
base::FEATURE_ENABLED_BY_DEFAULT
#else // !defined(OS_ANDROID)
base::FEATURE_DISABLED_BY_DEFAULT
#endif // defined(OS_ANDROID)
};
// Enables Optimization Hints that are marked as experimental. Optimizations are
// marked experimental by setting an experiment name in the "experiment_name"
......
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