diff --git a/tests/wpt/urlpattern-generate-test-data.json b/tests/wpt/urlpattern-generate-test-data.json new file mode 100644 index 000000000..c118f0a73 --- /dev/null +++ b/tests/wpt/urlpattern-generate-test-data.json @@ -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 + } +] diff --git a/tests/wpt/urlpatterntestdata.json b/tests/wpt/urlpatterntestdata.json index 60a7b1fc6..a613b6a74 100644 --- a/tests/wpt/urlpatterntestdata.json +++ b/tests/wpt/urlpatterntestdata.json @@ -1121,6 +1121,41 @@ "hostname": { "input": "xn--caf-dma.com", "groups": {}} } }, + { + "pattern": ["http://\uD83D\uDEB2.com/"], + "inputs": ["http://\uD83D\uDEB2.com/"], + "exactly_empty_components": [ "port" ], + "expected_obj": { + "protocol": "http", + "hostname": "xn--h78h.com", + "pathname": "/" + }, + "expected_match": { + "protocol": { "input": "http", "groups": {}}, + "hostname": { "input": "xn--h78h.com", "groups": {}}, + "pathname": { "input": "/", "groups": {}} + } + }, + { + "pattern": ["http://\uD83D \uDEB2"], + "expected_obj": "error" + }, + { + "pattern": [{"hostname":"\uD83D \uDEB2"}], + "expected_obj": "error" + }, + { + "pattern": [{"pathname":"\uD83D \uDEB2"}], + "inputs": [], + "expected_obj": { + "pathname": "%EF%BF%BD%20%EF%BF%BD" + }, + "expected_match": null + }, + { + "pattern": [{"pathname":":\uD83D \uDEB2"}], + "expected_obj": "error" + }, { "pattern": [{"pathname":":a\uDB40\uDD00b"}], "inputs": [], @@ -1439,6 +1474,10 @@ "pathname": { "input": "8675309", "groups": { "number": "8675309" }} } }, + { + "pattern": [{ "pathname": "/(\\m)" }], + "expected_obj": "error" + }, { "pattern": [{ "pathname": "/foo!" }], "inputs": [{ "pathname": "/foo!" }], @@ -2928,5 +2967,29 @@ "search": { "input": "q=*&v=?&hmm={}&umm=()", "groups": {} }, "hash": { "input": "foo", "groups": {} } } + }, + { + "pattern": [{ "pathname": "/([[a-z]--a])" }], + "inputs": [{ "pathname": "/a" }], + "expected_match": null + }, + { + "pattern": [{ "pathname": "/([[a-z]--a])" }], + "inputs": [{ "pathname": "/z" }], + "expected_match": { + "pathname": { "input": "/z", "groups": { "0": "z" } } + } + }, + { + "pattern": [{ "pathname": "/([\\d&&[0-1]])" }], + "inputs": [{ "pathname": "/0" }], + "expected_match": { + "pathname": { "input": "/0", "groups": { "0": "0" } } + } + }, + { + "pattern": [{ "pathname": "/([\\d&&[0-1]])" }], + "inputs": [{ "pathname": "/3" }], + "expected_match": null } ]