Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable cosmetic filtering by default #4511

Merged
merged 1 commit into from
Feb 14, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 10 additions & 11 deletions components/brave_shields/browser/ad_block_service_browsertest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -788,19 +788,18 @@ IN_PROC_BROWSER_TEST_F(AdBlockServiceTest, RedirectRulesAreRespected) {
EXPECT_EQ(browser()->profile()->GetPrefs()->GetUint64(kAdsBlocked), 1ULL);
}

class CosmeticFilteringEnabledTest : public AdBlockServiceTest {
class CosmeticFilteringDisabledTest : public AdBlockServiceTest {
public:
CosmeticFilteringEnabledTest() {
feature_list_.InitAndEnableFeature(kBraveAdblockCosmeticFiltering);
CosmeticFilteringDisabledTest() {
feature_list_.InitAndDisableFeature(kBraveAdblockCosmeticFiltering);
}

private:
base::test::ScopedFeatureList feature_list_;
};

// Ensure no cosmetic filtering occurs when the feature flag has not been
// enabled
IN_PROC_BROWSER_TEST_F(AdBlockServiceTest, CosmeticFilteringSimple) {
// Ensure no cosmetic filtering occurs when the feature flag is disabled
IN_PROC_BROWSER_TEST_F(CosmeticFilteringDisabledTest, CosmeticFilteringSimple) {
UpdateAdBlockInstanceWithRules(
"b.com###ad-banner\n"
"##.ad");
Expand Down Expand Up @@ -837,7 +836,7 @@ IN_PROC_BROWSER_TEST_F(AdBlockServiceTest, CosmeticFilteringSimple) {
}

// Test simple cosmetic filtering
IN_PROC_BROWSER_TEST_F(CosmeticFilteringEnabledTest, CosmeticFilteringSimple) {
IN_PROC_BROWSER_TEST_F(AdBlockServiceTest, CosmeticFilteringSimple) {
UpdateAdBlockInstanceWithRules(
"b.com###ad-banner\n"
"##.ad");
Expand Down Expand Up @@ -874,7 +873,7 @@ IN_PROC_BROWSER_TEST_F(CosmeticFilteringEnabledTest, CosmeticFilteringSimple) {
}

// Test cosmetic filtering ignores content determined to be 1st party
IN_PROC_BROWSER_TEST_F(CosmeticFilteringEnabledTest,
IN_PROC_BROWSER_TEST_F(AdBlockServiceTest,
CosmeticFilteringProtect1p) {
UpdateAdBlockInstanceWithRules("b.com##.fpsponsored\n");

Expand All @@ -896,7 +895,7 @@ IN_PROC_BROWSER_TEST_F(CosmeticFilteringEnabledTest,
}

// Test cosmetic filtering on elements added dynamically
IN_PROC_BROWSER_TEST_F(CosmeticFilteringEnabledTest, CosmeticFilteringDynamic) {
IN_PROC_BROWSER_TEST_F(AdBlockServiceTest, CosmeticFilteringDynamic) {
UpdateAdBlockInstanceWithRules("##.blockme");

WaitForBraveExtensionShieldsDataReady();
Expand Down Expand Up @@ -925,7 +924,7 @@ IN_PROC_BROWSER_TEST_F(CosmeticFilteringEnabledTest, CosmeticFilteringDynamic) {
}

// Test custom style rules
IN_PROC_BROWSER_TEST_F(CosmeticFilteringEnabledTest,
IN_PROC_BROWSER_TEST_F(AdBlockServiceTest,
CosmeticFilteringCustomStyle) {
UpdateAdBlockInstanceWithRules("b.com##.ad:style(padding-bottom: 10px)");

Expand All @@ -947,7 +946,7 @@ IN_PROC_BROWSER_TEST_F(CosmeticFilteringEnabledTest,
}

// Test rules overridden by hostname-specific exception rules
IN_PROC_BROWSER_TEST_F(CosmeticFilteringEnabledTest, CosmeticFilteringUnhide) {
IN_PROC_BROWSER_TEST_F(AdBlockServiceTest, CosmeticFilteringUnhide) {
UpdateAdBlockInstanceWithRules(
"##.ad\n"
"b.com#@#.ad\n"
Expand Down
2 changes: 1 addition & 1 deletion components/brave_shields/common/features.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace features {

const base::Feature kBraveAdblockCosmeticFiltering{
"BraveAdblockCosmeticFiltering",
base::FEATURE_DISABLED_BY_DEFAULT};
base::FEATURE_ENABLED_BY_DEFAULT};

} // namespace features
} // namespace brave_shields