Skip to content
File

Blob: src/wpt/urlpattern-test.ts

typescript186 lines
1// Copyright (c) 2017-2022 Cloudflare, Inc.
2// Licensed under the Apache 2.0 license found in the LICENSE file or at:
3// https://opensource.org/licenses/Apache-2.0
4 
5import { type TestRunnerConfig } from 'harness/harness';
6 
7export default {
8 'urlpattern-hasregexpgroups.any.js': {
9 comment: 'urlpattern implementation will soon be replaced with ada-url',
10 expectedFailures: [
11 // Each of these *ought* to pass. They are included here because we
12 // know they currently do not. Each needs to be investigated.
13 '', // This file consists of one unnamed subtest
14 ],
15 },
16 'urlpattern.any.js': {
17 comment: 'urlpattern implementation will soon be replaced with ada-url',
18 disabledTests: [
19 // Windows uses MSVC std::regex which rejects \H as an invalid escape,
20 // causing the URLPattern constructor to throw (test passes). Linux std::regex
21 // treats \H as an identity escape so no throw occurs (test fails). Use
22 // disabledTests to avoid the cross-platform mismatch.
23 'Pattern: ["(\\\\H):"] Inputs: undefined',
24 ],
25 expectedFailures: [
26 // Each of these *ought* to pass. They are included here because we
27 // know they currently do not. Each needs to be investigated.
28 'Pattern: ["((?R)):"] Inputs: undefined',
29 'Pattern: [{"pathname":"/foo/bar","baseURL":"https://example.com?query#hash"}] Inputs: [{"pathname":"/foo/bar"}]',
30 'Pattern: [{"pathname":"/foo/bar","baseURL":"https://example.com?query#hash"}] Inputs: [{"hostname":"example.com","pathname":"/foo/bar"}]',
31 'Pattern: [{"pathname":"/foo/bar","baseURL":"https://example.com?query#hash"}] Inputs: [{"protocol":"https","hostname":"example.com","pathname":"/foo/bar"}]',
32 'Pattern: [{"pathname":"/foo/bar","baseURL":"https://example.com"}] Inputs: [{"protocol":"https","hostname":"example.com","pathname":"/foo/bar"}]',
33 'Pattern: [{"pathname":"/foo/bar","baseURL":"https://example.com"}] Inputs: [{"protocol":"https","hostname":"example.com","pathname":"/foo/bar/baz"}]',
34 'Pattern: [{"pathname":"/foo/bar","baseURL":"https://example.com?query#hash"}] Inputs: [{"protocol":"https","hostname":"example.com","pathname":"/foo/bar","search":"otherquery","hash":"otherhash"}]',
35 'Pattern: [{"pathname":"/foo/bar","baseURL":"https://example.com"}] Inputs: [{"protocol":"https","hostname":"example.com","pathname":"/foo/bar","search":"otherquery","hash":"otherhash"}]',
36 'Pattern: [{"pathname":"/foo/bar","baseURL":"https://example.com?otherquery#otherhash"}] Inputs: [{"protocol":"https","hostname":"example.com","pathname":"/foo/bar","search":"otherquery","hash":"otherhash"}]',
37 'Pattern: [{"pathname":"/foo/bar","baseURL":"https://example.com?query#hash"}] Inputs: ["https://example.com/foo/bar"]',
38 'Pattern: [{"pathname":"/foo/bar","baseURL":"https://example.com?query#hash"}] Inputs: ["https://example.com/foo/bar?otherquery#otherhash"]',
39 'Pattern: [{"pathname":"/foo/bar","baseURL":"https://example.com?query#hash"}] Inputs: ["https://example.com/foo/bar?query#hash"]',
40 'Pattern: [{"pathname":"/foo/bar","baseURL":"https://example.com?query#hash"}] Inputs: ["https://example.com/foo/bar/baz"]',
41 'Pattern: [{"pathname":"/foo/bar","baseURL":"https://example.com?query#hash"}] Inputs: ["https://other.com/foo/bar"]',
42 'Pattern: [{"pathname":"/foo/bar","baseURL":"https://example.com?query#hash"}] Inputs: ["http://other.com/foo/bar"]',
43 'Pattern: [{"pathname":"/foo/bar","baseURL":"https://example.com?query#hash"}] Inputs: [{"pathname":"/foo/bar","baseURL":"https://example.com"}]',
44 'Pattern: [{"pathname":"/foo/bar","baseURL":"https://example.com?query#hash"}] Inputs: [{"pathname":"/foo/bar","baseURL":"https://example.com?query#hash"}]',
45 'Pattern: [{"pathname":"/foo/bar","baseURL":"https://example.com?query#hash"}] Inputs: [{"pathname":"/foo/bar/baz","baseURL":"https://example.com"}]',
46 'Pattern: [{"pathname":"/foo/bar","baseURL":"https://example.com?query#hash"}] Inputs: [{"pathname":"/foo/bar","baseURL":"https://other.com"}]',
47 'Pattern: [{"pathname":"/foo/bar","baseURL":"https://example.com?query#hash"}] Inputs: [{"pathname":"/foo/bar","baseURL":"http://example.com"}]',
48 'Pattern: [{"pathname":"/foo/:bar?"}] Inputs: [{"pathname":"/foo"}]',
49 'Pattern: [{"pathname":"/foo/:bar*"}] Inputs: [{"pathname":"/foo"}]',
50 'Pattern: [{"pathname":"/foo/(.*)?"}] Inputs: [{"pathname":"/foo"}]',
51 'Pattern: [{"pathname":"/foo/*?"}] Inputs: [{"pathname":"/foo"}]',
52 'Pattern: [{"pathname":"/foo/(.*)*"}] Inputs: [{"pathname":"/foo"}]',
53 'Pattern: [{"pathname":"/foo/**"}] Inputs: [{"pathname":"/foo"}]',
54 'Pattern: [{"protocol":"(.*)"}] Inputs: [{"protocol":"café"}]',
55 'Pattern: [{"hostname":"xn--caf-dma.com"}] Inputs: [{"hostname":"café.com"}]',
56 'Pattern: [{"hostname":"café.com"}] Inputs: [{"hostname":"café.com"}]',
57 'Pattern: [{"protocol":"http","port":"80"}] Inputs: [{"protocol":"http","port":"80"}]',
58 'Pattern: [{"port":"(.*)"}] Inputs: [{"port":"invalid80"}]',
59 'Pattern: [{"pathname":"/foo/bar"}] Inputs: [{"pathname":"foo/bar"}]',
60 'Pattern: [{"pathname":"./foo/bar","baseURL":"https://example.com"}] Inputs: [{"pathname":"foo/bar","baseURL":"https://example.com"}]',
61 'Pattern: [{"pathname":"","baseURL":"https://example.com"}] Inputs: [{"pathname":"/","baseURL":"https://example.com"}]',
62 'Pattern: [{"pathname":"{/bar}","baseURL":"https://example.com/foo/"}] Inputs: [{"pathname":"./bar","baseURL":"https://example.com/foo/"}]',
63 'Pattern: [{"pathname":"\\\\/bar","baseURL":"https://example.com/foo/"}] Inputs: [{"pathname":"./bar","baseURL":"https://example.com/foo/"}]',
64 'Pattern: [{"pathname":"b","baseURL":"https://example.com/foo/"}] Inputs: [{"pathname":"./b","baseURL":"https://example.com/foo/"}]',
65 'Pattern: [{"pathname":"foo/bar","baseURL":"https://example.com"}] Inputs: ["https://example.com/foo/bar"]',
66 'Pattern: [{"pathname":":name.html","baseURL":"https://example.com"}] Inputs: ["https://example.com/foo.html"]',
67 'Pattern: [{"protocol":"javascript","pathname":"var x = 1;"}] Inputs: [{"protocol":"javascript","pathname":"var x = 1;"}]',
68 'Pattern: [{"protocol":"(data|javascript)","pathname":"var x = 1;"}] Inputs: [{"protocol":"javascript","pathname":"var x = 1;"}]',
69 'Pattern: [{"pathname":"var x = 1;"}] Inputs: [{"pathname":"var x = 1;"}]',
70 'Pattern: ["https://example.com:8080/foo?bar#baz"] Inputs: [{"pathname":"/foo","search":"bar","hash":"baz","baseURL":"https://example.com:8080"}]',
71 'Pattern: ["/foo?bar#baz","https://example.com:8080"] Inputs: [{"pathname":"/foo","search":"bar","hash":"baz","baseURL":"https://example.com:8080"}]',
72 'Pattern: ["http{s}?://{*.}?example.com/:product/:endpoint"] Inputs: ["https://sub.example.com/foo/bar"]',
73 'Pattern: ["https://example.com?foo"] Inputs: ["https://example.com/?foo"]',
74 'Pattern: ["https://example.com#foo"] Inputs: ["https://example.com/#foo"]',
75 'Pattern: ["https://example.com:8080?foo"] Inputs: ["https://example.com:8080/?foo"]',
76 'Pattern: ["https://example.com:8080#foo"] Inputs: ["https://example.com:8080/#foo"]',
77 'Pattern: ["https://example.com/?foo"] Inputs: ["https://example.com/?foo"]',
78 'Pattern: ["https://example.com/#foo"] Inputs: ["https://example.com/#foo"]',
79 'Pattern: ["https://example.com/*?foo"] Inputs: ["https://example.com/?foo"]',
80 'Pattern: ["https://example.com/*\\\\?foo"] Inputs: ["https://example.com/?foo"]',
81 'Pattern: ["https://example.com/:name?foo"] Inputs: ["https://example.com/bar?foo"]',
82 'Pattern: ["https://example.com/:name\\\\?foo"] Inputs: ["https://example.com/bar?foo"]',
83 'Pattern: ["https://example.com/(bar)?foo"] Inputs: ["https://example.com/bar?foo"]',
84 'Pattern: ["https://example.com/(bar)\\\\?foo"] Inputs: ["https://example.com/bar?foo"]',
85 'Pattern: ["https://example.com/{bar}?foo"] Inputs: ["https://example.com/bar?foo"]',
86 'Pattern: ["https://example.com/{bar}\\\\?foo"] Inputs: ["https://example.com/bar?foo"]',
87 'Pattern: ["https://example.com/"] Inputs: ["https://example.com:8080/"]',
88 'Pattern: ["data\\\\:foobar"] Inputs: ["data:foobar"]',
89 'Pattern: ["https://{sub.}?example.com/foo"] Inputs: ["https://example.com/foo"]',
90 'Pattern: ["https://(sub.)?example.com/foo"] Inputs: ["https://example.com/foo"]',
91 'Pattern: ["https://(sub.)?example(.com/)foo"] Inputs: ["https://example.com/foo"]',
92 'Pattern: ["https://(sub(?:.))?example.com/foo"] Inputs: ["https://example.com/foo"]',
93 'Pattern: ["file:///foo/bar"] Inputs: ["file:///foo/bar"]',
94 'Pattern: ["data:"] Inputs: ["data:"]',
95 'Pattern: ["foo://bar"] Inputs: ["foo://bad_url_browser_interop"]',
96 'Pattern: ["https://example.com/foo?bar#baz"] Inputs: [{"protocol":"https:","search":"?bar","hash":"#baz","baseURL":"http://example.com/foo"}]',
97 'Pattern: ["?bar#baz","https://example.com/foo"] Inputs: ["?bar#baz","https://example.com/foo"]',
98 'Pattern: ["?bar","https://example.com/foo#baz"] Inputs: ["?bar","https://example.com/foo#snafu"]',
99 'Pattern: ["#baz","https://example.com/foo?bar"] Inputs: ["#baz","https://example.com/foo?bar"]',
100 'Pattern: ["#baz","https://example.com/foo"] Inputs: ["#baz","https://example.com/foo"]',
101 'Pattern: ["https://foo\\\\:bar@example.com"] Inputs: ["https://foo:bar@example.com"]',
102 'Pattern: ["https://foo@example.com"] Inputs: ["https://foo@example.com"]',
103 'Pattern: ["https://\\\\:bar@example.com"] Inputs: ["https://:bar@example.com"]',
104 'Pattern: ["https://:user::pass@example.com"] Inputs: ["https://foo:bar@example.com"]',
105 'Pattern: ["https\\\\:foo\\\\:bar@example.com"] Inputs: ["https:foo:bar@example.com"]',
106 'Pattern: ["data\\\\:foo\\\\:bar@example.com"] Inputs: ["data:foo:bar@example.com"]',
107 'Pattern: ["https://foo{\\\\:}bar@example.com"] Inputs: ["https://foo:bar@example.com"]',
108 'Pattern: ["data{\\\\:}channel.html","https://example.com"] Inputs: ["https://example.com/data:channel.html"]',
109 'Pattern: ["http://[\\\\:\\\\:1]/"] Inputs: ["http://[::1]/"]',
110 'Pattern: ["http://[\\\\:\\\\:1]:8080/"] Inputs: ["http://[::1]:8080/"]',
111 'Pattern: ["http://[\\\\:\\\\:a]/"] Inputs: ["http://[::a]/"]',
112 'Pattern: ["http://[:address]/"] Inputs: ["http://[::1]/"]',
113 'Pattern: ["http://[\\\\:\\\\:AB\\\\::num]/"] Inputs: ["http://[::ab:1]/"]',
114 'Pattern: [{"hostname":"[\\\\:\\\\:AB\\\\::num]"}] Inputs: [{"hostname":"[::ab:1]"}]',
115 'Pattern: ["data\\\\:text/javascript,let x = 100/:tens?5;"] Inputs: ["data:text/javascript,let x = 100/5;"]',
116 'Pattern: [{"pathname":"/foo"},"https://example.com"] Inputs: undefined',
117 'Pattern: [{"pathname":":name*"}] Inputs: [{"pathname":"foobar"}]',
118 'Pattern: [{"pathname":":name+"}] Inputs: [{"pathname":"foobar"}]',
119 'Pattern: [{"pathname":":name"}] Inputs: [{"pathname":"foobar"}]',
120 'Pattern: [{"pathname":"(foo)(.*)"}] Inputs: [{"pathname":"foobarbaz"}]',
121 'Pattern: [{"pathname":"{(foo)bar}(.*)"}] Inputs: [{"pathname":"foobarbaz"}]',
122 'Pattern: [{"pathname":"(foo)?(.*)"}] Inputs: [{"pathname":"foobarbaz"}]',
123 'Pattern: [{"pathname":"{:foo}(.*)"}] Inputs: [{"pathname":"foobarbaz"}]',
124 'Pattern: [{"pathname":"{:foo}(barbaz)"}] Inputs: [{"pathname":"foobarbaz"}]',
125 'Pattern: [{"pathname":"{:foo}{(.*)}"}] Inputs: [{"pathname":"foobarbaz"}]',
126 'Pattern: [{"pathname":"{:foo}{bar(.*)}"}] Inputs: [{"pathname":"foobarbaz"}]',
127 'Pattern: [{"pathname":"{:foo}:bar(.*)"}] Inputs: [{"pathname":"foobarbaz"}]',
128 'Pattern: [{"pathname":"{:foo}?(.*)"}] Inputs: [{"pathname":"foobarbaz"}]',
129 'Pattern: [{"pathname":"{:foo\\\\bar}"}] Inputs: [{"pathname":"foobar"}]',
130 'Pattern: [{"pathname":"{:foo\\\\.bar}"}] Inputs: [{"pathname":"foo.bar"}]',
131 'Pattern: [{"pathname":"{:foo(foo)bar}"}] Inputs: [{"pathname":"foobar"}]',
132 'Pattern: [{"pathname":"{:foo}bar"}] Inputs: [{"pathname":"foobar"}]',
133 'Pattern: [{"pathname":":foo\\\\bar"}] Inputs: [{"pathname":"foobar"}]',
134 'Pattern: [{"pathname":":foo{}(.*)"}] Inputs: [{"pathname":"foobar"}]',
135 'Pattern: [{"pathname":":foo{}bar"}] Inputs: [{"pathname":"foobar"}]',
136 'Pattern: [{"pathname":":foo{}?bar"}] Inputs: [{"pathname":"foobar"}]',
137 'Pattern: [{"pathname":"*{}**?"}] Inputs: [{"pathname":"foobar"}]',
138 'Pattern: [{"pathname":":foo(baz)(.*)"}] Inputs: [{"pathname":"bazbar"}]',
139 'Pattern: [{"pathname":":foo(baz)bar"}] Inputs: [{"pathname":"bazbar"}]',
140 'Pattern: [{"pathname":"*/*"}] Inputs: [{"pathname":"foo/bar"}]',
141 'Pattern: [{"pathname":"*\\\\/*"}] Inputs: [{"pathname":"foo/bar"}]',
142 'Pattern: [{"pathname":"*/{*}"}] Inputs: [{"pathname":"foo/bar"}]',
143 'Pattern: [{"pathname":"./foo"}] Inputs: [{"pathname":"./foo"}]',
144 'Pattern: [{"pathname":"../foo"}] Inputs: [{"pathname":"../foo"}]',
145 'Pattern: [{"pathname":":foo./"}] Inputs: [{"pathname":"bar./"}]',
146 'Pattern: [{"pathname":":foo../"}] Inputs: [{"pathname":"bar../"}]',
147 'Pattern: [{"pathname":"/:foo\\\\bar"}] Inputs: [{"pathname":"/bazbar"}]',
148 'Pattern: ["https://example.com:8080/foo?bar#baz",{"ignoreCase":true}] Inputs: [{"pathname":"/FOO","search":"BAR","hash":"BAZ","baseURL":"https://example.com:8080"}]',
149 'Pattern: ["/foo?bar#baz","https://example.com:8080",{"ignoreCase":true}] Inputs: [{"pathname":"/FOO","search":"BAR","hash":"BAZ","baseURL":"https://example.com:8080"}]',
150 'Pattern: [{"search":"foo","baseURL":"https://example.com/a/+/b"}] Inputs: [{"search":"foo","baseURL":"https://example.com/a/+/b"}]',
151 'Pattern: [{"hash":"foo","baseURL":"https://example.com/?q=*&v=?&hmm={}&umm=()"}] Inputs: [{"hash":"foo","baseURL":"https://example.com/?q=*&v=?&hmm={}&umm=()"}]',
152 'Pattern: ["#foo","https://example.com/?q=*&v=?&hmm={}&umm=()"] Inputs: ["https://example.com/?q=*&v=?&hmm={}&umm=()#foo"]',
153 'Pattern: [{"pathname":"/([[a-z]--a])"}] Inputs: [{"pathname":"/a"}]',
154 'Pattern: [{"pathname":"/([[a-z]--a])"}] Inputs: [{"pathname":"/z"}]',
155 'Pattern: [{"pathname":"/([\\\\d&&[0-1]])"}] Inputs: [{"pathname":"/0"}]',
156 'Pattern: [{"pathname":"/([\\\\d&&[0-1]])"}] Inputs: [{"pathname":"/3"}]',
157 'Pattern: ["http://🚲.com/"] Inputs: ["http://🚲.com/"]',
158 'Pattern: [{"pathname":"\\ud83d \\udeb2"}] Inputs: []',
159 'Pattern: [{"pathname":"test/:a𐑐b"}] Inputs: [{"pathname":"test/foo"}]',
160 'Pattern: [{"hostname":"bad#hostname"}] Inputs: [{"hostname":"bad"}]',
161 'Pattern: [{"hostname":"bad/hostname"}] Inputs: [{"hostname":"bad"}]',
162 'Pattern: [{"hostname":"bad\\\\\\\\hostname"}] Inputs: [{"hostname":"badhostname"}]',
163 'Pattern: [{"hostname":"bad\\nhostname"}] Inputs: [{"hostname":"badhostname"}]',
164 'Pattern: [{"hostname":"bad\\rhostname"}] Inputs: [{"hostname":"badhostname"}]',
165 'Pattern: [{"hostname":"bad\\thostname"}] Inputs: [{"hostname":"badhostname"}]',
166 'Pattern: [{"port":"80"}] Inputs: [{"port":"8\\t0"}]',
167 'Pattern: [{"port":"80"}] Inputs: [{"port":"80x"}]',
168 'Pattern: [{"port":"80"}] Inputs: [{"port":"80?x"}]',
169 'Pattern: [{"port":"80"}] Inputs: [{"port":"80\\\\x"}]',
170 'Pattern: ["https://{sub.}?example{.com/}foo"] Inputs: ["https://example.com/foo"]',
171 'Pattern: [{"protocol":"http","hostname":"example.com/ignoredpath"}] Inputs: ["http://example.com/"]',
172 'Pattern: [{"protocol":"http","hostname":"example.com\\\\?ignoredsearch"}] Inputs: ["http://example.com/"]',
173 'Pattern: [{"protocol":"http","hostname":"example.com#ignoredhash"}] Inputs: ["http://example.com/"]',
174 'Pattern: ["https://www.example.com/*"] Inputs: ["https://www.example.com/x"]',
175 'Pattern: ["https://www.example.com/*"] Inputs: ["https://www.example.com/xyz"]',
176 'Pattern: ["https://www.example.com/*"] Inputs: ["https://www.example.com/example"]',
177 'Pattern: ["https://www.example.com/*"] Inputs: ["https://www.example.com/text"]',
178 'Pattern: ["https://www.example.com/*"] Inputs: ["https://www.example.com/path/with/x"]',
179 ],
180 },
181 'urlpattern.https.any.js': {
182 comment: 'Test cases are identical to urlpattern.any.js.',
183 omittedTests: true,
184 },
185} satisfies TestRunnerConfig;