Closed Bug 1395278 Opened 2 years ago Closed 2 years ago

Expose MatchPattern API to WebExtensions


(WebExtensions :: General, defect, P5)



(Not tracked)



(Reporter: salar2k, Unassigned)


(Whiteboard: [design-decision-denied])

User Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:55.0) Gecko/20100101 Firefox/55.0
Build ID: 20170824053622

Expected results:

It would be very helpful to expose MatchPattern API to WebExtensions both in extension context and PAC script context.
This is quite useful for proxies.

My suggestion is an API like this:

if( browser.matchPattern.matches("*://","") ){
// ...

or an efficient one:

var match = new MatchPattern("*://");
match.matches(""); //        < true
match.matches(""); //        < false

(the API:
Component: Untriaged → WebExtensions: General
Product: Firefox → Toolkit
Priority: -- → P5
Whiteboard: [design-decision-needed]
Hi Salar, this has been added to the agenda for the February 6, 2018 WebExtensions APIs triage. Would you be able to join us? 

Here’s a quick overview of what to expect at the triage: 

* We normally spend 5 minutes per bug
* The more information in the bug, the better
* The goal of the triage is to give a general thumbs up or thumbs down on a proposal; we won't be going deep into implementation details

Relevant Links: 

* Wiki for the meeting:
* Meeting agenda:
* Vision doc for WebExtensions:
Flags: needinfo?(aswan)
Whiteboard: [design-decision-needed] → [design-decision-denied]
During the meeting yesterday we discussed the fact that MatchPattern is currently tailored to some specific uses inside the WebExtensions framework (eg the list of protocol schemes that * matches) so exposing this API would mean either generalizing it or documenting and freezing the current API.  The consensus was that this wouldn't provide enough benefit to justify doing either of those.

Note that you scan do most (all?) of what MatchPattern does with the DOM URL API:

Your example from the description could be written something like:
function match(url) {
  return new URL(url).hostname == "";
  // or:
  return new URL(url).hostname.endsWith("");
Closed: 2 years ago
Resolution: --- → WONTFIX
Flags: needinfo?(aswan)
Product: Toolkit → WebExtensions
You need to log in before you can comment on or make changes to this bug.