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

Unrevert cosmetic filtering #4269

Merged
merged 4 commits into from
Feb 4, 2020
Merged

Unrevert cosmetic filtering #4269

merged 4 commits into from
Feb 4, 2020

Conversation

antonok-edm
Copy link
Collaborator

@antonok-edm antonok-edm commented Dec 20, 2019

Closes brave/brave-browser#5381 (again...).

Original, now reverted, PR: #3303

This points to an updated adblock-rust-ffi version, which points to an updated adblock-rust version that makes CSS selector validation an optional feature. The GLIBC_2.29 error only occurred because of adblock-rust's cssparser library dependency calling f64::pow; this is no longer included in brave-core builds. It only really needs to be used by the CRX packager when building DAT files.

Apart from the original changes from #3303, there are a few additional commits from @snyderp and myself which are used to detect whether matching elements on a page are 1p content tor 3p whitespace before injecting a stylesheet to block them.

Submitter Checklist:

Test Plan:

CI on this PR should pass.
npm run test -- brave_browser_tests --filter="CosmeticFilteringEnabledTest.*"

Reviewer Checklist:

  • New files have MPL-2.0 license header.
  • Request a security/privacy review as needed.
  • Adequate test coverage exists to prevent regressions
  • Verify test plan is specified in PR before merging to source

After-merge Checklist:

  • The associated issue milestone is set to the smallest version that the
    changes has landed on.
  • All relevant documentation has been updated.

@antonok-edm antonok-edm self-assigned this Dec 20, 2019
@antonok-edm antonok-edm force-pushed the unrevert-cosmetic-filtering branch 2 times, most recently from f423a6d to 4a2ee6b Compare January 9, 2020 14:53
@bsclifton bsclifton added this to the 1.5.x - Nightly milestone Jan 9, 2020
@bsclifton bsclifton self-requested a review January 9, 2020 22:50
@bsclifton
Copy link
Member

Just rebased; let's watch CI here. Most importantly, we'll want to watch Linux CI. It was having problems with GLIBC

@bsclifton
Copy link
Member

@bridiver did you have any other concerns about this? You were an approver for the original work, IIRC. If things look good, go ahead and hit the approve button 😄

DEPS Outdated
@@ -1,7 +1,7 @@
use_relative_paths = True

deps = {
"vendor/adblock_rust_ffi": "https://github.com/brave/adblock-rust-ffi.git@89127a30655eaf54cf73794309846084ea8b91b9",
"vendor/adblock_rust_ffi": "https://github.com/brave/adblock-rust-ffi.git@pes-cosmetic-analysis",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we change this to a commit hash?

Copy link
Member

@petemill petemill left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This has some tests failing which seem related:

19:01:40  4 tests failed:
19:01:40      CosmeticFilteringEnabledTest.CosmeticFilteringCustomStyle (../../brave/components/brave_shields/browser/ad_block_service_browsertest.cc:906)
19:01:40      CosmeticFilteringEnabledTest.CosmeticFilteringDynamic (../../brave/components/brave_shields/browser/ad_block_service_browsertest.cc:876)
19:01:40      CosmeticFilteringEnabledTest.CosmeticFilteringSimple (../../brave/components/brave_shields/browser/ad_block_service_browsertest.cc:839)
19:01:40      CosmeticFilteringEnabledTest.CosmeticFilteringUnhide (../../brave/components/brave_shields/browser/ad_block_service_browsertest.cc:927)

@pes10k
Copy link
Contributor

pes10k commented Jan 22, 2020

@petemill just double checking, do @antonok-edm 's new tests address the concern?

@bsclifton
Copy link
Member

bsclifton commented Jan 23, 2020

@snyderp looks like tests all pass with the latest push! 🎉 So I think we're good to go here

As there is a cherry-picked commit from here in one of @petemill 's PRs that we're trying to expedite for 1.3, I'll let him do the honors of approving / merging 😄

@bsclifton
Copy link
Member

After merge, let's ping @snyderp / @ryanbr to address #4403 (comment) 😄

@petemill
Copy link
Member

petemill commented Feb 3, 2020

I rebased, fixed conflicts and pushed. Let's see what CI does (although tests passed locally). Giving the code another once-over.


const handleMutations = function (mutations: any[]) {
for (const aMutation of mutations) {
if (aMutation.type === 'attribute') {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this will work - shouldn't it be checking for attributes not attribute? We need to use proper TS types and not pass in any as the params, which would have caught this. I'm happy to fix this now.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@petemill yes from checking https://developer.mozilla.org/en-US/docs/Web/API/MutationObserver that looks right to me too (i.e. changing to attributes is correct).

antonok-edm and others added 3 commits February 3, 2020 16:40
… block component.

Reverts the revert of the oringal implementation: "Merge pull request #4255 from brave/bsc-revert-cosmetic-filtering"

This reverts commit fcfe38a, reversing
changes made to 950778a.

Fixes some conflicts as a result of master getting flag features and uses updated adblock-rust-ffi version which provides a slightly different API than for the original implementation.
Copy link
Member

@petemill petemill left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CI passed. @snyderp @antonok-edm please can you review my additions before merge: d2675a1

@petemill petemill requested a review from pes10k February 4, 2020 05:37
@petemill
Copy link
Member

petemill commented Feb 4, 2020

Awaiting final code owner review from @bridiver

@antonok-edm
Copy link
Collaborator Author

CI passed. @snyderp @antonok-edm please can you review my additions before merge: d2675a1

@petemill those changes look good to me!

"allowJs": true,
// convert jsx to react components
"jsx": "react",
"lib": [
"es6",
"dom",
"DOM.Iterable",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prevents Typescript from complaining when we iterate over DomList and provides values() in DOMTokenList

@petemill
Copy link
Member

petemill commented Feb 4, 2020

@antonok-edm @snyderp It's being asked what exactly fixes the issue that made this previously get reverted because of #4255 ?

base::Optional<base::Value> AdBlockBaseService::HostnameCosmeticResources(
const std::string& hostname) {
return base::JSONReader::Read(
this->ad_block_client_->hostnameCosmeticResources(hostname));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Callling this from UI thread was causing this quite nasty family of crashes brave/brave-browser#10907 - just wanted to emphasize that we should super carefully review multithreaded code

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@iefremov yikes! Are they sorted out now? What would be helpful for @antonok-edm or I do from here to sort things out?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pes10k fixing it here #6250

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gotcha, thanks a million @iefremov !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CI/skip-android Do not run CI builds for Android CI/skip-ios Do not run CI builds for iOS
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement cosmetic blocking [tracking]
7 participants