Skip to content

🚫 Prevent email popups from mailto: and tel: links#70

Open
mohamedmamdouh22 wants to merge 10 commits intomainfrom
APE-160
Open

🚫 Prevent email popups from mailto: and tel: links#70
mohamedmamdouh22 wants to merge 10 commits intomainfrom
APE-160

Conversation

@mohamedmamdouh22
Copy link
Contributor

  • Implemented MailtoTelBlockerHandler to intercept and block mailto: and tel: links at the network level.
  • Added JS-based click prevention to stop client-side interaction with mailto: and tel: links.
  • Enhanced E2E tests to verify that popups and navigation for email and phone links are properly blocked.
  • Verified no dialogs or popups are triggered during user interactions with these links.

@linear
Copy link

linear bot commented Sep 19, 2024

Comment on lines +364 to +372
if harness == playwright_harness:
await page.wait_for_load_state("domcontentloaded")
await page.evaluate("""
document.addEventListener('click', (event) => {
const target = event.target.closest('a[href^="mailto:"], a[href^="tel:"]');
if (target) {
event.preventDefault();
}
});
Copy link
Contributor

Choose a reason for hiding this comment

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

why do we need this if we have the route handler already?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

because the route handler will prevent the request from being sent, but it will not prevent the js code from being executed so the popup window will still appear, using this code, it will prevent the js code itself from opening a new window since its href starts with mailto or tel. @asim-shrestha

@mohamedmamdouh22 mohamedmamdouh22 marked this pull request as ready for review October 23, 2024 15:07
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.

2 participants