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

Proposal: about: matching #755

Open
erosman opened this issue Jan 31, 2025 · 5 comments
Open

Proposal: about: matching #755

erosman opened this issue Jan 31, 2025 · 5 comments
Labels
needs-triage: chrome Chrome needs to assess this issue for the first time needs-triage: firefox Firefox needs to assess this issue for the first time needs-triage: safari Safari needs to assess this issue for the first time

Comments

@erosman
Copy link

erosman commented Jan 31, 2025

Proposal: about: matching

Background

Match patterns does not match about: URLs.
While some APIs such as Content scripts or scripting support about: matching via additional options (match_about_blank, match_origin_as_fallback), there are others that don't have such options.

menus/contextMenus is a commonly used example where documentUrlPatterns is insufficient for this purpose.

I recently needed to limit the context-menu to ['http://*/*', 'https://*/*','about:newtab', 'about:blank']. The only option is to omit documentUrlPatterns which results in the contextMenu appearing in many unwanted pages such as file://, toolbar popups, and extension pages.

Proposal

Provide a method to match about:newtab, about:blank, etc

Suggestions

A few possibilities:

  1. Include the ability to match about:newtab, about:blank and in Match patterns (preferable)
  2. Add additional matching options (e.g. similar to scripting) to APIs that don't have it
@github-actions github-actions bot added needs-triage: chrome Chrome needs to assess this issue for the first time needs-triage: firefox Firefox needs to assess this issue for the first time needs-triage: safari Safari needs to assess this issue for the first time labels Jan 31, 2025
@fregante

This comment has been minimized.

@xeenon
Copy link
Collaborator

xeenon commented Feb 1, 2025

menus/contextMenus is a commonly used example where documentUrlPatterns is insufficient for this purpose

It's not just insufficient, it's completely unsupported outside Firefox. There are at least 3 tickets like https://issues.chromium.org/issues/41305289 documenting this but they're all expired/closed.

Safari supports documentUrlPatterns.

@fregante
Copy link

fregante commented Feb 1, 2025

Safari supports documentUrlPatterns.

Indeed it appears to have been resolved since I first noticed this in 2021 (Safari 14.0.1) fregante/webext-permission-toggle#14

So it's just a Chrome issue

@fregante
Copy link

fregante commented Feb 1, 2025

I recently needed to limit the context-menu to ['http://*/*', 'https://*/*','about:newtab', 'about:blank'].

I think that allowing explicit 'about:blank' strings would be safer than a blanket about:* pattern:

  • no extension should probably have access to about:debugging or about:flags
  • it's easier to statically detect what an extension intends to alter/access

So the array of strings as you wrote it sounds good to me. Dropping match_about_blank would also be a good followup for MV4

fregante added a commit to fregante/webext-permission-toggle that referenced this issue Feb 1, 2025
@erosman
Copy link
Author

erosman commented Feb 1, 2025

I think that allowing explicit 'about:blank' strings would be safer than a blanket about:* pattern:

That is also what I meant (as per Proposal). I will update the topic to make it clearer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-triage: chrome Chrome needs to assess this issue for the first time needs-triage: firefox Firefox needs to assess this issue for the first time needs-triage: safari Safari needs to assess this issue for the first time
Projects
None yet
Development

No branches or pull requests

3 participants