1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
9 * A URL match pattern as used by the WebExtension and Chrome extension APIs.
11 * A match pattern is a string with one of the following formats:
14 * The literal string "<all_urls>" matches any URL with a supported
17 * - <proto>://<host>/<path>
18 * A URL pattern with the following placeholders:
21 * The protocol to match, or "*" to match either "http" or "https".
23 * The hostname to match. May be either a complete, literal hostname to
24 * match a specific host, the wildcard character "*", to match any host,
25 * or a subdomain pattern, with "*." followed by a domain name, to match
26 * that domain name or any subdomain thereof.
28 * A glob pattern for paths to match. A "*" may appear anywhere within
29 * the path, and will match any string of characters. If no "*" appears,
30 * the URL path must exactly match the pattern path.
32 [ChromeOnly, Exposed=Window]
33 interface MatchPattern {
35 constructor(DOMString pattern, optional MatchPatternOptions options = {});
38 * Returns true if the given URI matches the pattern.
40 * If explicit is true, only explicit domain matches, without wildcards, are
44 boolean matches(URI uri, optional boolean explicit = false);
47 boolean matches(DOMString url, optional boolean explicit = false);
50 * Returns true if a URL exists which a) would be able to access the given
51 * cookie, and b) would be matched by this match pattern.
53 boolean matchesCookie(Cookie cookie);
56 * Returns true if this pattern will match any host which would be matched
57 * by the given pattern.
59 boolean subsumes(MatchPattern pattern);
62 * Returns true if this pattern will match any host which would be matched
63 * by the given pattern, ignoring the scheme.
65 boolean subsumesDomain(MatchPattern pattern);
68 * Returns true if there is any host which would be matched by both this
69 * pattern and the given pattern.
71 boolean overlaps(MatchPattern pattern);
74 * The match pattern string represented by this pattern.
77 readonly attribute DOMString pattern;
80 * Whether the match pattern matches all http(s) URLs.
83 readonly attribute boolean matchesAllWebUrls;
87 * A set of MatchPattern objects, which implements the MatchPattern API and
88 * matches when any of its sub-patterns matches.
90 [ChromeOnly, Exposed=Window]
91 interface MatchPatternSet {
93 constructor(sequence<(DOMString or MatchPattern)> patterns, optional MatchPatternOptions options = {});
96 * Returns true if the given URI matches any sub-pattern.
98 * If explicit is true, only explicit domain matches, without wildcards, are
102 boolean matches(URI uri, optional boolean explicit = false);
105 boolean matches(DOMString url, optional boolean explicit = false);
108 * Returns true if any sub-pattern matches the given cookie.
110 boolean matchesCookie(Cookie cookie);
113 * Returns true if any sub-pattern subsumes the given pattern.
115 boolean subsumes(MatchPattern pattern);
118 * Returns true if any sub-pattern subsumes the given pattern,
119 * ignoring any of the schemes in the patterns.
121 boolean subsumesDomain(MatchPattern pattern);
124 * Returns true if any sub-pattern overlaps the given pattern.
126 boolean overlaps(MatchPattern pattern);
129 * Returns true if any sub-pattern overlaps any sub-pattern the given
132 boolean overlaps(MatchPatternSet patternSet);
135 * Returns true if any sub-pattern overlaps *every* sub-pattern in the given
138 boolean overlapsAll(MatchPatternSet patternSet);
140 [Cached, Constant, Frozen]
141 readonly attribute sequence<MatchPattern> patterns;
144 * Whether all http(s) URLs are matched by any of the sub-patterns.
147 readonly attribute boolean matchesAllWebUrls;
150 dictionary MatchPatternOptions {
152 * If true, the path portion of the pattern is ignored, and replaced with a
153 * wildcard. The `pattern` property is updated to reflect this.
155 boolean ignorePath = false;
158 * If true, the set of schemes this pattern can match is restricted to
159 * those accessible by WebExtensions.
161 boolean restrictSchemes = true;