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

Use MutationObserver to listen for DOM changes. #736

Merged
merged 4 commits into from
Jun 7, 2022
Merged

Use MutationObserver to listen for DOM changes. #736

merged 4 commits into from
Jun 7, 2022

Conversation

mrwensveen
Copy link
Contributor

  • Only run pattern detection on changed nodes.
  • Start the content script at document_start, otherwise we miss the window.load event (not 100% sure about this one)
  • Fix "Badging" feature test.

Please note the part with "XXX: ..". I needed to add a timeout for Selenium to work, but when manually testing the same page (badges.html) it worked fine without the timeout. It seems that browser.runtime.sendMessage is too early in some scenarios.

fixes #601

- Only run pattern detection on changed nodes.
- Start the content script at document_start,
otherwise we miss the  window.load event
@maxxcrawford maxxcrawford requested review from groovecoder and maxxcrawford and removed request for groovecoder March 4, 2021 19:19
@mrwensveen
Copy link
Contributor Author

Hi, so, I knew this would take some time to review but I didn't quite expect this to hang around for more than 7 months. Are there any plans to merge this PR?

@mrwensveen
Copy link
Contributor Author

mrwensveen commented May 26, 2022

Hi @maxxcrawford,

I merged the latest from the upstream main branch into my own branch (and PR) so that there aren't any merge conflicts.

I do see a failing test, which I would like to look at. How do I run these tests locally? Or is there another way to look at the test result and fix this problem? It looks like I already fixed that problem in the 2nd commit, so there shouldn't be anything in the way to merge this.

Cheers, Matthijs

@maxxcrawford
Copy link
Collaborator

@codemist Can you incorporate this PR into your iframe work? I'd love to merge this in. Let's sync and see if we should merge this in as is first, and you solve conflicts from your side.

@maxxcrawford
Copy link
Collaborator

Hi @maxxcrawford,

I merged the latest from the upstream main branch into my own branch (and PR) so that there aren't any merge conflicts.

I do see a failing test, which I would like to look at. How do I run these tests locally? Or is there another way to look at the test result and fix this problem? It looks like I already fixed that problem in the 2nd commit, so there shouldn't be anything in the way to merge this.

Cheers, Matthijs

@mrwensveen Thanks for the work on this. We will incorporate this in our next release!

@maxxcrawford maxxcrawford self-assigned this May 26, 2022
@maxxcrawford maxxcrawford requested review from codemist and removed request for groovecoder May 26, 2022 14:25
Copy link
Collaborator

@codemist codemist left a comment

Choose a reason for hiding this comment

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

Tested this and it worked except for missing FBC icon on email fields. On L702, patternDetection(EMAIL_PATTERN_DETECTION_SELECTORS, "email") is missing an argument, should be patternDetection(EMAIL_PATTERN_DETECTION_SELECTORS, "email", target).

@mrwensveen
Copy link
Contributor Author

Thanks @codemist! Should be fixed now.

Copy link
Collaborator

@maxxcrawford maxxcrawford left a comment

Choose a reason for hiding this comment

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

@mrwensveen Thank you for this PR! This looks good to ship. I had one nit comment, but we can resolve it in a future PR.

Commented using conventional comments language

Comment on lines +78 to +82
const OBSERVER_ATTRIBUTES = [
"action", "aria-label", "class",
"data-action", "data-bfa-network", "data-destination", "data-login-with-facebook",
"data-oauthserver", "data-partner", "data-tag", "data-test-id", "data-tracking",
"href", "id", "title"];
Copy link
Collaborator

Choose a reason for hiding this comment

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

praise: This is so much cleaner to watch these attrs, rather the whole, dang DOM.

Comment on lines 761 to 763
} else {
contentScriptInit(true);
// contentScriptInit(true);
}
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 remove this entire else statement, if not in use?

}

}

// Cross-browser implementation of element.addEventListener()
function addPassiveWindowOnloadListener() {
window.addEventListener("load", function() {
CheckIfURLShouldBeBlocked();
// XXX: Work around slow test startup.
Copy link
Collaborator

Choose a reason for hiding this comment

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

suggestion: (non-blocking) Can we change this from XXX to TODO/FIXME?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Very slow performance on page with Facebook Container extension enabled
3 participants