• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1'use strict';
2
3// TODO: Incorporate this with the other WPT tests if it makes sense to do that.
4
5/* The following tests are copied from WPT. Modifications to them should be
6   upstreamed first. Refs:
7   https://github.com/w3c/web-platform-tests/blob/88b75886e/url/urltestdata.json
8   License: http://www.w3.org/Consortium/Legal/2008/04-testsuite-copyright.html
9*/
10module.exports = [
11  "Basics",
12  {
13    "input": "text/html;charset=gbk",
14    "output": "text/html;charset=gbk",
15    "navigable": true,
16    "encoding": "GBK"
17  },
18  {
19    "input": "TEXT/HTML;CHARSET=GBK",
20    "output": "text/html;charset=GBK",
21    "navigable": true,
22    "encoding": "GBK"
23  },
24  "Legacy comment syntax",
25  {
26    "input": "text/html;charset=gbk(",
27    "output": "text/html;charset=\"gbk(\"",
28    "navigable": true,
29    "encoding": null
30  },
31  {
32    "input": "text/html;x=(;charset=gbk",
33    "output": "text/html;x=\"(\";charset=gbk",
34    "navigable": true,
35    "encoding": "GBK"
36  },
37  "Duplicate parameter",
38  {
39    "input": "text/html;charset=gbk;charset=windows-1255",
40    "output": "text/html;charset=gbk",
41    "navigable": true,
42    "encoding": "GBK"
43  },
44  {
45    "input": "text/html;charset=();charset=GBK",
46    "output": "text/html;charset=\"()\"",
47    "navigable": true,
48    "encoding": null
49  },
50  "Spaces",
51  {
52    "input": "text/html;charset =gbk",
53    "output": "text/html",
54    "navigable": true,
55    "encoding": null
56  },
57  {
58    "input": "text/html ;charset=gbk",
59    "output": "text/html;charset=gbk",
60    "navigable": true,
61    "encoding": "GBK"
62  },
63  {
64    "input": "text/html; charset=gbk",
65    "output": "text/html;charset=gbk",
66    "navigable": true,
67    "encoding": "GBK"
68  },
69  {
70    "input": "text/html;charset= gbk",
71    "output": "text/html;charset=\" gbk\"",
72    "navigable": true,
73    "encoding": "GBK"
74  },
75  {
76    "input": "text/html;charset= \"gbk\"",
77    "output": "text/html;charset=\" \\\"gbk\\\"\"",
78    "navigable": true,
79    "encoding": null
80  },
81  "0x0B and 0x0C",
82  {
83    "input": "text/html;charset=\u000Bgbk",
84    "output": "text/html",
85    "navigable": true,
86    "encoding": null
87  },
88  {
89    "input": "text/html;charset=\u000Cgbk",
90    "output": "text/html",
91    "navigable": true,
92    "encoding": null
93  },
94  {
95    "input": "text/html;\u000Bcharset=gbk",
96    "output": "text/html",
97    "navigable": true,
98    "encoding": null
99  },
100  {
101    "input": "text/html;\u000Ccharset=gbk",
102    "output": "text/html",
103    "navigable": true,
104    "encoding": null
105  },
106  "Single quotes are a token, not a delimiter",
107  {
108    "input": "text/html;charset='gbk'",
109    "output": "text/html;charset='gbk'",
110    "navigable": true,
111    "encoding": null
112  },
113  {
114    "input": "text/html;charset='gbk",
115    "output": "text/html;charset='gbk",
116    "navigable": true,
117    "encoding": null
118  },
119  {
120    "input": "text/html;charset=gbk'",
121    "output": "text/html;charset=gbk'",
122    "navigable": true,
123    "encoding": null
124  },
125  {
126    "input": "text/html;charset=';charset=GBK",
127    "output": "text/html;charset='",
128    "navigable": true,
129    "encoding": null
130  },
131  "Invalid parameters",
132  {
133    "input": "text/html;test;charset=gbk",
134    "output": "text/html;charset=gbk",
135    "navigable": true,
136    "encoding": "GBK"
137  },
138  {
139    "input": "text/html;test=;charset=gbk",
140    "output": "text/html;charset=gbk",
141    "navigable": true,
142    "encoding": "GBK"
143  },
144  {
145    "input": "text/html;';charset=gbk",
146    "output": "text/html;charset=gbk",
147    "navigable": true,
148    "encoding": "GBK"
149  },
150  {
151    "input": "text/html;\";charset=gbk",
152    "output": "text/html;charset=gbk",
153    "navigable": true,
154    "encoding": "GBK"
155  },
156  {
157    "input": "text/html ; ; charset=gbk",
158    "output": "text/html;charset=gbk",
159    "navigable": true,
160    "encoding": "GBK"
161  },
162  {
163    "input": "text/html;;;;charset=gbk",
164    "output": "text/html;charset=gbk",
165    "navigable": true,
166    "encoding": "GBK"
167  },
168  {
169    "input": "text/html;charset= \"\u007F;charset=GBK",
170    "output": "text/html;charset=GBK",
171    "navigable": true,
172    "encoding": "GBK"
173  },
174  {
175    "input": "text/html;charset=\"\u007F;charset=foo\";charset=GBK",
176    "output": "text/html;charset=GBK",
177    "navigable": true,
178    "encoding": "GBK"
179  },
180  "Double quotes",
181  {
182    "input": "text/html;charset=\"gbk\"",
183    "output": "text/html;charset=gbk",
184    "navigable": true,
185    "encoding": "GBK"
186  },
187  {
188    "input": "text/html;charset=\"gbk",
189    "output": "text/html;charset=gbk",
190    "navigable": true,
191    "encoding": "GBK"
192  },
193  {
194    "input": "text/html;charset=gbk\"",
195    "output": "text/html;charset=\"gbk\\\"\"",
196    "navigable": true,
197    "encoding": null
198  },
199  {
200    "input": "text/html;charset=\" gbk\"",
201    "output": "text/html;charset=\" gbk\"",
202    "navigable": true,
203    "encoding": "GBK"
204  },
205  {
206    "input": "text/html;charset=\"gbk \"",
207    "output": "text/html;charset=\"gbk \"",
208    "navigable": true,
209    "encoding": "GBK"
210  },
211  {
212    "input": "text/html;charset=\"\\ gbk\"",
213    "output": "text/html;charset=\" gbk\"",
214    "navigable": true,
215    "encoding": "GBK"
216  },
217  {
218    "input": "text/html;charset=\"\\g\\b\\k\"",
219    "output": "text/html;charset=gbk",
220    "navigable": true,
221    "encoding": "GBK"
222  },
223  {
224    "input": "text/html;charset=\"gbk\"x",
225    "output": "text/html;charset=gbk",
226    "navigable": true,
227    "encoding": "GBK"
228  },
229  {
230    "input": "text/html;charset=\"\";charset=GBK",
231    "output": "text/html;charset=\"\"",
232    "navigable": true,
233    "encoding": null
234  },
235  {
236    "input": "text/html;charset=\";charset=GBK",
237    "output": "text/html;charset=\";charset=GBK\"",
238    "navigable": true,
239    "encoding": null
240  },
241  "Unexpected code points",
242  {
243    "input": "text/html;charset={gbk}",
244    "output": "text/html;charset=\"{gbk}\"",
245    "navigable": true,
246    "encoding": null
247  },
248  "Parameter name longer than 127",
249  {
250    "input": "text/html;0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789=x;charset=gbk",
251    "output": "text/html;0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789=x;charset=gbk",
252    "navigable": true,
253    "encoding": "GBK"
254  },
255  "type/subtype longer than 127",
256  {
257    "input": "0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789/0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789",
258    "output": "0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789/0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789"
259  },
260  "Valid",
261  {
262    "input": "!#$%&'*+-.^_`|~0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz/!#$%&'*+-.^_`|~0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz;!#$%&'*+-.^_`|~0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz=!#$%&'*+-.^_`|~0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",
263    "output": "!#$%&'*+-.^_`|~0123456789abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz/!#$%&'*+-.^_`|~0123456789abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz;!#$%&'*+-.^_`|~0123456789abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz=!#$%&'*+-.^_`|~0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
264  },
265  {
266    "input": "x/x;x=\"\t !\\\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\u0080\u0081\u0082\u0083\u0084\u0085\u0086\u0087\u0088\u0089\u008A\u008B\u008C\u008D\u008E\u008F\u0090\u0091\u0092\u0093\u0094\u0095\u0096\u0097\u0098\u0099\u009A\u009B\u009C\u009D\u009E\u009F\u00A0\u00A1\u00A2\u00A3\u00A4\u00A5\u00A6\u00A7\u00A8\u00A9\u00AA\u00AB\u00AC\u00AD\u00AE\u00AF\u00B0\u00B1\u00B2\u00B3\u00B4\u00B5\u00B6\u00B7\u00B8\u00B9\u00BA\u00BB\u00BC\u00BD\u00BE\u00BF\u00C0\u00C1\u00C2\u00C3\u00C4\u00C5\u00C6\u00C7\u00C8\u00C9\u00CA\u00CB\u00CC\u00CD\u00CE\u00CF\u00D0\u00D1\u00D2\u00D3\u00D4\u00D5\u00D6\u00D7\u00D8\u00D9\u00DA\u00DB\u00DC\u00DD\u00DE\u00DF\u00E0\u00E1\u00E2\u00E3\u00E4\u00E5\u00E6\u00E7\u00E8\u00E9\u00EA\u00EB\u00EC\u00ED\u00EE\u00EF\u00F0\u00F1\u00F2\u00F3\u00F4\u00F5\u00F6\u00F7\u00F8\u00F9\u00FA\u00FB\u00FC\u00FD\u00FE\u00FF\"",
267    "output": "x/x;x=\"\t !\\\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\u0080\u0081\u0082\u0083\u0084\u0085\u0086\u0087\u0088\u0089\u008A\u008B\u008C\u008D\u008E\u008F\u0090\u0091\u0092\u0093\u0094\u0095\u0096\u0097\u0098\u0099\u009A\u009B\u009C\u009D\u009E\u009F\u00A0\u00A1\u00A2\u00A3\u00A4\u00A5\u00A6\u00A7\u00A8\u00A9\u00AA\u00AB\u00AC\u00AD\u00AE\u00AF\u00B0\u00B1\u00B2\u00B3\u00B4\u00B5\u00B6\u00B7\u00B8\u00B9\u00BA\u00BB\u00BC\u00BD\u00BE\u00BF\u00C0\u00C1\u00C2\u00C3\u00C4\u00C5\u00C6\u00C7\u00C8\u00C9\u00CA\u00CB\u00CC\u00CD\u00CE\u00CF\u00D0\u00D1\u00D2\u00D3\u00D4\u00D5\u00D6\u00D7\u00D8\u00D9\u00DA\u00DB\u00DC\u00DD\u00DE\u00DF\u00E0\u00E1\u00E2\u00E3\u00E4\u00E5\u00E6\u00E7\u00E8\u00E9\u00EA\u00EB\u00EC\u00ED\u00EE\u00EF\u00F0\u00F1\u00F2\u00F3\u00F4\u00F5\u00F6\u00F7\u00F8\u00F9\u00FA\u00FB\u00FC\u00FD\u00FE\u00FF\""
268  },
269  "End-of-file handling",
270  {
271    "input": "x/x;test",
272    "output": "x/x"
273  },
274  {
275    "input": "x/x;test=\"\\",
276    "output": "x/x;test=\"\\\\\""
277  },
278  "Whitespace (not handled by generated-mime-types.json or above)",
279  {
280    "input": "x/x;x= ",
281    "output": "x/x"
282  },
283  {
284    "input": "x/x;x=\t",
285    "output": "x/x"
286  },
287  {
288    "input": "x/x\n\r\t ;x=x",
289    "output": "x/x;x=x"
290  },
291  {
292    "input": "\n\r\t x/x;x=x\n\r\t ",
293    "output": "x/x;x=x"
294  },
295  {
296    "input": "x/x;\n\r\t x=x\n\r\t ;x=y",
297    "output": "x/x;x=x"
298  },
299  "Latin1",
300  {
301    "input": "text/html;test=\u00FF;charset=gbk",
302    "output": "text/html;test=\"\u00FF\";charset=gbk",
303    "navigable": true,
304    "encoding": "GBK"
305  },
306  ">Latin1",
307  {
308    "input": "x/x;test=\uFFFD;x=x",
309    "output": "x/x;x=x"
310  },
311  "Failure",
312  {
313    "input": "\u000Bx/x",
314    "output": null
315  },
316  {
317    "input": "\u000Cx/x",
318    "output": null
319  },
320  {
321    "input": "x/x\u000B",
322    "output": null
323  },
324  {
325    "input": "x/x\u000C",
326    "output": null
327  },
328  {
329    "input": "",
330    "output": null
331  },
332  {
333    "input": "\t",
334    "output": null
335  },
336  {
337    "input": "/",
338    "output": null
339  },
340  {
341    "input": "bogus",
342    "output": null
343  },
344  {
345    "input": "bogus/",
346    "output": null
347  },
348  {
349    "input": "bogus/ ",
350    "output": null
351  },
352  {
353    "input": "bogus/bogus/;",
354    "output": null
355  },
356  {
357    "input": "</>",
358    "output": null
359  },
360  {
361    "input": "(/)",
362    "output": null
363  },
364  {
365    "input": "ÿ/ÿ",
366    "output": null
367  },
368  {
369    "input": "text/html(;doesnot=matter",
370    "output": null
371  },
372  {
373    "input": "{/}",
374    "output": null
375  },
376  {
377    "input": "\u0100/\u0100",
378    "output": null
379  },
380  {
381    "input": "text /html",
382    "output": null
383  },
384  {
385    "input": "text/ html",
386    "output": null
387  },
388  {
389    "input": "\"text/html\"",
390    "output": null
391  }
392];
393