зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1866169 [wpt PR 43315] - Implement URLPattern.hasRegExpGroups., a=testonly
Automatic update from web-platform-tests Implement URLPattern.hasRegExpGroups. This allows authors to tell whether a pattern contains one or more regexp groups, which may limit the uses they're able to make of it. Bug: 1504650 Change-Id: I07b684788e921448b60c4ffee9cfe87585a794c3 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5054393 Reviewed-by: Shunya Shishido <sisidovski@chromium.org> Commit-Queue: Jeremy Roman <jbroman@chromium.org> Cr-Commit-Position: refs/heads/main@{#1228894} -- wpt-commits: 2cc9ec1abaae212d24e2587d89d8d641634d417d wpt-pr: 43315
This commit is contained in:
Родитель
2c383e6493
Коммит
a880e99e3c
|
@ -0,0 +1,18 @@
|
|||
test(() => {
|
||||
assert_implements('hasRegExpGroups' in URLPattern.prototype, "hasRegExpGroups is not implemented");
|
||||
assert_false(new URLPattern({}).hasRegExpGroups, "match-everything pattern");
|
||||
for (let component of ['protocol', 'username', 'password', 'hostname', 'port', 'pathname', 'search', 'hash']) {
|
||||
assert_false(new URLPattern({[component]: '*'}).hasRegExpGroups, `wildcard in ${component}`);
|
||||
assert_false(new URLPattern({[component]: ':foo'}).hasRegExpGroups, `segment wildcard in ${component}`);
|
||||
assert_false(new URLPattern({[component]: ':foo?'}).hasRegExpGroups, `optional segment wildcard in ${component}`);
|
||||
assert_true(new URLPattern({[component]: ':foo(hi)'}).hasRegExpGroups, `named regexp group in ${component}`);
|
||||
assert_true(new URLPattern({[component]: '(hi)'}).hasRegExpGroups, `anonymous regexp group in ${component}`);
|
||||
if (component !== 'protocol' && component !== 'port') {
|
||||
// These components are more narrow in what they accept in any case.
|
||||
assert_false(new URLPattern({[component]: 'a-{:hello}-z-*-a'}).hasRegExpGroups, `wildcards mixed in with fixed text and wildcards in ${component}`);
|
||||
assert_true(new URLPattern({[component]: 'a-(hi)-z-(lo)-a'}).hasRegExpGroups, `regexp groups mixed in with fixed text and wildcards in ${component}`);
|
||||
}
|
||||
}
|
||||
assert_false(new URLPattern({pathname: '/a/:foo/:baz?/b/*'}).hasRegExpGroups, "complex pathname with no regexp");
|
||||
assert_true(new URLPattern({pathname: '/a/:foo/:baz([a-z]+)?/b/*'}).hasRegExpGroups, "complex pathname with regexp");
|
||||
}, '');
|
|
@ -0,0 +1,2 @@
|
|||
// META: global=window,worker
|
||||
// META: script=resources/urlpattern-hasregexpgroups-tests.js
|
Загрузка…
Ссылка в новой задаче