Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
test: update WPT for urlpattern to 3ffda23e5a
  • Loading branch information
nodejs-github-bot committed Jun 1, 2025
commit aa995258d1415b117b9e882d5d9f42b4717e71a9
2 changes: 1 addition & 1 deletion test/fixtures/wpt/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Last update:
- resources: https://github.com/web-platform-tests/wpt/tree/1e140d63ec/resources
- streams: https://github.com/web-platform-tests/wpt/tree/bc9dcbbf1a/streams
- url: https://github.com/web-platform-tests/wpt/tree/9504a83e01/url
- urlpattern: https://github.com/web-platform-tests/wpt/tree/f07d05f49c/urlpattern
- urlpattern: https://github.com/web-platform-tests/wpt/tree/3ffda23e5a/urlpattern
- user-timing: https://github.com/web-platform-tests/wpt/tree/5ae85bf826/user-timing
- wasm/jsapi: https://github.com/web-platform-tests/wpt/tree/cde25e7e3c/wasm/jsapi
- wasm/webapi: https://github.com/web-platform-tests/wpt/tree/fd1b23eeaa/wasm/webapi
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
[
{
"pattern": { "pathname": "/foo" },
"component": "invalid",
"groups": {},
"expected": null
},
{
"pattern": { "pathname": "/foo" },
"component": "pathname",
"groups": {},
"expected": "/foo"
},
{
"pattern": { "pathname": "/:foo" },
"component": "pathname",
"groups": { "foo": "bar" },
"expected": "/bar"
},
{
"pattern": { "pathname": "/:foo" },
"component": "pathname",
"groups": { "foo": "🍅" },
"expected": "/%F0%9F%8D%85"
},
{
"pattern": { "hostname": "{:foo}.example.com" },
"component": "hostname",
"groups": { "foo": "🍅" },
"expected": "xn--fi8h.example.com"
},
{
"pattern": { "pathname": "/:foo" },
"component": "pathname",
"groups": {},
"expected": null
},
{
"pattern": { "pathname": "/foo/:bar" },
"component": "pathname",
"groups": { "bar": "baz" },
"expected": "/foo/baz"
},
{
"pattern": { "pathname": "/foo:bar" },
"component": "pathname",
"groups": { "bar": "baz" },
"expected": "/foobaz"
},
{
"pattern": { "pathname": "/:foo/:bar" },
"component": "pathname",
"groups": { "foo": "baz", "bar": "qux" },
"expected": "/baz/qux"
},
{
"pattern": "https://example.com/:foo",
"component": "pathname",
"groups": { "foo": " " },
"expected": "/%20"
},
{
"pattern": "original-scheme://example.com/:foo",
"component": "pathname",
"groups": { "foo": " " },
"expected": "/ "
},
{
"pattern": { "pathname": "/:foo" },
"component": "pathname",
"groups": { "foo": "bar/baz" },
"expected": null
},
{
"pattern": { "pathname": "*" },
"component": "pathname",
"groups": {},
"expected": null
},
{
"pattern": { "pathname": "/{foo}+" },
"component": "pathname",
"groups": {},
"expected": null
},
{
"pattern": { "pathname": "/{foo}?" },
"component": "pathname",
"groups": {},
"expected": null
},
{
"pattern": { "pathname": "/{foo}*" },
"component": "pathname",
"groups": {},
"expected": null
},
{
"pattern": { "pathname": "/(regexp)" },
"component": "pathname",
"groups": {},
"expected": null
},
{
"pattern": { "pathname": "/([^\\/]+?)" },
"component": "pathname",
"groups": {},
"expected": null
},
{
"pattern": { "port": "([^\\:]+?)" },
"component": "port",
"groups": {},
"expected": null
}
]
26 changes: 26 additions & 0 deletions test/fixtures/wpt/urlpattern/urlpattern-generate.tentative.any.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// META: global=window,worker

function runTests(data) {
for (let entry of data) {
test(function () {
const pattern = new URLPattern(entry.pattern);

if (entry.expected === null) {
assert_throws_js(TypeError, _ => pattern.generate(entry.component, entry.groups),
'generate() should fail with TypeError');
return;
}

const result = pattern.generate(entry.component, entry.groups);
assert_equals(result, entry.expected);
}, `Pattern: ${JSON.stringify(entry.pattern)} ` +
`Component: ${entry.component} ` +
`Groups: ${JSON.stringify(entry.groups)}`);
}
}

promise_test(async function () {
const response = await fetch('resources/urlpattern-generate-test-data.json');
const data = await response.json();
runTests(data);
}, 'Loading data...');
2 changes: 1 addition & 1 deletion test/fixtures/wpt/versions.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
"path": "url"
},
"urlpattern": {
"commit": "f07d05f49c679a62dd112e18aa07405859745952",
"commit": "3ffda23e5af7c59590b17c2710a22efd22dd4973",
"path": "urlpattern"
},
"user-timing": {
Expand Down
Loading