Skip to content
File

Blob: src/workerd/api/tests/url-test.js

javascript7252 lines
1// Copyright (c) 2023 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
4import { deepStrictEqual, strictEqual, ok, fail, throws } from 'node:assert';
5 
6export const constructAndGet = {
7 test() {
8 const cases = [
9 {
10 input: 'https://capnproto.org',
11 pathname: '/',
12 comment: 'special URL, 0-component path',
13 },
14 {
15 input: 'https://capnproto.org/',
16 pathname: '/',
17 comment: 'special URL, 1-component path with empty terminal component',
18 },
19 {
20 input: 'https://capnproto.org/foo',
21 pathname: '/foo',
22 comment: 'special URL, 1-component path',
23 },
24 {
25 input: 'https://capnproto.org/foo/',
26 pathname: '/foo/',
27 comment: 'special URL, 2-component path with empty terminal component',
28 },
29 {
30 input: 'https://capnproto.org/%2F',
31 pathname: '/%2F',
32 comment: 'encoded slash can be a path component',
33 },
34 {
35 input: 'https://capnproto.org//',
36 pathname: '//',
37 comment: '// in path is not collapsed',
38 },
39 {
40 input: 'https://capnproto.org/./',
41 pathname: '/',
42 comment: '/./ in path is collapsed',
43 },
44 {
45 input: 'https://capnproto.org/?<>',
46 search: '?%3C%3E',
47 comment: 'angle brackets in search get percent-encoded',
48 },
49 {
50 input: 'https://capnproto.org/??',
51 search: '??',
52 comment: 'question mark in search does not get percent-encoded',
53 },
54 {
55 input: 'https://capnproto.org/?foo',
56 search: '?foo',
57 href: 'https://capnproto.org/?foo',
58 comment:
59 'No-valued/empty-valued query parameters are preserved round-trip',
60 },
61 {
62 input: 'https://capnproto.org/?foo=',
63 search: '?foo=',
64 href: 'https://capnproto.org/?foo=',
65 comment:
66 'No-valued/empty-valued query parameters are preserved round-trip',
67 },
68 {
69 input: 'https://capnproto.org/?foo=&bar',
70 search: '?foo=&bar',
71 href: 'https://capnproto.org/?foo=&bar',
72 comment:
73 'No-valued/empty-valued query parameters are preserved round-trip',
74 },
75 {
76 input: 'https://capnproto.org/?foo&bar=',
77 search: '?foo&bar=',
78 href: 'https://capnproto.org/?foo&bar=',
79 comment:
80 'No-valued/empty-valued query parameters are preserved round-trip',
81 },
82 {
83 input: 'https://capnproto.org/?foo+bar=baz+qux',
84 search: '?foo+bar=baz+qux',
85 comment: 'pluses in search do not get percent-encoded',
86 },
87 {
88 input: 'https://capnproto.org/?😺',
89 search: '?%F0%9F%98%BA',
90 comment: 'cat emoji in search gets percent-encoded',
91 },
92 {
93 input: 'https://capnproto.org/#😺',
94 hash: '#%F0%9F%98%BA',
95 comment: 'cat emoji in hash gets percent-encoded',
96 },
97 {
98 input: 'https://capnproto.org:443/',
99 href: 'https://capnproto.org/',
100 comment:
101 'Parsing a URL with an explicit scheme-default port ignores the port',
102 },
103 {
104 input: 'https://capnproto.org:/',
105 href: 'https://capnproto.org/',
106 comment: 'Parsing a URL with a ":" but no port ignores port',
107 },
108 {
109 input: 'http://foo/bar;baz@qux',
110 href: 'http://foo/bar;baz@qux',
111 comment:
112 'URL path components are encoded with the path percent encode set',
113 },
114 {
115 input: 'https://jam_com.helpusersvote.net/',
116 href: 'https://jam_com.helpusersvote.net/',
117 comment: 'Underscores are allowed in hostnames',
118 },
119 {
120 input:
121 'https://foo%25bar:baz%25qux@capnproto.org/foo%25bar?foo%25bar=baz%25qux#foo%25bar',
122 href: 'https://foo%25bar:baz%25qux@capnproto.org/foo%25bar?foo%25bar=baz%25qux#foo%25bar',
123 comment:
124 'Encoded percent signs in userinfo, path, query, and fragment get round-tripped',
125 },
126 ];
127 
128 cases.forEach((test) => {
129 ['pathname', 'search', 'hash', 'href'].forEach((attribute) => {
130 const url = new URL(test.input);
131 if (test[attribute] !== undefined) {
132 strictEqual(
133 url[attribute],
134 test[attribute],
135 `${test.input}: ${test.comment}`
136 );
137 }
138 });
139 });
140 },
141};
142 
143export const constructSetAndGet = {
144 test() {
145 const cases = {
146 protocol: [
147 {
148 href: 'https://example.com/',
149 new_value: 'http',
150 expected: {
151 href: 'http://example.com/',
152 },
153 comment: 'Setting scheme on URL with null port does not change port',
154 },
155 {
156 href: 'https://example.com:80/',
157 new_value: 'http',
158 expected: {
159 href: 'http://example.com/',
160 },
161 comment:
162 'Setting scheme on URL with port that is the new scheme-default port nulls out port',
163 },
164 {
165 href: 'https://example.com:1234/',
166 new_value: 'http',
167 expected: {
168 href: 'http://example.com:1234/',
169 },
170 comment:
171 'Setting scheme on URL with non-scheme-default port preserves port',
172 },
173 ],
174 search: [
175 {
176 href: 'https://capnproto.org/',
177 new_value: '#',
178 expected: {
179 href: 'https://capnproto.org/?%23',
180 search: '?%23',
181 },
182 },
183 {
184 href: 'https://capnproto.org/',
185 new_value: '#=#',
186 expected: {
187 href: 'https://capnproto.org/?%23=%23',
188 search: '?%23=%23',
189 },
190 },
191 ],
192 host: [
193 {
194 href: 'https://example.com/',
195 new_value: 'foo.example.com:',
196 expected: {
197 href: 'https://foo.example.com/',
198 },
199 comment: 'Setting host with ":" but no port ignores port',
200 },
201 {
202 href: 'https://example.com/',
203 new_value: 'foo.example.com:80',
204 expected: {
205 href: 'https://foo.example.com:80/',
206 },
207 comment: 'Setting host with non-scheme-default port sets port',
208 },
209 {
210 href: 'https://example.com:1234/',
211 new_value: 'foo.example.com:443',
212 expected: {
213 href: 'https://foo.example.com/',
214 },
215 comment: 'Setting host with scheme-default port nulls out port',
216 },
217 {
218 href: 'https://example.com/',
219 new_value: 'foo.example.com:443',
220 expected: {
221 href: 'https://foo.example.com/',
222 },
223 comment: 'Setting host with scheme-default port nulls out port',
224 },
225 ],
226 port: [
227 {
228 href: 'https://example.com/',
229 new_value: '443',
230 expected: {
231 href: 'https://example.com/',
232 },
233 comment: 'Setting port to scheme-default port is a no-op',
234 },
235 {
236 href: 'https://example.com:1234/',
237 new_value: '443',
238 expected: {
239 href: 'https://example.com/',
240 },
241 comment: 'Setting port to scheme-default port nulls out port',
242 },
243 {
244 href: 'https://example.com/',
245 new_value: '1234',
246 expected: {
247 href: 'https://example.com:1234/',
248 },
249 comment: 'Setting port to non-scheme-default port adopts port',
250 },
251 {
252 href: 'https://example.com:80/',
253 new_value: '1234',
254 expected: {
255 href: 'https://example.com:1234/',
256 },
257 comment: 'Setting port to non-scheme-default port adopts port',
258 },
259 {
260 href: 'https://example.com:1234/',
261 new_value: '',
262 expected: {
263 href: 'https://example.com/',
264 },
265 comment: 'Setting port to the empty string nulls out port',
266 },
267 ],
268 hostname: [
269 {
270 href: 'http://example.com/path/to/something?query=foo#hash',
271 new_value: 'newexample.com',
272 expected: {
273 href: 'http://newexample.com/path/to/something?query=foo#hash',
274 },
275 },
276 ],
277 };
278 
279 for (const attribute in cases) {
280 cases[attribute].forEach((test) => {
281 const url = new URL(test.href);
282 url[attribute] = test.new_value;
283 for (const a in test.expected) {
284 strictEqual(
285 url[a],
286 test.expected[a],
287 `${test.href}: ${test.comment}`
288 );
289 }
290 });
291 }
292 },
293};
294 
295export const urlSearchParamsStringifyBehavior = {
296 test() {
297 const url = new URL('https://example.com/?foo&bar=&baz=qux');
298 strictEqual(url.href, 'https://example.com/?foo&bar=&baz=qux');
299 strictEqual(url.search, '?foo&bar=&baz=qux');
300 strictEqual(url.searchParams.toString(), 'foo=&bar=&baz=qux');
301 },
302};
303 
304export const urlSearchParamsForEach = {
305 test() {
306 let searchParams = new URLSearchParams('');
307 searchParams.forEach(() => {
308 fail('Should not have been called');
309 });
310 
311 const foreachOutput = [];
312 searchParams = new URLSearchParams('key1=value1&key2=value2');
313 strictEqual(searchParams.size, 2);
314 let pushed = false;
315 searchParams.forEach((val, key) => {
316 foreachOutput.push([key, val]);
317 if (!pushed) {
318 // We can add params within this loop but it's not really safe
319 // because it will cause the loop to run forever if we're not
320 // careful.
321 pushed = true;
322 searchParams.set('key3', 'value3');
323 }
324 });
325 deepStrictEqual(foreachOutput, [
326 ['key1', 'value1'],
327 ['key2', 'value2'],
328 ['key3', 'value3'],
329 ]);
330 strictEqual(searchParams.size, 3);
331 
332 // Calling forEach with no argument throws
333 throws(() => searchParams.forEach());
334 
335 // Calling forEach with wrong arguments throws
336 throws(() => searchParams.forEach(1));
337 
338 // This can be overridden by the second argument
339 searchParams.forEach(function () {
340 strictEqual(this, 1);
341 }, 1);
342 
343 // Propagates errors
344 throws(() =>
345 searchParams.forEach(() => {
346 throw new Error('boom');
347 })
348 );
349 },
350};
351 
352export const urlSearchParamsInit1 = {
353 test() {
354 const search1 = new URLSearchParams('a=b');
355 const search2 = new URLSearchParams(search1);
356 strictEqual(search1.toString(), search2.toString());
357 },
358};
359 
360export const urlSearchParamsInit2 = {
361 test() {
362 const search1 = new URLSearchParams('a=b');
363 search1[Symbol.iterator] = function* () {
364 yield ['y', 'z'];
365 };
366 const search2 = new URLSearchParams(search1);
367 ok(!search2.has('a'));
368 ok(search2.has('y'));
369 strictEqual(search2.get('y'), 'z');
370 },
371};
372 
373export const urlSearchParamsInit3 = {
374 test() {
375 // If the initializer has a deleted iterator, then its
376 // contents are ignored but can still be interpreted as
377 // a dictionary.
378 const search1 = new URLSearchParams('a=b');
379 search1[Symbol.iterator] = undefined;
380 search1.y = 'z';
381 const search2 = new URLSearchParams(search1);
382 ok(!search2.has('a'));
383 ok(search2.has('y'));
384 strictEqual(search2.get('y'), 'z');
385 },
386};
387 
388export const urlSearchParamsInit4 = {
389 test() {
390 const formdata = new FormData();
391 formdata.append('a', 'b');
392 ok(formdata.has('a'));
393 const search2 = new URLSearchParams(formdata);
394 ok(search2.has('a'));
395 strictEqual(search2.get('a'), 'b');
396 },
397};
398 
399export const urlSearchParamsInit5 = {
400 test() {
401 const formdata = new FormData();
402 formdata.append('a', 'b');
403 formdata[Symbol.iterator] = undefined;
404 const search2 = new URLSearchParams(formdata);
405 ok(!search2.has('a'));
406 },
407};
408 
409export const urlToJson = {
410 test() {
411 const url = new URL('https://example.com');
412 strictEqual(JSON.stringify(url), '"https://example.com/"');
413 },
414};
415 
416export const urlSearchParamsSet = {
417 test() {
418 const url = new URL('https://example.com?c=d');
419 url.searchParams.set('a', 'b');
420 strictEqual(url.searchParams.size, 2);
421 url.searchParams.delete('c');
422 strictEqual(url.searchParams.size, 1);
423 ok(url.searchParams.has('a'));
424 ok(!url.searchParams.has('c'));
425 ok(url.searchParams.has('a', 'b'));
426 ok(!url.searchParams.has('a', 'c'));
427 url.searchParams.delete('a', 'c');
428 ok(url.searchParams.has('a'));
429 },
430};
431 
432export const urlConstructorTests = {
433 test() {
434 const cases = [
435 '# Based on http://trac.webkit.org/browser/trunk/LayoutTests/fast/url/script-tests/segments.js',
436 {
437 input: 'http://example\t.\norg',
438 base: 'http://example.org/foo/bar',
439 href: 'http://example.org/',
440 origin: 'http://example.org',
441 protocol: 'http:',
442 username: '',
443 password: '',
444 host: 'example.org',
445 hostname: 'example.org',
446 port: '',
447 pathname: '/',
448 search: '',
449 hash: '',
450 },
451 {
452 input: 'C|/',
453 base: 'file://host/dir/file',
454 href: 'file://host/C:/',
455 protocol: 'file:',
456 username: '',
457 password: '',
458 host: 'host',
459 hostname: 'host',
460 port: '',
461 pathname: '/C:/',
462 search: '',
463 hash: '',
464 },
465 {
466 input: 'C|\n/',
467 base: 'file://host/dir/file',
468 href: 'file://host/C:/',
469 protocol: 'file:',
470 username: '',
471 password: '',
472 host: 'host',
473 hostname: 'host',
474 port: '',
475 pathname: '/C:/',
476 search: '',
477 hash: '',
478 },
479 {
480 input: 'https://:@test',
481 base: 'about:blank',
482 href: 'https://test/',
483 origin: 'https://test',
484 protocol: 'https:',
485 username: '',
486 password: '',
487 host: 'test',
488 hostname: 'test',
489 port: '',
490 pathname: '/',
491 search: '',
492 hash: '',
493 },
494 {
495 input: 'non-special://test:@test/x',
496 base: 'about:blank',
497 href: 'non-special://test@test/x',
498 origin: 'null',
499 protocol: 'non-special:',
500 username: 'test',
501 password: '',
502 host: 'test',
503 hostname: 'test',
504 port: '',
505 pathname: '/x',
506 search: '',
507 hash: '',
508 },
509 {
510 input: 'non-special://:@test/x',
511 base: 'about:blank',
512 href: 'non-special://test/x',
513 origin: 'null',
514 protocol: 'non-special:',
515 username: '',
516 password: '',
517 host: 'test',
518 hostname: 'test',
519 port: '',
520 pathname: '/x',
521 search: '',
522 hash: '',
523 },
524 {
525 input: 'http:foo.com',
526 base: 'http://example.org/foo/bar',
527 href: 'http://example.org/foo/foo.com',
528 origin: 'http://example.org',
529 protocol: 'http:',
530 username: '',
531 password: '',
532 host: 'example.org',
533 hostname: 'example.org',
534 port: '',
535 pathname: '/foo/foo.com',
536 search: '',
537 hash: '',
538 },
539 {
540 input: '\t :foo.com \n',
541 base: 'http://example.org/foo/bar',
542 href: 'http://example.org/foo/:foo.com',
543 origin: 'http://example.org',
544 protocol: 'http:',
545 username: '',
546 password: '',
547 host: 'example.org',
548 hostname: 'example.org',
549 port: '',
550 pathname: '/foo/:foo.com',
551 search: '',
552 hash: '',
553 },
554 {
555 input: ' foo.com ',
556 base: 'http://example.org/foo/bar',
557 href: 'http://example.org/foo/foo.com',
558 origin: 'http://example.org',
559 protocol: 'http:',
560 username: '',
561 password: '',
562 host: 'example.org',
563 hostname: 'example.org',
564 port: '',
565 pathname: '/foo/foo.com',
566 search: '',
567 hash: '',
568 },
569 {
570 input: 'a:\t foo.com',
571 base: 'http://example.org/foo/bar',
572 href: 'a: foo.com',
573 origin: 'null',
574 protocol: 'a:',
575 username: '',
576 password: '',
577 host: '',
578 hostname: '',
579 port: '',
580 pathname: ' foo.com',
581 search: '',
582 hash: '',
583 },
584 {
585 input: 'http://f:21/ b ? d # e ',
586 base: 'http://example.org/foo/bar',
587 href: 'http://f:21/%20b%20?%20d%20#%20e',
588 origin: 'http://f:21',
589 protocol: 'http:',
590 username: '',
591 password: '',
592 host: 'f:21',
593 hostname: 'f',
594 port: '21',
595 pathname: '/%20b%20',
596 search: '?%20d%20',
597 hash: '#%20e',
598 },
599 {
600 input: 'lolscheme:x x#x x',
601 base: 'about:blank',
602 href: 'lolscheme:x x#x%20x',
603 protocol: 'lolscheme:',
604 username: '',
605 password: '',
606 host: '',
607 hostname: '',
608 port: '',
609 pathname: 'x x',
610 search: '',
611 hash: '#x%20x',
612 },
613 {
614 input: 'http://f:/c',
615 base: 'http://example.org/foo/bar',
616 href: 'http://f/c',
617 origin: 'http://f',
618 protocol: 'http:',
619 username: '',
620 password: '',
621 host: 'f',
622 hostname: 'f',
623 port: '',
624 pathname: '/c',
625 search: '',
626 hash: '',
627 },
628 {
629 input: 'http://f:0/c',
630 base: 'http://example.org/foo/bar',
631 href: 'http://f:0/c',
632 origin: 'http://f:0',
633 protocol: 'http:',
634 username: '',
635 password: '',
636 host: 'f:0',
637 hostname: 'f',
638 port: '0',
639 pathname: '/c',
640 search: '',
641 hash: '',
642 },
643 {
644 input: 'http://f:00000000000000/c',
645 base: 'http://example.org/foo/bar',
646 href: 'http://f:0/c',
647 origin: 'http://f:0',
648 protocol: 'http:',
649 username: '',
650 password: '',
651 host: 'f:0',
652 hostname: 'f',
653 port: '0',
654 pathname: '/c',
655 search: '',
656 hash: '',
657 },
658 {
659 input: 'http://f:00000000000000000000080/c',
660 base: 'http://example.org/foo/bar',
661 href: 'http://f/c',
662 origin: 'http://f',
663 protocol: 'http:',
664 username: '',
665 password: '',
666 host: 'f',
667 hostname: 'f',
668 port: '',
669 pathname: '/c',
670 search: '',
671 hash: '',
672 },
673 {
674 input: 'http://f:b/c',
675 base: 'http://example.org/foo/bar',
676 failure: true,
677 },
678 {
679 input: 'http://f: /c',
680 base: 'http://example.org/foo/bar',
681 failure: true,
682 },
683 {
684 input: 'http://f:\n/c',
685 base: 'http://example.org/foo/bar',
686 href: 'http://f/c',
687 origin: 'http://f',
688 protocol: 'http:',
689 username: '',
690 password: '',
691 host: 'f',
692 hostname: 'f',
693 port: '',
694 pathname: '/c',
695 search: '',
696 hash: '',
697 },
698 {
699 input: 'http://f:fifty-two/c',
700 base: 'http://example.org/foo/bar',
701 failure: true,
702 },
703 {
704 input: 'http://f:999999/c',
705 base: 'http://example.org/foo/bar',
706 failure: true,
707 },
708 {
709 input: 'non-special://f:999999/c',
710 base: 'http://example.org/foo/bar',
711 failure: true,
712 },
713 {
714 input: 'http://f: 21 / b ? d # e ',
715 base: 'http://example.org/foo/bar',
716 failure: true,
717 },
718 {
719 input: '',
720 base: 'http://example.org/foo/bar',
721 href: 'http://example.org/foo/bar',
722 origin: 'http://example.org',
723 protocol: 'http:',
724 username: '',
725 password: '',
726 host: 'example.org',
727 hostname: 'example.org',
728 port: '',
729 pathname: '/foo/bar',
730 search: '',
731 hash: '',
732 },
733 {
734 input: ' \t',
735 base: 'http://example.org/foo/bar',
736 href: 'http://example.org/foo/bar',
737 origin: 'http://example.org',
738 protocol: 'http:',
739 username: '',
740 password: '',
741 host: 'example.org',
742 hostname: 'example.org',
743 port: '',
744 pathname: '/foo/bar',
745 search: '',
746 hash: '',
747 },
748 {
749 input: ':foo.com/',
750 base: 'http://example.org/foo/bar',
751 href: 'http://example.org/foo/:foo.com/',
752 origin: 'http://example.org',
753 protocol: 'http:',
754 username: '',
755 password: '',
756 host: 'example.org',
757 hostname: 'example.org',
758 port: '',
759 pathname: '/foo/:foo.com/',
760 search: '',
761 hash: '',
762 },
763 {
764 input: ':foo.com\\',
765 base: 'http://example.org/foo/bar',
766 href: 'http://example.org/foo/:foo.com/',
767 origin: 'http://example.org',
768 protocol: 'http:',
769 username: '',
770 password: '',
771 host: 'example.org',
772 hostname: 'example.org',
773 port: '',
774 pathname: '/foo/:foo.com/',
775 search: '',
776 hash: '',
777 },
778 {
779 input: ':',
780 base: 'http://example.org/foo/bar',
781 href: 'http://example.org/foo/:',
782 origin: 'http://example.org',
783 protocol: 'http:',
784 username: '',
785 password: '',
786 host: 'example.org',
787 hostname: 'example.org',
788 port: '',
789 pathname: '/foo/:',
790 search: '',
791 hash: '',
792 },
793 {
794 input: ':a',
795 base: 'http://example.org/foo/bar',
796 href: 'http://example.org/foo/:a',
797 origin: 'http://example.org',
798 protocol: 'http:',
799 username: '',
800 password: '',
801 host: 'example.org',
802 hostname: 'example.org',
803 port: '',
804 pathname: '/foo/:a',
805 search: '',
806 hash: '',
807 },
808 {
809 input: ':/',
810 base: 'http://example.org/foo/bar',
811 href: 'http://example.org/foo/:/',
812 origin: 'http://example.org',
813 protocol: 'http:',
814 username: '',
815 password: '',
816 host: 'example.org',
817 hostname: 'example.org',
818 port: '',
819 pathname: '/foo/:/',
820 search: '',
821 hash: '',
822 },
823 {
824 input: ':\\',
825 base: 'http://example.org/foo/bar',
826 href: 'http://example.org/foo/:/',
827 origin: 'http://example.org',
828 protocol: 'http:',
829 username: '',
830 password: '',
831 host: 'example.org',
832 hostname: 'example.org',
833 port: '',
834 pathname: '/foo/:/',
835 search: '',
836 hash: '',
837 },
838 {
839 input: ':#',
840 base: 'http://example.org/foo/bar',
841 href: 'http://example.org/foo/:#',
842 origin: 'http://example.org',
843 protocol: 'http:',
844 username: '',
845 password: '',
846 host: 'example.org',
847 hostname: 'example.org',
848 port: '',
849 pathname: '/foo/:',
850 search: '',
851 hash: '',
852 },
853 {
854 input: '#',
855 base: 'http://example.org/foo/bar',
856 href: 'http://example.org/foo/bar#',
857 origin: 'http://example.org',
858 protocol: 'http:',
859 username: '',
860 password: '',
861 host: 'example.org',
862 hostname: 'example.org',
863 port: '',
864 pathname: '/foo/bar',
865 search: '',
866 hash: '',
867 },
868 {
869 input: '#/',
870 base: 'http://example.org/foo/bar',
871 href: 'http://example.org/foo/bar#/',
872 origin: 'http://example.org',
873 protocol: 'http:',
874 username: '',
875 password: '',
876 host: 'example.org',
877 hostname: 'example.org',
878 port: '',
879 pathname: '/foo/bar',
880 search: '',
881 hash: '#/',
882 },
883 {
884 input: '#\\',
885 base: 'http://example.org/foo/bar',
886 href: 'http://example.org/foo/bar#\\',
887 origin: 'http://example.org',
888 protocol: 'http:',
889 username: '',
890 password: '',
891 host: 'example.org',
892 hostname: 'example.org',
893 port: '',
894 pathname: '/foo/bar',
895 search: '',
896 hash: '#\\',
897 },
898 {
899 input: '#;?',
900 base: 'http://example.org/foo/bar',
901 href: 'http://example.org/foo/bar#;?',
902 origin: 'http://example.org',
903 protocol: 'http:',
904 username: '',
905 password: '',
906 host: 'example.org',
907 hostname: 'example.org',
908 port: '',
909 pathname: '/foo/bar',
910 search: '',
911 hash: '#;?',
912 },
913 {
914 input: '?',
915 base: 'http://example.org/foo/bar',
916 href: 'http://example.org/foo/bar?',
917 origin: 'http://example.org',
918 protocol: 'http:',
919 username: '',
920 password: '',
921 host: 'example.org',
922 hostname: 'example.org',
923 port: '',
924 pathname: '/foo/bar',
925 search: '',
926 hash: '',
927 },
928 {
929 input: '/',
930 base: 'http://example.org/foo/bar',
931 href: 'http://example.org/',
932 origin: 'http://example.org',
933 protocol: 'http:',
934 username: '',
935 password: '',
936 host: 'example.org',
937 hostname: 'example.org',
938 port: '',
939 pathname: '/',
940 search: '',
941 hash: '',
942 },
943 {
944 input: ':23',
945 base: 'http://example.org/foo/bar',
946 href: 'http://example.org/foo/:23',
947 origin: 'http://example.org',
948 protocol: 'http:',
949 username: '',
950 password: '',
951 host: 'example.org',
952 hostname: 'example.org',
953 port: '',
954 pathname: '/foo/:23',
955 search: '',
956 hash: '',
957 },
958 {
959 input: '/:23',
960 base: 'http://example.org/foo/bar',
961 href: 'http://example.org/:23',
962 origin: 'http://example.org',
963 protocol: 'http:',
964 username: '',
965 password: '',
966 host: 'example.org',
967 hostname: 'example.org',
968 port: '',
969 pathname: '/:23',
970 search: '',
971 hash: '',
972 },
973 {
974 input: '::',
975 base: 'http://example.org/foo/bar',
976 href: 'http://example.org/foo/::',
977 origin: 'http://example.org',
978 protocol: 'http:',
979 username: '',
980 password: '',
981 host: 'example.org',
982 hostname: 'example.org',
983 port: '',
984 pathname: '/foo/::',
985 search: '',
986 hash: '',
987 },
988 {
989 input: '::23',
990 base: 'http://example.org/foo/bar',
991 href: 'http://example.org/foo/::23',
992 origin: 'http://example.org',
993 protocol: 'http:',
994 username: '',
995 password: '',
996 host: 'example.org',
997 hostname: 'example.org',
998 port: '',
999 pathname: '/foo/::23',
1000 search: '',
1001 hash: '',
1002 },
1003 {
1004 input: 'foo://',
1005 base: 'http://example.org/foo/bar',
1006 href: 'foo://',
1007 origin: 'null',
1008 protocol: 'foo:',
1009 username: '',
1010 password: '',
1011 host: '',
1012 hostname: '',
1013 port: '',
1014 pathname: '',
1015 search: '',
1016 hash: '',
1017 },
1018 {
1019 input: 'http://a:b@c:29/d',
1020 base: 'http://example.org/foo/bar',
1021 href: 'http://a:b@c:29/d',
1022 origin: 'http://c:29',
1023 protocol: 'http:',
1024 username: 'a',
1025 password: 'b',
1026 host: 'c:29',
1027 hostname: 'c',
1028 port: '29',
1029 pathname: '/d',
1030 search: '',
1031 hash: '',
1032 },
1033 {
1034 input: 'http::@c:29',
1035 base: 'http://example.org/foo/bar',
1036 href: 'http://example.org/foo/:@c:29',
1037 origin: 'http://example.org',
1038 protocol: 'http:',
1039 username: '',
1040 password: '',
1041 host: 'example.org',
1042 hostname: 'example.org',
1043 port: '',
1044 pathname: '/foo/:@c:29',
1045 search: '',
1046 hash: '',
1047 },
1048 {
1049 input: 'http://&a:foo(b]c@d:2/',
1050 base: 'http://example.org/foo/bar',
1051 href: 'http://&a:foo(b%5Dc@d:2/',
1052 origin: 'http://d:2',
1053 protocol: 'http:',
1054 username: '&a',
1055 password: 'foo(b%5Dc',
1056 host: 'd:2',
1057 hostname: 'd',
1058 port: '2',
1059 pathname: '/',
1060 search: '',
1061 hash: '',
1062 },
1063 {
1064 input: 'http://::@c@d:2',
1065 base: 'http://example.org/foo/bar',
1066 href: 'http://:%3A%40c@d:2/',
1067 origin: 'http://d:2',
1068 protocol: 'http:',
1069 username: '',
1070 password: '%3A%40c',
1071 host: 'd:2',
1072 hostname: 'd',
1073 port: '2',
1074 pathname: '/',
1075 search: '',
1076 hash: '',
1077 },
1078 {
1079 input: 'http://foo.com:b@d/',
1080 base: 'http://example.org/foo/bar',
1081 href: 'http://foo.com:b@d/',
1082 origin: 'http://d',
1083 protocol: 'http:',
1084 username: 'foo.com',
1085 password: 'b',
1086 host: 'd',
1087 hostname: 'd',
1088 port: '',
1089 pathname: '/',
1090 search: '',
1091 hash: '',
1092 },
1093 {
1094 input: 'http://foo.com/\\@',
1095 base: 'http://example.org/foo/bar',
1096 href: 'http://foo.com//@',
1097 origin: 'http://foo.com',
1098 protocol: 'http:',
1099 username: '',
1100 password: '',
1101 host: 'foo.com',
1102 hostname: 'foo.com',
1103 port: '',
1104 pathname: '//@',
1105 search: '',
1106 hash: '',
1107 },
1108 {
1109 input: 'http:\\\\foo.com\\',
1110 base: 'http://example.org/foo/bar',
1111 href: 'http://foo.com/',
1112 origin: 'http://foo.com',
1113 protocol: 'http:',
1114 username: '',
1115 password: '',
1116 host: 'foo.com',
1117 hostname: 'foo.com',
1118 port: '',
1119 pathname: '/',
1120 search: '',
1121 hash: '',
1122 },
1123 {
1124 input: 'http:\\\\a\\b:c\\d@foo.com\\',
1125 base: 'http://example.org/foo/bar',
1126 href: 'http://a/b:c/d@foo.com/',
1127 origin: 'http://a',
1128 protocol: 'http:',
1129 username: '',
1130 password: '',
1131 host: 'a',
1132 hostname: 'a',
1133 port: '',
1134 pathname: '/b:c/d@foo.com/',
1135 search: '',
1136 hash: '',
1137 },
1138 {
1139 input: 'foo:/',
1140 base: 'http://example.org/foo/bar',
1141 href: 'foo:/',
1142 origin: 'null',
1143 protocol: 'foo:',
1144 username: '',
1145 password: '',
1146 host: '',
1147 hostname: '',
1148 port: '',
1149 pathname: '/',
1150 search: '',
1151 hash: '',
1152 },
1153 {
1154 input: 'foo:/bar.com/',
1155 base: 'http://example.org/foo/bar',
1156 href: 'foo:/bar.com/',
1157 origin: 'null',
1158 protocol: 'foo:',
1159 username: '',
1160 password: '',
1161 host: '',
1162 hostname: '',
1163 port: '',
1164 pathname: '/bar.com/',
1165 search: '',
1166 hash: '',
1167 },
1168 {
1169 input: 'foo://///////',
1170 base: 'http://example.org/foo/bar',
1171 href: 'foo://///////',
1172 origin: 'null',
1173 protocol: 'foo:',
1174 username: '',
1175 password: '',
1176 host: '',
1177 hostname: '',
1178 port: '',
1179 pathname: '///////',
1180 search: '',
1181 hash: '',
1182 },
1183 {
1184 input: 'foo://///////bar.com/',
1185 base: 'http://example.org/foo/bar',
1186 href: 'foo://///////bar.com/',
1187 origin: 'null',
1188 protocol: 'foo:',
1189 username: '',
1190 password: '',
1191 host: '',
1192 hostname: '',
1193 port: '',
1194 pathname: '///////bar.com/',
1195 search: '',
1196 hash: '',
1197 },
1198 {
1199 input: 'foo:////://///',
1200 base: 'http://example.org/foo/bar',
1201 href: 'foo:////://///',
1202 origin: 'null',
1203 protocol: 'foo:',
1204 username: '',
1205 password: '',
1206 host: '',
1207 hostname: '',
1208 port: '',
1209 pathname: '//://///',
1210 search: '',
1211 hash: '',
1212 },
1213 {
1214 input: 'c:/foo',
1215 base: 'http://example.org/foo/bar',
1216 href: 'c:/foo',
1217 origin: 'null',
1218 protocol: 'c:',
1219 username: '',
1220 password: '',
1221 host: '',
1222 hostname: '',
1223 port: '',
1224 pathname: '/foo',
1225 search: '',
1226 hash: '',
1227 },
1228 {
1229 input: '//foo/bar',
1230 base: 'http://example.org/foo/bar',
1231 href: 'http://foo/bar',
1232 origin: 'http://foo',
1233 protocol: 'http:',
1234 username: '',
1235 password: '',
1236 host: 'foo',
1237 hostname: 'foo',
1238 port: '',
1239 pathname: '/bar',
1240 search: '',
1241 hash: '',
1242 },
1243 {
1244 input: 'http://foo/path;a??e#f#g',
1245 base: 'http://example.org/foo/bar',
1246 href: 'http://foo/path;a??e#f#g',
1247 origin: 'http://foo',
1248 protocol: 'http:',
1249 username: '',
1250 password: '',
1251 host: 'foo',
1252 hostname: 'foo',
1253 port: '',
1254 pathname: '/path;a',
1255 search: '??e',
1256 hash: '#f#g',
1257 },
1258 {
1259 input: 'http://foo/abcd?efgh?ijkl',
1260 base: 'http://example.org/foo/bar',
1261 href: 'http://foo/abcd?efgh?ijkl',
1262 origin: 'http://foo',
1263 protocol: 'http:',
1264 username: '',
1265 password: '',
1266 host: 'foo',
1267 hostname: 'foo',
1268 port: '',
1269 pathname: '/abcd',
1270 search: '?efgh?ijkl',
1271 hash: '',
1272 },
1273 {
1274 input: 'http://foo/abcd#foo?bar',
1275 base: 'http://example.org/foo/bar',
1276 href: 'http://foo/abcd#foo?bar',
1277 origin: 'http://foo',
1278 protocol: 'http:',
1279 username: '',
1280 password: '',
1281 host: 'foo',
1282 hostname: 'foo',
1283 port: '',
1284 pathname: '/abcd',
1285 search: '',
1286 hash: '#foo?bar',
1287 },
1288 {
1289 input: '[61:24:74]:98',
1290 base: 'http://example.org/foo/bar',
1291 href: 'http://example.org/foo/[61:24:74]:98',
1292 origin: 'http://example.org',
1293 protocol: 'http:',
1294 username: '',
1295 password: '',
1296 host: 'example.org',
1297 hostname: 'example.org',
1298 port: '',
1299 pathname: '/foo/[61:24:74]:98',
1300 search: '',
1301 hash: '',
1302 },
1303 {
1304 input: 'http:[61:27]/:foo',
1305 base: 'http://example.org/foo/bar',
1306 href: 'http://example.org/foo/[61:27]/:foo',
1307 origin: 'http://example.org',
1308 protocol: 'http:',
1309 username: '',
1310 password: '',
1311 host: 'example.org',
1312 hostname: 'example.org',
1313 port: '',
1314 pathname: '/foo/[61:27]/:foo',
1315 search: '',
1316 hash: '',
1317 },
1318 {
1319 input: 'http://[1::2]:3:4',
1320 base: 'http://example.org/foo/bar',
1321 failure: true,
1322 },
1323 {
1324 input: 'http://2001::1',
1325 base: 'http://example.org/foo/bar',
1326 failure: true,
1327 },
1328 {
1329 input: 'http://2001::1]',
1330 base: 'http://example.org/foo/bar',
1331 failure: true,
1332 },
1333 {
1334 input: 'http://2001::1]:80',
1335 base: 'http://example.org/foo/bar',
1336 failure: true,
1337 },
1338 {
1339 input: 'http://[2001::1]',
1340 base: 'http://example.org/foo/bar',
1341 href: 'http://[2001::1]/',
1342 origin: 'http://[2001::1]',
1343 protocol: 'http:',
1344 username: '',
1345 password: '',
1346 host: '[2001::1]',
1347 hostname: '[2001::1]',
1348 port: '',
1349 pathname: '/',
1350 search: '',
1351 hash: '',
1352 },
1353 {
1354 input: 'http://[::127.0.0.1]',
1355 base: 'http://example.org/foo/bar',
1356 href: 'http://[::7f00:1]/',
1357 origin: 'http://[::7f00:1]',
1358 protocol: 'http:',
1359 username: '',
1360 password: '',
1361 host: '[::7f00:1]',
1362 hostname: '[::7f00:1]',
1363 port: '',
1364 pathname: '/',
1365 search: '',
1366 hash: '',
1367 },
1368 {
1369 input: 'http://[0:0:0:0:0:0:13.1.68.3]',
1370 base: 'http://example.org/foo/bar',
1371 href: 'http://[::d01:4403]/',
1372 origin: 'http://[::d01:4403]',
1373 protocol: 'http:',
1374 username: '',
1375 password: '',
1376 host: '[::d01:4403]',
1377 hostname: '[::d01:4403]',
1378 port: '',
1379 pathname: '/',
1380 search: '',
1381 hash: '',
1382 },
1383 {
1384 input: 'http://[2001::1]:80',
1385 base: 'http://example.org/foo/bar',
1386 href: 'http://[2001::1]/',
1387 origin: 'http://[2001::1]',
1388 protocol: 'http:',
1389 username: '',
1390 password: '',
1391 host: '[2001::1]',
1392 hostname: '[2001::1]',
1393 port: '',
1394 pathname: '/',
1395 search: '',
1396 hash: '',
1397 },
1398 {
1399 input: 'http:/example.com/',
1400 base: 'http://example.org/foo/bar',
1401 href: 'http://example.org/example.com/',
1402 origin: 'http://example.org',
1403 protocol: 'http:',
1404 username: '',
1405 password: '',
1406 host: 'example.org',
1407 hostname: 'example.org',
1408 port: '',
1409 pathname: '/example.com/',
1410 search: '',
1411 hash: '',
1412 },
1413 {
1414 input: 'ftp:/example.com/',
1415 base: 'http://example.org/foo/bar',
1416 href: 'ftp://example.com/',
1417 origin: 'ftp://example.com',
1418 protocol: 'ftp:',
1419 username: '',
1420 password: '',
1421 host: 'example.com',
1422 hostname: 'example.com',
1423 port: '',
1424 pathname: '/',
1425 search: '',
1426 hash: '',
1427 },
1428 {
1429 input: 'https:/example.com/',
1430 base: 'http://example.org/foo/bar',
1431 href: 'https://example.com/',
1432 origin: 'https://example.com',
1433 protocol: 'https:',
1434 username: '',
1435 password: '',
1436 host: 'example.com',
1437 hostname: 'example.com',
1438 port: '',
1439 pathname: '/',
1440 search: '',
1441 hash: '',
1442 },
1443 {
1444 input: 'madeupscheme:/example.com/',
1445 base: 'http://example.org/foo/bar',
1446 href: 'madeupscheme:/example.com/',
1447 origin: 'null',
1448 protocol: 'madeupscheme:',
1449 username: '',
1450 password: '',
1451 host: '',
1452 hostname: '',
1453 port: '',
1454 pathname: '/example.com/',
1455 search: '',
1456 hash: '',
1457 },
1458 {
1459 input: 'file:/example.com/',
1460 base: 'http://example.org/foo/bar',
1461 href: 'file:///example.com/',
1462 protocol: 'file:',
1463 username: '',
1464 password: '',
1465 host: '',
1466 hostname: '',
1467 port: '',
1468 pathname: '/example.com/',
1469 search: '',
1470 hash: '',
1471 },
1472 {
1473 input: 'file://example:1/',
1474 base: 'about:blank',
1475 failure: true,
1476 },
1477 {
1478 input: 'file://example:test/',
1479 base: 'about:blank',
1480 failure: true,
1481 },
1482 {
1483 input: 'file://example%/',
1484 base: 'about:blank',
1485 failure: true,
1486 },
1487 {
1488 input: 'file://[example]/',
1489 base: 'about:blank',
1490 failure: true,
1491 },
1492 {
1493 input: 'ftps:/example.com/',
1494 base: 'http://example.org/foo/bar',
1495 href: 'ftps:/example.com/',
1496 origin: 'null',
1497 protocol: 'ftps:',
1498 username: '',
1499 password: '',
1500 host: '',
1501 hostname: '',
1502 port: '',
1503 pathname: '/example.com/',
1504 search: '',
1505 hash: '',
1506 },
1507 {
1508 input: 'gopher:/example.com/',
1509 base: 'http://example.org/foo/bar',
1510 href: 'gopher:/example.com/',
1511 protocol: 'gopher:',
1512 username: '',
1513 password: '',
1514 host: '',
1515 hostname: '',
1516 port: '',
1517 pathname: '/example.com/',
1518 search: '',
1519 hash: '',
1520 },
1521 {
1522 input: 'ws:/example.com/',
1523 base: 'http://example.org/foo/bar',
1524 href: 'ws://example.com/',
1525 origin: 'ws://example.com',
1526 protocol: 'ws:',
1527 username: '',
1528 password: '',
1529 host: 'example.com',
1530 hostname: 'example.com',
1531 port: '',
1532 pathname: '/',
1533 search: '',
1534 hash: '',
1535 },
1536 {
1537 input: 'wss:/example.com/',
1538 base: 'http://example.org/foo/bar',
1539 href: 'wss://example.com/',
1540 origin: 'wss://example.com',
1541 protocol: 'wss:',
1542 username: '',
1543 password: '',
1544 host: 'example.com',
1545 hostname: 'example.com',
1546 port: '',
1547 pathname: '/',
1548 search: '',
1549 hash: '',
1550 },
1551 {
1552 input: 'data:/example.com/',
1553 base: 'http://example.org/foo/bar',
1554 href: 'data:/example.com/',
1555 origin: 'null',
1556 protocol: 'data:',
1557 username: '',
1558 password: '',
1559 host: '',
1560 hostname: '',
1561 port: '',
1562 pathname: '/example.com/',
1563 search: '',
1564 hash: '',
1565 },
1566 {
1567 input: 'javascript:/example.com/',
1568 base: 'http://example.org/foo/bar',
1569 href: 'javascript:/example.com/',
1570 origin: 'null',
1571 protocol: 'javascript:',
1572 username: '',
1573 password: '',
1574 host: '',
1575 hostname: '',
1576 port: '',
1577 pathname: '/example.com/',
1578 search: '',
1579 hash: '',
1580 },
1581 {
1582 input: 'mailto:/example.com/',
1583 base: 'http://example.org/foo/bar',
1584 href: 'mailto:/example.com/',
1585 origin: 'null',
1586 protocol: 'mailto:',
1587 username: '',
1588 password: '',
1589 host: '',
1590 hostname: '',
1591 port: '',
1592 pathname: '/example.com/',
1593 search: '',
1594 hash: '',
1595 },
1596 {
1597 input: 'http:example.com/',
1598 base: 'http://example.org/foo/bar',
1599 href: 'http://example.org/foo/example.com/',
1600 origin: 'http://example.org',
1601 protocol: 'http:',
1602 username: '',
1603 password: '',
1604 host: 'example.org',
1605 hostname: 'example.org',
1606 port: '',
1607 pathname: '/foo/example.com/',
1608 search: '',
1609 hash: '',
1610 },
1611 {
1612 input: 'ftp:example.com/',
1613 base: 'http://example.org/foo/bar',
1614 href: 'ftp://example.com/',
1615 origin: 'ftp://example.com',
1616 protocol: 'ftp:',
1617 username: '',
1618 password: '',
1619 host: 'example.com',
1620 hostname: 'example.com',
1621 port: '',
1622 pathname: '/',
1623 search: '',
1624 hash: '',
1625 },
1626 {
1627 input: 'https:example.com/',
1628 base: 'http://example.org/foo/bar',
1629 href: 'https://example.com/',
1630 origin: 'https://example.com',
1631 protocol: 'https:',
1632 username: '',
1633 password: '',
1634 host: 'example.com',
1635 hostname: 'example.com',
1636 port: '',
1637 pathname: '/',
1638 search: '',
1639 hash: '',
1640 },
1641 {
1642 input: 'madeupscheme:example.com/',
1643 base: 'http://example.org/foo/bar',
1644 href: 'madeupscheme:example.com/',
1645 origin: 'null',
1646 protocol: 'madeupscheme:',
1647 username: '',
1648 password: '',
1649 host: '',
1650 hostname: '',
1651 port: '',
1652 pathname: 'example.com/',
1653 search: '',
1654 hash: '',
1655 },
1656 {
1657 input: 'ftps:example.com/',
1658 base: 'http://example.org/foo/bar',
1659 href: 'ftps:example.com/',
1660 origin: 'null',
1661 protocol: 'ftps:',
1662 username: '',
1663 password: '',
1664 host: '',
1665 hostname: '',
1666 port: '',
1667 pathname: 'example.com/',
1668 search: '',
1669 hash: '',
1670 },
1671 {
1672 input: 'gopher:example.com/',
1673 base: 'http://example.org/foo/bar',
1674 href: 'gopher:example.com/',
1675 protocol: 'gopher:',
1676 username: '',
1677 password: '',
1678 host: '',
1679 hostname: '',
1680 port: '',
1681 pathname: 'example.com/',
1682 search: '',
1683 hash: '',
1684 },
1685 {
1686 input: 'ws:example.com/',
1687 base: 'http://example.org/foo/bar',
1688 href: 'ws://example.com/',
1689 origin: 'ws://example.com',
1690 protocol: 'ws:',
1691 username: '',
1692 password: '',
1693 host: 'example.com',
1694 hostname: 'example.com',
1695 port: '',
1696 pathname: '/',
1697 search: '',
1698 hash: '',
1699 },
1700 {
1701 input: 'wss:example.com/',
1702 base: 'http://example.org/foo/bar',
1703 href: 'wss://example.com/',
1704 origin: 'wss://example.com',
1705 protocol: 'wss:',
1706 username: '',
1707 password: '',
1708 host: 'example.com',
1709 hostname: 'example.com',
1710 port: '',
1711 pathname: '/',
1712 search: '',
1713 hash: '',
1714 },
1715 {
1716 input: 'data:example.com/',
1717 base: 'http://example.org/foo/bar',
1718 href: 'data:example.com/',
1719 origin: 'null',
1720 protocol: 'data:',
1721 username: '',
1722 password: '',
1723 host: '',
1724 hostname: '',
1725 port: '',
1726 pathname: 'example.com/',
1727 search: '',
1728 hash: '',
1729 },
1730 {
1731 input: 'javascript:example.com/',
1732 base: 'http://example.org/foo/bar',
1733 href: 'javascript:example.com/',
1734 origin: 'null',
1735 protocol: 'javascript:',
1736 username: '',
1737 password: '',
1738 host: '',
1739 hostname: '',
1740 port: '',
1741 pathname: 'example.com/',
1742 search: '',
1743 hash: '',
1744 },
1745 {
1746 input: 'mailto:example.com/',
1747 base: 'http://example.org/foo/bar',
1748 href: 'mailto:example.com/',
1749 origin: 'null',
1750 protocol: 'mailto:',
1751 username: '',
1752 password: '',
1753 host: '',
1754 hostname: '',
1755 port: '',
1756 pathname: 'example.com/',
1757 search: '',
1758 hash: '',
1759 },
1760 {
1761 input: '/a/b/c',
1762 base: 'http://example.org/foo/bar',
1763 href: 'http://example.org/a/b/c',
1764 origin: 'http://example.org',
1765 protocol: 'http:',
1766 username: '',
1767 password: '',
1768 host: 'example.org',
1769 hostname: 'example.org',
1770 port: '',
1771 pathname: '/a/b/c',
1772 search: '',
1773 hash: '',
1774 },
1775 {
1776 input: '/a/ /c',
1777 base: 'http://example.org/foo/bar',
1778 href: 'http://example.org/a/%20/c',
1779 origin: 'http://example.org',
1780 protocol: 'http:',
1781 username: '',
1782 password: '',
1783 host: 'example.org',
1784 hostname: 'example.org',
1785 port: '',
1786 pathname: '/a/%20/c',
1787 search: '',
1788 hash: '',
1789 },
1790 {
1791 input: '/a%2fc',
1792 base: 'http://example.org/foo/bar',
1793 href: 'http://example.org/a%2fc',
1794 origin: 'http://example.org',
1795 protocol: 'http:',
1796 username: '',
1797 password: '',
1798 host: 'example.org',
1799 hostname: 'example.org',
1800 port: '',
1801 pathname: '/a%2fc',
1802 search: '',
1803 hash: '',
1804 },
1805 {
1806 input: '/a/%2f/c',
1807 base: 'http://example.org/foo/bar',
1808 href: 'http://example.org/a/%2f/c',
1809 origin: 'http://example.org',
1810 protocol: 'http:',
1811 username: '',
1812 password: '',
1813 host: 'example.org',
1814 hostname: 'example.org',
1815 port: '',
1816 pathname: '/a/%2f/c',
1817 search: '',
1818 hash: '',
1819 },
1820 {
1821 input: '#β',
1822 base: 'http://example.org/foo/bar',
1823 href: 'http://example.org/foo/bar#%CE%B2',
1824 origin: 'http://example.org',
1825 protocol: 'http:',
1826 username: '',
1827 password: '',
1828 host: 'example.org',
1829 hostname: 'example.org',
1830 port: '',
1831 pathname: '/foo/bar',
1832 search: '',
1833 hash: '#%CE%B2',
1834 },
1835 {
1836 input: 'data:text/html,test#test',
1837 base: 'http://example.org/foo/bar',
1838 href: 'data:text/html,test#test',
1839 origin: 'null',
1840 protocol: 'data:',
1841 username: '',
1842 password: '',
1843 host: '',
1844 hostname: '',
1845 port: '',
1846 pathname: 'text/html,test',
1847 search: '',
1848 hash: '#test',
1849 },
1850 {
1851 input: 'tel:1234567890',
1852 base: 'http://example.org/foo/bar',
1853 href: 'tel:1234567890',
1854 origin: 'null',
1855 protocol: 'tel:',
1856 username: '',
1857 password: '',
1858 host: '',
1859 hostname: '',
1860 port: '',
1861 pathname: '1234567890',
1862 search: '',
1863 hash: '',
1864 },
1865 '# Based on http://trac.webkit.org/browser/trunk/LayoutTests/fast/url/file.html',
1866 {
1867 input: 'file:c:\\foo\\bar.html',
1868 base: 'file:///tmp/mock/path',
1869 href: 'file:///c:/foo/bar.html',
1870 protocol: 'file:',
1871 username: '',
1872 password: '',
1873 host: '',
1874 hostname: '',
1875 port: '',
1876 pathname: '/c:/foo/bar.html',
1877 search: '',
1878 hash: '',
1879 },
1880 {
1881 input: ' File:c|////foo\\bar.html',
1882 base: 'file:///tmp/mock/path',
1883 href: 'file:///c:////foo/bar.html',
1884 protocol: 'file:',
1885 username: '',
1886 password: '',
1887 host: '',
1888 hostname: '',
1889 port: '',
1890 pathname: '/c:////foo/bar.html',
1891 search: '',
1892 hash: '',
1893 },
1894 {
1895 input: 'C|/foo/bar',
1896 base: 'file:///tmp/mock/path',
1897 href: 'file:///C:/foo/bar',
1898 protocol: 'file:',
1899 username: '',
1900 password: '',
1901 host: '',
1902 hostname: '',
1903 port: '',
1904 pathname: '/C:/foo/bar',
1905 search: '',
1906 hash: '',
1907 },
1908 {
1909 input: '/C|\\foo\\bar',
1910 base: 'file:///tmp/mock/path',
1911 href: 'file:///C:/foo/bar',
1912 protocol: 'file:',
1913 username: '',
1914 password: '',
1915 host: '',
1916 hostname: '',
1917 port: '',
1918 pathname: '/C:/foo/bar',
1919 search: '',
1920 hash: '',
1921 },
1922 {
1923 input: '//C|/foo/bar',
1924 base: 'file:///tmp/mock/path',
1925 href: 'file:///C:/foo/bar',
1926 protocol: 'file:',
1927 username: '',
1928 password: '',
1929 host: '',
1930 hostname: '',
1931 port: '',
1932 pathname: '/C:/foo/bar',
1933 search: '',
1934 hash: '',
1935 },
1936 {
1937 input: '//server/file',
1938 base: 'file:///tmp/mock/path',
1939 href: 'file://server/file',
1940 protocol: 'file:',
1941 username: '',
1942 password: '',
1943 host: 'server',
1944 hostname: 'server',
1945 port: '',
1946 pathname: '/file',
1947 search: '',
1948 hash: '',
1949 },
1950 {
1951 input: '\\\\server\\file',
1952 base: 'file:///tmp/mock/path',
1953 href: 'file://server/file',
1954 protocol: 'file:',
1955 username: '',
1956 password: '',
1957 host: 'server',
1958 hostname: 'server',
1959 port: '',
1960 pathname: '/file',
1961 search: '',
1962 hash: '',
1963 },
1964 {
1965 input: '/\\server/file',
1966 base: 'file:///tmp/mock/path',
1967 href: 'file://server/file',
1968 protocol: 'file:',
1969 username: '',
1970 password: '',
1971 host: 'server',
1972 hostname: 'server',
1973 port: '',
1974 pathname: '/file',
1975 search: '',
1976 hash: '',
1977 },
1978 {
1979 input: 'file:///foo/bar.txt',
1980 base: 'file:///tmp/mock/path',
1981 href: 'file:///foo/bar.txt',
1982 protocol: 'file:',
1983 username: '',
1984 password: '',
1985 host: '',
1986 hostname: '',
1987 port: '',
1988 pathname: '/foo/bar.txt',
1989 search: '',
1990 hash: '',
1991 },
1992 {
1993 input: 'file:///home/me',
1994 base: 'file:///tmp/mock/path',
1995 href: 'file:///home/me',
1996 protocol: 'file:',
1997 username: '',
1998 password: '',
1999 host: '',
2000 hostname: '',
2001 port: '',
2002 pathname: '/home/me',
2003 search: '',
2004 hash: '',
2005 },
2006 {
2007 input: '//',
2008 base: 'file:///tmp/mock/path',
2009 href: 'file:///',
2010 protocol: 'file:',
2011 username: '',
2012 password: '',
2013 host: '',
2014 hostname: '',
2015 port: '',
2016 pathname: '/',
2017 search: '',
2018 hash: '',
2019 },
2020 {
2021 input: '///',
2022 base: 'file:///tmp/mock/path',
2023 href: 'file:///',
2024 protocol: 'file:',
2025 username: '',
2026 password: '',
2027 host: '',
2028 hostname: '',
2029 port: '',
2030 pathname: '/',
2031 search: '',
2032 hash: '',
2033 },
2034 {
2035 input: '///test',
2036 base: 'file:///tmp/mock/path',
2037 href: 'file:///test',
2038 protocol: 'file:',
2039 username: '',
2040 password: '',
2041 host: '',
2042 hostname: '',
2043 port: '',
2044 pathname: '/test',
2045 search: '',
2046 hash: '',
2047 },
2048 {
2049 input: 'file://test',
2050 base: 'file:///tmp/mock/path',
2051 href: 'file://test/',
2052 protocol: 'file:',
2053 username: '',
2054 password: '',
2055 host: 'test',
2056 hostname: 'test',
2057 port: '',
2058 pathname: '/',
2059 search: '',
2060 hash: '',
2061 },
2062 {
2063 input: 'file://localhost',
2064 base: 'file:///tmp/mock/path',
2065 href: 'file:///',
2066 protocol: 'file:',
2067 username: '',
2068 password: '',
2069 host: '',
2070 hostname: '',
2071 port: '',
2072 pathname: '/',
2073 search: '',
2074 hash: '',
2075 },
2076 {
2077 input: 'file://localhost/',
2078 base: 'file:///tmp/mock/path',
2079 href: 'file:///',
2080 protocol: 'file:',
2081 username: '',
2082 password: '',
2083 host: '',
2084 hostname: '',
2085 port: '',
2086 pathname: '/',
2087 search: '',
2088 hash: '',
2089 },
2090 {
2091 input: 'file://localhost/test',
2092 base: 'file:///tmp/mock/path',
2093 href: 'file:///test',
2094 protocol: 'file:',
2095 username: '',
2096 password: '',
2097 host: '',
2098 hostname: '',
2099 port: '',
2100 pathname: '/test',
2101 search: '',
2102 hash: '',
2103 },
2104 {
2105 input: 'test',
2106 base: 'file:///tmp/mock/path',
2107 href: 'file:///tmp/mock/test',
2108 protocol: 'file:',
2109 username: '',
2110 password: '',
2111 host: '',
2112 hostname: '',
2113 port: '',
2114 pathname: '/tmp/mock/test',
2115 search: '',
2116 hash: '',
2117 },
2118 {
2119 input: 'file:test',
2120 base: 'file:///tmp/mock/path',
2121 href: 'file:///tmp/mock/test',
2122 protocol: 'file:',
2123 username: '',
2124 password: '',
2125 host: '',
2126 hostname: '',
2127 port: '',
2128 pathname: '/tmp/mock/test',
2129 search: '',
2130 hash: '',
2131 },
2132 '# Based on http://trac.webkit.org/browser/trunk/LayoutTests/fast/url/script-tests/path.js',
2133 {
2134 input: 'http://example.com/././foo',
2135 base: 'about:blank',
2136 href: 'http://example.com/foo',
2137 origin: 'http://example.com',
2138 protocol: 'http:',
2139 username: '',
2140 password: '',
2141 host: 'example.com',
2142 hostname: 'example.com',
2143 port: '',
2144 pathname: '/foo',
2145 search: '',
2146 hash: '',
2147 },
2148 {
2149 input: 'http://example.com/./.foo',
2150 base: 'about:blank',
2151 href: 'http://example.com/.foo',
2152 origin: 'http://example.com',
2153 protocol: 'http:',
2154 username: '',
2155 password: '',
2156 host: 'example.com',
2157 hostname: 'example.com',
2158 port: '',
2159 pathname: '/.foo',
2160 search: '',
2161 hash: '',
2162 },
2163 {
2164 input: 'http://example.com/foo/.',
2165 base: 'about:blank',
2166 href: 'http://example.com/foo/',
2167 origin: 'http://example.com',
2168 protocol: 'http:',
2169 username: '',
2170 password: '',
2171 host: 'example.com',
2172 hostname: 'example.com',
2173 port: '',
2174 pathname: '/foo/',
2175 search: '',
2176 hash: '',
2177 },
2178 {
2179 input: 'http://example.com/foo/./',
2180 base: 'about:blank',
2181 href: 'http://example.com/foo/',
2182 origin: 'http://example.com',
2183 protocol: 'http:',
2184 username: '',
2185 password: '',
2186 host: 'example.com',
2187 hostname: 'example.com',
2188 port: '',
2189 pathname: '/foo/',
2190 search: '',
2191 hash: '',
2192 },
2193 {
2194 input: 'http://example.com/foo/bar/..',
2195 base: 'about:blank',
2196 href: 'http://example.com/foo/',
2197 origin: 'http://example.com',
2198 protocol: 'http:',
2199 username: '',
2200 password: '',
2201 host: 'example.com',
2202 hostname: 'example.com',
2203 port: '',
2204 pathname: '/foo/',
2205 search: '',
2206 hash: '',
2207 },
2208 {
2209 input: 'http://example.com/foo/bar/../',
2210 base: 'about:blank',
2211 href: 'http://example.com/foo/',
2212 origin: 'http://example.com',
2213 protocol: 'http:',
2214 username: '',
2215 password: '',
2216 host: 'example.com',
2217 hostname: 'example.com',
2218 port: '',
2219 pathname: '/foo/',
2220 search: '',
2221 hash: '',
2222 },
2223 {
2224 input: 'http://example.com/foo/..bar',
2225 base: 'about:blank',
2226 href: 'http://example.com/foo/..bar',
2227 origin: 'http://example.com',
2228 protocol: 'http:',
2229 username: '',
2230 password: '',
2231 host: 'example.com',
2232 hostname: 'example.com',
2233 port: '',
2234 pathname: '/foo/..bar',
2235 search: '',
2236 hash: '',
2237 },
2238 {
2239 input: 'http://example.com/foo/bar/../ton',
2240 base: 'about:blank',
2241 href: 'http://example.com/foo/ton',
2242 origin: 'http://example.com',
2243 protocol: 'http:',
2244 username: '',
2245 password: '',
2246 host: 'example.com',
2247 hostname: 'example.com',
2248 port: '',
2249 pathname: '/foo/ton',
2250 search: '',
2251 hash: '',
2252 },
2253 {
2254 input: 'http://example.com/foo/bar/../ton/../../a',
2255 base: 'about:blank',
2256 href: 'http://example.com/a',
2257 origin: 'http://example.com',
2258 protocol: 'http:',
2259 username: '',
2260 password: '',
2261 host: 'example.com',
2262 hostname: 'example.com',
2263 port: '',
2264 pathname: '/a',
2265 search: '',
2266 hash: '',
2267 },
2268 {
2269 input: 'http://example.com/foo/../../..',
2270 base: 'about:blank',
2271 href: 'http://example.com/',
2272 origin: 'http://example.com',
2273 protocol: 'http:',
2274 username: '',
2275 password: '',
2276 host: 'example.com',
2277 hostname: 'example.com',
2278 port: '',
2279 pathname: '/',
2280 search: '',
2281 hash: '',
2282 },
2283 {
2284 input: 'http://example.com/foo/../../../ton',
2285 base: 'about:blank',
2286 href: 'http://example.com/ton',
2287 origin: 'http://example.com',
2288 protocol: 'http:',
2289 username: '',
2290 password: '',
2291 host: 'example.com',
2292 hostname: 'example.com',
2293 port: '',
2294 pathname: '/ton',
2295 search: '',
2296 hash: '',
2297 },
2298 {
2299 input: 'http://example.com/foo/%2e',
2300 base: 'about:blank',
2301 href: 'http://example.com/foo/',
2302 origin: 'http://example.com',
2303 protocol: 'http:',
2304 username: '',
2305 password: '',
2306 host: 'example.com',
2307 hostname: 'example.com',
2308 port: '',
2309 pathname: '/foo/',
2310 search: '',
2311 hash: '',
2312 },
2313 {
2314 input: 'http://example.com/foo/%2e%2',
2315 base: 'about:blank',
2316 href: 'http://example.com/foo/%2e%2',
2317 origin: 'http://example.com',
2318 protocol: 'http:',
2319 username: '',
2320 password: '',
2321 host: 'example.com',
2322 hostname: 'example.com',
2323 port: '',
2324 pathname: '/foo/%2e%2',
2325 search: '',
2326 hash: '',
2327 },
2328 {
2329 input: 'http://example.com/foo/%2e./%2e%2e/.%2e/%2e.bar',
2330 base: 'about:blank',
2331 href: 'http://example.com/%2e.bar',
2332 origin: 'http://example.com',
2333 protocol: 'http:',
2334 username: '',
2335 password: '',
2336 host: 'example.com',
2337 hostname: 'example.com',
2338 port: '',
2339 pathname: '/%2e.bar',
2340 search: '',
2341 hash: '',
2342 },
2343 {
2344 input: 'http://example.com////../..',
2345 base: 'about:blank',
2346 href: 'http://example.com//',
2347 origin: 'http://example.com',
2348 protocol: 'http:',
2349 username: '',
2350 password: '',
2351 host: 'example.com',
2352 hostname: 'example.com',
2353 port: '',
2354 pathname: '//',
2355 search: '',
2356 hash: '',
2357 },
2358 {
2359 input: 'http://example.com/foo/bar//../..',
2360 base: 'about:blank',
2361 href: 'http://example.com/foo/',
2362 origin: 'http://example.com',
2363 protocol: 'http:',
2364 username: '',
2365 password: '',
2366 host: 'example.com',
2367 hostname: 'example.com',
2368 port: '',
2369 pathname: '/foo/',
2370 search: '',
2371 hash: '',
2372 },
2373 {
2374 input: 'http://example.com/foo/bar//..',
2375 base: 'about:blank',
2376 href: 'http://example.com/foo/bar/',
2377 origin: 'http://example.com',
2378 protocol: 'http:',
2379 username: '',
2380 password: '',
2381 host: 'example.com',
2382 hostname: 'example.com',
2383 port: '',
2384 pathname: '/foo/bar/',
2385 search: '',
2386 hash: '',
2387 },
2388 {
2389 input: 'http://example.com/foo',
2390 base: 'about:blank',
2391 href: 'http://example.com/foo',
2392 origin: 'http://example.com',
2393 protocol: 'http:',
2394 username: '',
2395 password: '',
2396 host: 'example.com',
2397 hostname: 'example.com',
2398 port: '',
2399 pathname: '/foo',
2400 search: '',
2401 hash: '',
2402 },
2403 {
2404 input: 'http://example.com/%20foo',
2405 base: 'about:blank',
2406 href: 'http://example.com/%20foo',
2407 origin: 'http://example.com',
2408 protocol: 'http:',
2409 username: '',
2410 password: '',
2411 host: 'example.com',
2412 hostname: 'example.com',
2413 port: '',
2414 pathname: '/%20foo',
2415 search: '',
2416 hash: '',
2417 },
2418 {
2419 input: 'http://example.com/foo%',
2420 base: 'about:blank',
2421 href: 'http://example.com/foo%',
2422 origin: 'http://example.com',
2423 protocol: 'http:',
2424 username: '',
2425 password: '',
2426 host: 'example.com',
2427 hostname: 'example.com',
2428 port: '',
2429 pathname: '/foo%',
2430 search: '',
2431 hash: '',
2432 },
2433 {
2434 input: 'http://example.com/foo%2',
2435 base: 'about:blank',
2436 href: 'http://example.com/foo%2',
2437 origin: 'http://example.com',
2438 protocol: 'http:',
2439 username: '',
2440 password: '',
2441 host: 'example.com',
2442 hostname: 'example.com',
2443 port: '',
2444 pathname: '/foo%2',
2445 search: '',
2446 hash: '',
2447 },
2448 {
2449 input: 'http://example.com/foo%2zbar',
2450 base: 'about:blank',
2451 href: 'http://example.com/foo%2zbar',
2452 origin: 'http://example.com',
2453 protocol: 'http:',
2454 username: '',
2455 password: '',
2456 host: 'example.com',
2457 hostname: 'example.com',
2458 port: '',
2459 pathname: '/foo%2zbar',
2460 search: '',
2461 hash: '',
2462 },
2463 {
2464 input: 'http://example.com/foo%2©zbar',
2465 base: 'about:blank',
2466 href: 'http://example.com/foo%2%C3%82%C2%A9zbar',
2467 origin: 'http://example.com',
2468 protocol: 'http:',
2469 username: '',
2470 password: '',
2471 host: 'example.com',
2472 hostname: 'example.com',
2473 port: '',
2474 pathname: '/foo%2%C3%82%C2%A9zbar',
2475 search: '',
2476 hash: '',
2477 },
2478 {
2479 input: 'http://example.com/foo%41%7a',
2480 base: 'about:blank',
2481 href: 'http://example.com/foo%41%7a',
2482 origin: 'http://example.com',
2483 protocol: 'http:',
2484 username: '',
2485 password: '',
2486 host: 'example.com',
2487 hostname: 'example.com',
2488 port: '',
2489 pathname: '/foo%41%7a',
2490 search: '',
2491 hash: '',
2492 },
2493 {
2494 input: 'http://example.com/foo\t\u0091%91',
2495 base: 'about:blank',
2496 href: 'http://example.com/foo%C2%91%91',
2497 origin: 'http://example.com',
2498 protocol: 'http:',
2499 username: '',
2500 password: '',
2501 host: 'example.com',
2502 hostname: 'example.com',
2503 port: '',
2504 pathname: '/foo%C2%91%91',
2505 search: '',
2506 hash: '',
2507 },
2508 {
2509 input: 'http://example.com/foo%00%51',
2510 base: 'about:blank',
2511 href: 'http://example.com/foo%00%51',
2512 origin: 'http://example.com',
2513 protocol: 'http:',
2514 username: '',
2515 password: '',
2516 host: 'example.com',
2517 hostname: 'example.com',
2518 port: '',
2519 pathname: '/foo%00%51',
2520 search: '',
2521 hash: '',
2522 },
2523 {
2524 input: 'http://example.com/(%28:%3A%29)',
2525 base: 'about:blank',
2526 href: 'http://example.com/(%28:%3A%29)',
2527 origin: 'http://example.com',
2528 protocol: 'http:',
2529 username: '',
2530 password: '',
2531 host: 'example.com',
2532 hostname: 'example.com',
2533 port: '',
2534 pathname: '/(%28:%3A%29)',
2535 search: '',
2536 hash: '',
2537 },
2538 {
2539 input: 'http://example.com/%3A%3a%3C%3c',
2540 base: 'about:blank',
2541 href: 'http://example.com/%3A%3a%3C%3c',
2542 origin: 'http://example.com',
2543 protocol: 'http:',
2544 username: '',
2545 password: '',
2546 host: 'example.com',
2547 hostname: 'example.com',
2548 port: '',
2549 pathname: '/%3A%3a%3C%3c',
2550 search: '',
2551 hash: '',
2552 },
2553 {
2554 input: 'http://example.com/foo\tbar',
2555 base: 'about:blank',
2556 href: 'http://example.com/foobar',
2557 origin: 'http://example.com',
2558 protocol: 'http:',
2559 username: '',
2560 password: '',
2561 host: 'example.com',
2562 hostname: 'example.com',
2563 port: '',
2564 pathname: '/foobar',
2565 search: '',
2566 hash: '',
2567 },
2568 {
2569 input: 'http://example.com\\\\foo\\\\bar',
2570 base: 'about:blank',
2571 href: 'http://example.com//foo//bar',
2572 origin: 'http://example.com',
2573 protocol: 'http:',
2574 username: '',
2575 password: '',
2576 host: 'example.com',
2577 hostname: 'example.com',
2578 port: '',
2579 pathname: '//foo//bar',
2580 search: '',
2581 hash: '',
2582 },
2583 {
2584 input: 'http://example.com/%7Ffp3%3Eju%3Dduvgw%3Dd',
2585 base: 'about:blank',
2586 href: 'http://example.com/%7Ffp3%3Eju%3Dduvgw%3Dd',
2587 origin: 'http://example.com',
2588 protocol: 'http:',
2589 username: '',
2590 password: '',
2591 host: 'example.com',
2592 hostname: 'example.com',
2593 port: '',
2594 pathname: '/%7Ffp3%3Eju%3Dduvgw%3Dd',
2595 search: '',
2596 hash: '',
2597 },
2598 {
2599 input: 'http://example.com/@asdf%40',
2600 base: 'about:blank',
2601 href: 'http://example.com/@asdf%40',
2602 origin: 'http://example.com',
2603 protocol: 'http:',
2604 username: '',
2605 password: '',
2606 host: 'example.com',
2607 hostname: 'example.com',
2608 port: '',
2609 pathname: '/@asdf%40',
2610 search: '',
2611 hash: '',
2612 },
2613 {
2614 input: 'http://example.com/你好你好',
2615 base: 'about:blank',
2616 href: 'http://example.com/%E4%BD%A0%E5%A5%BD%E4%BD%A0%E5%A5%BD',
2617 origin: 'http://example.com',
2618 protocol: 'http:',
2619 username: '',
2620 password: '',
2621 host: 'example.com',
2622 hostname: 'example.com',
2623 port: '',
2624 pathname: '/%E4%BD%A0%E5%A5%BD%E4%BD%A0%E5%A5%BD',
2625 search: '',
2626 hash: '',
2627 },
2628 {
2629 input: 'http://example.com/‥/foo',
2630 base: 'about:blank',
2631 href: 'http://example.com/%E2%80%A5/foo',
2632 origin: 'http://example.com',
2633 protocol: 'http:',
2634 username: '',
2635 password: '',
2636 host: 'example.com',
2637 hostname: 'example.com',
2638 port: '',
2639 pathname: '/%E2%80%A5/foo',
2640 search: '',
2641 hash: '',
2642 },
2643 {
2644 input: 'http://example.com//foo',
2645 base: 'about:blank',
2646 href: 'http://example.com/%EF%BB%BF/foo',
2647 origin: 'http://example.com',
2648 protocol: 'http:',
2649 username: '',
2650 password: '',
2651 host: 'example.com',
2652 hostname: 'example.com',
2653 port: '',
2654 pathname: '/%EF%BB%BF/foo',
2655 search: '',
2656 hash: '',
2657 },
2658 {
2659 input: 'http://example.com/‮/foo/‭/bar',
2660 base: 'about:blank',
2661 href: 'http://example.com/%E2%80%AE/foo/%E2%80%AD/bar',
2662 origin: 'http://example.com',
2663 protocol: 'http:',
2664 username: '',
2665 password: '',
2666 host: 'example.com',
2667 hostname: 'example.com',
2668 port: '',
2669 pathname: '/%E2%80%AE/foo/%E2%80%AD/bar',
2670 search: '',
2671 hash: '',
2672 },
2673 '# Based on http://trac.webkit.org/browser/trunk/LayoutTests/fast/url/script-tests/relative.js',
2674 {
2675 input: 'http://www.google.com/foo?bar=baz#',
2676 base: 'about:blank',
2677 href: 'http://www.google.com/foo?bar=baz#',
2678 origin: 'http://www.google.com',
2679 protocol: 'http:',
2680 username: '',
2681 password: '',
2682 host: 'www.google.com',
2683 hostname: 'www.google.com',
2684 port: '',
2685 pathname: '/foo',
2686 search: '?bar=baz',
2687 hash: '',
2688 },
2689 {
2690 input: 'http://www.google.com/foo?bar=baz# »',
2691 base: 'about:blank',
2692 href: 'http://www.google.com/foo?bar=baz#%20%C2%BB',
2693 origin: 'http://www.google.com',
2694 protocol: 'http:',
2695 username: '',
2696 password: '',
2697 host: 'www.google.com',
2698 hostname: 'www.google.com',
2699 port: '',
2700 pathname: '/foo',
2701 search: '?bar=baz',
2702 hash: '#%20%C2%BB',
2703 },
2704 {
2705 input: 'data:test# »',
2706 base: 'about:blank',
2707 href: 'data:test#%20%C2%BB',
2708 origin: 'null',
2709 protocol: 'data:',
2710 username: '',
2711 password: '',
2712 host: '',
2713 hostname: '',
2714 port: '',
2715 pathname: 'test',
2716 search: '',
2717 hash: '#%20%C2%BB',
2718 },
2719 {
2720 input: 'http://www.google.com',
2721 base: 'about:blank',
2722 href: 'http://www.google.com/',
2723 origin: 'http://www.google.com',
2724 protocol: 'http:',
2725 username: '',
2726 password: '',
2727 host: 'www.google.com',
2728 hostname: 'www.google.com',
2729 port: '',
2730 pathname: '/',
2731 search: '',
2732 hash: '',
2733 },
2734 {
2735 input: 'http://192.0x00A80001',
2736 base: 'about:blank',
2737 href: 'http://192.168.0.1/',
2738 origin: 'http://192.168.0.1',
2739 protocol: 'http:',
2740 username: '',
2741 password: '',
2742 host: '192.168.0.1',
2743 hostname: '192.168.0.1',
2744 port: '',
2745 pathname: '/',
2746 search: '',
2747 hash: '',
2748 },
2749 {
2750 input: 'http://www/foo%2Ehtml',
2751 base: 'about:blank',
2752 href: 'http://www/foo%2Ehtml',
2753 origin: 'http://www',
2754 protocol: 'http:',
2755 username: '',
2756 password: '',
2757 host: 'www',
2758 hostname: 'www',
2759 port: '',
2760 pathname: '/foo%2Ehtml',
2761 search: '',
2762 hash: '',
2763 },
2764 {
2765 input: 'http://www/foo/%2E/html',
2766 base: 'about:blank',
2767 href: 'http://www/foo/html',
2768 origin: 'http://www',
2769 protocol: 'http:',
2770 username: '',
2771 password: '',
2772 host: 'www',
2773 hostname: 'www',
2774 port: '',
2775 pathname: '/foo/html',
2776 search: '',
2777 hash: '',
2778 },
2779 {
2780 input: 'http://user:pass@/',
2781 base: 'about:blank',
2782 failure: true,
2783 },
2784 {
2785 input: 'http://%25DOMAIN:foobar@foodomain.com/',
2786 base: 'about:blank',
2787 href: 'http://%25DOMAIN:foobar@foodomain.com/',
2788 origin: 'http://foodomain.com',
2789 protocol: 'http:',
2790 username: '%25DOMAIN',
2791 password: 'foobar',
2792 host: 'foodomain.com',
2793 hostname: 'foodomain.com',
2794 port: '',
2795 pathname: '/',
2796 search: '',
2797 hash: '',
2798 },
2799 {
2800 input: 'http:\\\\www.google.com\\foo',
2801 base: 'about:blank',
2802 href: 'http://www.google.com/foo',
2803 origin: 'http://www.google.com',
2804 protocol: 'http:',
2805 username: '',
2806 password: '',
2807 host: 'www.google.com',
2808 hostname: 'www.google.com',
2809 port: '',
2810 pathname: '/foo',
2811 search: '',
2812 hash: '',
2813 },
2814 {
2815 input: 'http://foo:80/',
2816 base: 'about:blank',
2817 href: 'http://foo/',
2818 origin: 'http://foo',
2819 protocol: 'http:',
2820 username: '',
2821 password: '',
2822 host: 'foo',
2823 hostname: 'foo',
2824 port: '',
2825 pathname: '/',
2826 search: '',
2827 hash: '',
2828 },
2829 {
2830 input: 'http://foo:81/',
2831 base: 'about:blank',
2832 href: 'http://foo:81/',
2833 origin: 'http://foo:81',
2834 protocol: 'http:',
2835 username: '',
2836 password: '',
2837 host: 'foo:81',
2838 hostname: 'foo',
2839 port: '81',
2840 pathname: '/',
2841 search: '',
2842 hash: '',
2843 },
2844 {
2845 input: 'httpa://foo:80/',
2846 base: 'about:blank',
2847 href: 'httpa://foo:80/',
2848 origin: 'null',
2849 protocol: 'httpa:',
2850 username: '',
2851 password: '',
2852 host: 'foo:80',
2853 hostname: 'foo',
2854 port: '80',
2855 pathname: '/',
2856 search: '',
2857 hash: '',
2858 },
2859 {
2860 input: 'http://foo:-80/',
2861 base: 'about:blank',
2862 failure: true,
2863 },
2864 {
2865 input: 'https://foo:443/',
2866 base: 'about:blank',
2867 href: 'https://foo/',
2868 origin: 'https://foo',
2869 protocol: 'https:',
2870 username: '',
2871 password: '',
2872 host: 'foo',
2873 hostname: 'foo',
2874 port: '',
2875 pathname: '/',
2876 search: '',
2877 hash: '',
2878 },
2879 {
2880 input: 'https://foo:80/',
2881 base: 'about:blank',
2882 href: 'https://foo:80/',
2883 origin: 'https://foo:80',
2884 protocol: 'https:',
2885 username: '',
2886 password: '',
2887 host: 'foo:80',
2888 hostname: 'foo',
2889 port: '80',
2890 pathname: '/',
2891 search: '',
2892 hash: '',
2893 },
2894 {
2895 input: 'ftp://foo:21/',
2896 base: 'about:blank',
2897 href: 'ftp://foo/',
2898 origin: 'ftp://foo',
2899 protocol: 'ftp:',
2900 username: '',
2901 password: '',
2902 host: 'foo',
2903 hostname: 'foo',
2904 port: '',
2905 pathname: '/',
2906 search: '',
2907 hash: '',
2908 },
2909 {
2910 input: 'ftp://foo:80/',
2911 base: 'about:blank',
2912 href: 'ftp://foo:80/',
2913 origin: 'ftp://foo:80',
2914 protocol: 'ftp:',
2915 username: '',
2916 password: '',
2917 host: 'foo:80',
2918 hostname: 'foo',
2919 port: '80',
2920 pathname: '/',
2921 search: '',
2922 hash: '',
2923 },
2924 {
2925 input: 'gopher://foo:70/',
2926 base: 'about:blank',
2927 href: 'gopher://foo:70/',
2928 protocol: 'gopher:',
2929 username: '',
2930 password: '',
2931 host: 'foo:70',
2932 hostname: 'foo',
2933 port: '70',
2934 pathname: '/',
2935 search: '',
2936 hash: '',
2937 },
2938 {
2939 input: 'gopher://foo:443/',
2940 base: 'about:blank',
2941 href: 'gopher://foo:443/',
2942 protocol: 'gopher:',
2943 username: '',
2944 password: '',
2945 host: 'foo:443',
2946 hostname: 'foo',
2947 port: '443',
2948 pathname: '/',
2949 search: '',
2950 hash: '',
2951 },
2952 {
2953 input: 'ws://foo:80/',
2954 base: 'about:blank',
2955 href: 'ws://foo/',
2956 origin: 'ws://foo',
2957 protocol: 'ws:',
2958 username: '',
2959 password: '',
2960 host: 'foo',
2961 hostname: 'foo',
2962 port: '',
2963 pathname: '/',
2964 search: '',
2965 hash: '',
2966 },
2967 {
2968 input: 'ws://foo:81/',
2969 base: 'about:blank',
2970 href: 'ws://foo:81/',
2971 origin: 'ws://foo:81',
2972 protocol: 'ws:',
2973 username: '',
2974 password: '',
2975 host: 'foo:81',
2976 hostname: 'foo',
2977 port: '81',
2978 pathname: '/',
2979 search: '',
2980 hash: '',
2981 },
2982 {
2983 input: 'ws://foo:443/',
2984 base: 'about:blank',
2985 href: 'ws://foo:443/',
2986 origin: 'ws://foo:443',
2987 protocol: 'ws:',
2988 username: '',
2989 password: '',
2990 host: 'foo:443',
2991 hostname: 'foo',
2992 port: '443',
2993 pathname: '/',
2994 search: '',
2995 hash: '',
2996 },
2997 {
2998 input: 'ws://foo:815/',
2999 base: 'about:blank',
3000 href: 'ws://foo:815/',
3001 origin: 'ws://foo:815',
3002 protocol: 'ws:',
3003 username: '',
3004 password: '',
3005 host: 'foo:815',
3006 hostname: 'foo',
3007 port: '815',
3008 pathname: '/',
3009 search: '',
3010 hash: '',
3011 },
3012 {
3013 input: 'wss://foo:80/',
3014 base: 'about:blank',
3015 href: 'wss://foo:80/',
3016 origin: 'wss://foo:80',
3017 protocol: 'wss:',
3018 username: '',
3019 password: '',
3020 host: 'foo:80',
3021 hostname: 'foo',
3022 port: '80',
3023 pathname: '/',
3024 search: '',
3025 hash: '',
3026 },
3027 {
3028 input: 'wss://foo:81/',
3029 base: 'about:blank',
3030 href: 'wss://foo:81/',
3031 origin: 'wss://foo:81',
3032 protocol: 'wss:',
3033 username: '',
3034 password: '',
3035 host: 'foo:81',
3036 hostname: 'foo',
3037 port: '81',
3038 pathname: '/',
3039 search: '',
3040 hash: '',
3041 },
3042 {
3043 input: 'wss://foo:443/',
3044 base: 'about:blank',
3045 href: 'wss://foo/',
3046 origin: 'wss://foo',
3047 protocol: 'wss:',
3048 username: '',
3049 password: '',
3050 host: 'foo',
3051 hostname: 'foo',
3052 port: '',
3053 pathname: '/',
3054 search: '',
3055 hash: '',
3056 },
3057 {
3058 input: 'wss://foo:815/',
3059 base: 'about:blank',
3060 href: 'wss://foo:815/',
3061 origin: 'wss://foo:815',
3062 protocol: 'wss:',
3063 username: '',
3064 password: '',
3065 host: 'foo:815',
3066 hostname: 'foo',
3067 port: '815',
3068 pathname: '/',
3069 search: '',
3070 hash: '',
3071 },
3072 {
3073 input: 'http:/example.com/',
3074 base: 'about:blank',
3075 href: 'http://example.com/',
3076 origin: 'http://example.com',
3077 protocol: 'http:',
3078 username: '',
3079 password: '',
3080 host: 'example.com',
3081 hostname: 'example.com',
3082 port: '',
3083 pathname: '/',
3084 search: '',
3085 hash: '',
3086 },
3087 {
3088 input: 'ftp:/example.com/',
3089 base: 'about:blank',
3090 href: 'ftp://example.com/',
3091 origin: 'ftp://example.com',
3092 protocol: 'ftp:',
3093 username: '',
3094 password: '',
3095 host: 'example.com',
3096 hostname: 'example.com',
3097 port: '',
3098 pathname: '/',
3099 search: '',
3100 hash: '',
3101 },
3102 {
3103 input: 'https:/example.com/',
3104 base: 'about:blank',
3105 href: 'https://example.com/',
3106 origin: 'https://example.com',
3107 protocol: 'https:',
3108 username: '',
3109 password: '',
3110 host: 'example.com',
3111 hostname: 'example.com',
3112 port: '',
3113 pathname: '/',
3114 search: '',
3115 hash: '',
3116 },
3117 {
3118 input: 'madeupscheme:/example.com/',
3119 base: 'about:blank',
3120 href: 'madeupscheme:/example.com/',
3121 origin: 'null',
3122 protocol: 'madeupscheme:',
3123 username: '',
3124 password: '',
3125 host: '',
3126 hostname: '',
3127 port: '',
3128 pathname: '/example.com/',
3129 search: '',
3130 hash: '',
3131 },
3132 {
3133 input: 'file:/example.com/',
3134 base: 'about:blank',
3135 href: 'file:///example.com/',
3136 protocol: 'file:',
3137 username: '',
3138 password: '',
3139 host: '',
3140 hostname: '',
3141 port: '',
3142 pathname: '/example.com/',
3143 search: '',
3144 hash: '',
3145 },
3146 {
3147 input: 'ftps:/example.com/',
3148 base: 'about:blank',
3149 href: 'ftps:/example.com/',
3150 origin: 'null',
3151 protocol: 'ftps:',
3152 username: '',
3153 password: '',
3154 host: '',
3155 hostname: '',
3156 port: '',
3157 pathname: '/example.com/',
3158 search: '',
3159 hash: '',
3160 },
3161 {
3162 input: 'gopher:/example.com/',
3163 base: 'about:blank',
3164 href: 'gopher:/example.com/',
3165 protocol: 'gopher:',
3166 username: '',
3167 password: '',
3168 host: '',
3169 hostname: '',
3170 port: '',
3171 pathname: '/example.com/',
3172 search: '',
3173 hash: '',
3174 },
3175 {
3176 input: 'ws:/example.com/',
3177 base: 'about:blank',
3178 href: 'ws://example.com/',
3179 origin: 'ws://example.com',
3180 protocol: 'ws:',
3181 username: '',
3182 password: '',
3183 host: 'example.com',
3184 hostname: 'example.com',
3185 port: '',
3186 pathname: '/',
3187 search: '',
3188 hash: '',
3189 },
3190 {
3191 input: 'wss:/example.com/',
3192 base: 'about:blank',
3193 href: 'wss://example.com/',
3194 origin: 'wss://example.com',
3195 protocol: 'wss:',
3196 username: '',
3197 password: '',
3198 host: 'example.com',
3199 hostname: 'example.com',
3200 port: '',
3201 pathname: '/',
3202 search: '',
3203 hash: '',
3204 },
3205 {
3206 input: 'data:/example.com/',
3207 base: 'about:blank',
3208 href: 'data:/example.com/',
3209 origin: 'null',
3210 protocol: 'data:',
3211 username: '',
3212 password: '',
3213 host: '',
3214 hostname: '',
3215 port: '',
3216 pathname: '/example.com/',
3217 search: '',
3218 hash: '',
3219 },
3220 {
3221 input: 'javascript:/example.com/',
3222 base: 'about:blank',
3223 href: 'javascript:/example.com/',
3224 origin: 'null',
3225 protocol: 'javascript:',
3226 username: '',
3227 password: '',
3228 host: '',
3229 hostname: '',
3230 port: '',
3231 pathname: '/example.com/',
3232 search: '',
3233 hash: '',
3234 },
3235 {
3236 input: 'mailto:/example.com/',
3237 base: 'about:blank',
3238 href: 'mailto:/example.com/',
3239 origin: 'null',
3240 protocol: 'mailto:',
3241 username: '',
3242 password: '',
3243 host: '',
3244 hostname: '',
3245 port: '',
3246 pathname: '/example.com/',
3247 search: '',
3248 hash: '',
3249 },
3250 {
3251 input: 'http:example.com/',
3252 base: 'about:blank',
3253 href: 'http://example.com/',
3254 origin: 'http://example.com',
3255 protocol: 'http:',
3256 username: '',
3257 password: '',
3258 host: 'example.com',
3259 hostname: 'example.com',
3260 port: '',
3261 pathname: '/',
3262 search: '',
3263 hash: '',
3264 },
3265 {
3266 input: 'ftp:example.com/',
3267 base: 'about:blank',
3268 href: 'ftp://example.com/',
3269 origin: 'ftp://example.com',
3270 protocol: 'ftp:',
3271 username: '',
3272 password: '',
3273 host: 'example.com',
3274 hostname: 'example.com',
3275 port: '',
3276 pathname: '/',
3277 search: '',
3278 hash: '',
3279 },
3280 {
3281 input: 'https:example.com/',
3282 base: 'about:blank',
3283 href: 'https://example.com/',
3284 origin: 'https://example.com',
3285 protocol: 'https:',
3286 username: '',
3287 password: '',
3288 host: 'example.com',
3289 hostname: 'example.com',
3290 port: '',
3291 pathname: '/',
3292 search: '',
3293 hash: '',
3294 },
3295 {
3296 input: 'madeupscheme:example.com/',
3297 base: 'about:blank',
3298 href: 'madeupscheme:example.com/',
3299 origin: 'null',
3300 protocol: 'madeupscheme:',
3301 username: '',
3302 password: '',
3303 host: '',
3304 hostname: '',
3305 port: '',
3306 pathname: 'example.com/',
3307 search: '',
3308 hash: '',
3309 },
3310 {
3311 input: 'ftps:example.com/',
3312 base: 'about:blank',
3313 href: 'ftps:example.com/',
3314 origin: 'null',
3315 protocol: 'ftps:',
3316 username: '',
3317 password: '',
3318 host: '',
3319 hostname: '',
3320 port: '',
3321 pathname: 'example.com/',
3322 search: '',
3323 hash: '',
3324 },
3325 {
3326 input: 'gopher:example.com/',
3327 base: 'about:blank',
3328 href: 'gopher:example.com/',
3329 protocol: 'gopher:',
3330 username: '',
3331 password: '',
3332 host: '',
3333 hostname: '',
3334 port: '',
3335 pathname: 'example.com/',
3336 search: '',
3337 hash: '',
3338 },
3339 {
3340 input: 'ws:example.com/',
3341 base: 'about:blank',
3342 href: 'ws://example.com/',
3343 origin: 'ws://example.com',
3344 protocol: 'ws:',
3345 username: '',
3346 password: '',
3347 host: 'example.com',
3348 hostname: 'example.com',
3349 port: '',
3350 pathname: '/',
3351 search: '',
3352 hash: '',
3353 },
3354 {
3355 input: 'wss:example.com/',
3356 base: 'about:blank',
3357 href: 'wss://example.com/',
3358 origin: 'wss://example.com',
3359 protocol: 'wss:',
3360 username: '',
3361 password: '',
3362 host: 'example.com',
3363 hostname: 'example.com',
3364 port: '',
3365 pathname: '/',
3366 search: '',
3367 hash: '',
3368 },
3369 {
3370 input: 'data:example.com/',
3371 base: 'about:blank',
3372 href: 'data:example.com/',
3373 origin: 'null',
3374 protocol: 'data:',
3375 username: '',
3376 password: '',
3377 host: '',
3378 hostname: '',
3379 port: '',
3380 pathname: 'example.com/',
3381 search: '',
3382 hash: '',
3383 },
3384 {
3385 input: 'javascript:example.com/',
3386 base: 'about:blank',
3387 href: 'javascript:example.com/',
3388 origin: 'null',
3389 protocol: 'javascript:',
3390 username: '',
3391 password: '',
3392 host: '',
3393 hostname: '',
3394 port: '',
3395 pathname: 'example.com/',
3396 search: '',
3397 hash: '',
3398 },
3399 {
3400 input: 'mailto:example.com/',
3401 base: 'about:blank',
3402 href: 'mailto:example.com/',
3403 origin: 'null',
3404 protocol: 'mailto:',
3405 username: '',
3406 password: '',
3407 host: '',
3408 hostname: '',
3409 port: '',
3410 pathname: 'example.com/',
3411 search: '',
3412 hash: '',
3413 },
3414 '# Based on http://trac.webkit.org/browser/trunk/LayoutTests/fast/url/segments-userinfo-vs-host.html',
3415 {
3416 input: 'http:@www.example.com',
3417 base: 'about:blank',
3418 href: 'http://www.example.com/',
3419 origin: 'http://www.example.com',
3420 protocol: 'http:',
3421 username: '',
3422 password: '',
3423 host: 'www.example.com',
3424 hostname: 'www.example.com',
3425 port: '',
3426 pathname: '/',
3427 search: '',
3428 hash: '',
3429 },
3430 {
3431 input: 'http:/@www.example.com',
3432 base: 'about:blank',
3433 href: 'http://www.example.com/',
3434 origin: 'http://www.example.com',
3435 protocol: 'http:',
3436 username: '',
3437 password: '',
3438 host: 'www.example.com',
3439 hostname: 'www.example.com',
3440 port: '',
3441 pathname: '/',
3442 search: '',
3443 hash: '',
3444 },
3445 {
3446 input: 'http://@www.example.com',
3447 base: 'about:blank',
3448 href: 'http://www.example.com/',
3449 origin: 'http://www.example.com',
3450 protocol: 'http:',
3451 username: '',
3452 password: '',
3453 host: 'www.example.com',
3454 hostname: 'www.example.com',
3455 port: '',
3456 pathname: '/',
3457 search: '',
3458 hash: '',
3459 },
3460 {
3461 input: 'http:a:b@www.example.com',
3462 base: 'about:blank',
3463 href: 'http://a:b@www.example.com/',
3464 origin: 'http://www.example.com',
3465 protocol: 'http:',
3466 username: 'a',
3467 password: 'b',
3468 host: 'www.example.com',
3469 hostname: 'www.example.com',
3470 port: '',
3471 pathname: '/',
3472 search: '',
3473 hash: '',
3474 },
3475 {
3476 input: 'http:/a:b@www.example.com',
3477 base: 'about:blank',
3478 href: 'http://a:b@www.example.com/',
3479 origin: 'http://www.example.com',
3480 protocol: 'http:',
3481 username: 'a',
3482 password: 'b',
3483 host: 'www.example.com',
3484 hostname: 'www.example.com',
3485 port: '',
3486 pathname: '/',
3487 search: '',
3488 hash: '',
3489 },
3490 {
3491 input: 'http://a:b@www.example.com',
3492 base: 'about:blank',
3493 href: 'http://a:b@www.example.com/',
3494 origin: 'http://www.example.com',
3495 protocol: 'http:',
3496 username: 'a',
3497 password: 'b',
3498 host: 'www.example.com',
3499 hostname: 'www.example.com',
3500 port: '',
3501 pathname: '/',
3502 search: '',
3503 hash: '',
3504 },
3505 {
3506 input: 'http://@pple.com',
3507 base: 'about:blank',
3508 href: 'http://pple.com/',
3509 origin: 'http://pple.com',
3510 protocol: 'http:',
3511 username: '',
3512 password: '',
3513 host: 'pple.com',
3514 hostname: 'pple.com',
3515 port: '',
3516 pathname: '/',
3517 search: '',
3518 hash: '',
3519 },
3520 {
3521 input: 'http::b@www.example.com',
3522 base: 'about:blank',
3523 href: 'http://:b@www.example.com/',
3524 origin: 'http://www.example.com',
3525 protocol: 'http:',
3526 username: '',
3527 password: 'b',
3528 host: 'www.example.com',
3529 hostname: 'www.example.com',
3530 port: '',
3531 pathname: '/',
3532 search: '',
3533 hash: '',
3534 },
3535 {
3536 input: 'http:/:b@www.example.com',
3537 base: 'about:blank',
3538 href: 'http://:b@www.example.com/',
3539 origin: 'http://www.example.com',
3540 protocol: 'http:',
3541 username: '',
3542 password: 'b',
3543 host: 'www.example.com',
3544 hostname: 'www.example.com',
3545 port: '',
3546 pathname: '/',
3547 search: '',
3548 hash: '',
3549 },
3550 {
3551 input: 'http://:b@www.example.com',
3552 base: 'about:blank',
3553 href: 'http://:b@www.example.com/',
3554 origin: 'http://www.example.com',
3555 protocol: 'http:',
3556 username: '',
3557 password: 'b',
3558 host: 'www.example.com',
3559 hostname: 'www.example.com',
3560 port: '',
3561 pathname: '/',
3562 search: '',
3563 hash: '',
3564 },
3565 {
3566 input: 'http:/:@/www.example.com',
3567 base: 'about:blank',
3568 failure: true,
3569 },
3570 {
3571 input: 'http://user@/www.example.com',
3572 base: 'about:blank',
3573 failure: true,
3574 },
3575 {
3576 input: 'http:@/www.example.com',
3577 base: 'about:blank',
3578 failure: true,
3579 },
3580 {
3581 input: 'http:/@/www.example.com',
3582 base: 'about:blank',
3583 failure: true,
3584 },
3585 {
3586 input: 'http://@/www.example.com',
3587 base: 'about:blank',
3588 failure: true,
3589 },
3590 {
3591 input: 'https:@/www.example.com',
3592 base: 'about:blank',
3593 failure: true,
3594 },
3595 {
3596 input: 'http:a:b@/www.example.com',
3597 base: 'about:blank',
3598 failure: true,
3599 },
3600 {
3601 input: 'http:/a:b@/www.example.com',
3602 base: 'about:blank',
3603 failure: true,
3604 },
3605 {
3606 input: 'http://a:b@/www.example.com',
3607 base: 'about:blank',
3608 failure: true,
3609 },
3610 {
3611 input: 'http::@/www.example.com',
3612 base: 'about:blank',
3613 failure: true,
3614 },
3615 {
3616 input: 'http:a:@www.example.com',
3617 base: 'about:blank',
3618 href: 'http://a@www.example.com/',
3619 origin: 'http://www.example.com',
3620 protocol: 'http:',
3621 username: 'a',
3622 password: '',
3623 host: 'www.example.com',
3624 hostname: 'www.example.com',
3625 port: '',
3626 pathname: '/',
3627 search: '',
3628 hash: '',
3629 },
3630 {
3631 input: 'http:/a:@www.example.com',
3632 base: 'about:blank',
3633 href: 'http://a@www.example.com/',
3634 origin: 'http://www.example.com',
3635 protocol: 'http:',
3636 username: 'a',
3637 password: '',
3638 host: 'www.example.com',
3639 hostname: 'www.example.com',
3640 port: '',
3641 pathname: '/',
3642 search: '',
3643 hash: '',
3644 },
3645 {
3646 input: 'http://a:@www.example.com',
3647 base: 'about:blank',
3648 href: 'http://a@www.example.com/',
3649 origin: 'http://www.example.com',
3650 protocol: 'http:',
3651 username: 'a',
3652 password: '',
3653 host: 'www.example.com',
3654 hostname: 'www.example.com',
3655 port: '',
3656 pathname: '/',
3657 search: '',
3658 hash: '',
3659 },
3660 {
3661 input: 'http://www.@pple.com',
3662 base: 'about:blank',
3663 href: 'http://www.@pple.com/',
3664 origin: 'http://pple.com',
3665 protocol: 'http:',
3666 username: 'www.',
3667 password: '',
3668 host: 'pple.com',
3669 hostname: 'pple.com',
3670 port: '',
3671 pathname: '/',
3672 search: '',
3673 hash: '',
3674 },
3675 {
3676 input: 'http:@:www.example.com',
3677 base: 'about:blank',
3678 failure: true,
3679 },
3680 {
3681 input: 'http:/@:www.example.com',
3682 base: 'about:blank',
3683 failure: true,
3684 },
3685 {
3686 input: 'http://@:www.example.com',
3687 base: 'about:blank',
3688 failure: true,
3689 },
3690 {
3691 input: 'http://:@www.example.com',
3692 base: 'about:blank',
3693 href: 'http://www.example.com/',
3694 origin: 'http://www.example.com',
3695 protocol: 'http:',
3696 username: '',
3697 password: '',
3698 host: 'www.example.com',
3699 hostname: 'www.example.com',
3700 port: '',
3701 pathname: '/',
3702 search: '',
3703 hash: '',
3704 },
3705 '# Others',
3706 {
3707 input: '/',
3708 base: 'http://www.example.com/test',
3709 href: 'http://www.example.com/',
3710 origin: 'http://www.example.com',
3711 protocol: 'http:',
3712 username: '',
3713 password: '',
3714 host: 'www.example.com',
3715 hostname: 'www.example.com',
3716 port: '',
3717 pathname: '/',
3718 search: '',
3719 hash: '',
3720 },
3721 {
3722 input: '/test.txt',
3723 base: 'http://www.example.com/test',
3724 href: 'http://www.example.com/test.txt',
3725 origin: 'http://www.example.com',
3726 protocol: 'http:',
3727 username: '',
3728 password: '',
3729 host: 'www.example.com',
3730 hostname: 'www.example.com',
3731 port: '',
3732 pathname: '/test.txt',
3733 search: '',
3734 hash: '',
3735 },
3736 {
3737 input: '.',
3738 base: 'http://www.example.com/test',
3739 href: 'http://www.example.com/',
3740 origin: 'http://www.example.com',
3741 protocol: 'http:',
3742 username: '',
3743 password: '',
3744 host: 'www.example.com',
3745 hostname: 'www.example.com',
3746 port: '',
3747 pathname: '/',
3748 search: '',
3749 hash: '',
3750 },
3751 {
3752 input: '..',
3753 base: 'http://www.example.com/test',
3754 href: 'http://www.example.com/',
3755 origin: 'http://www.example.com',
3756 protocol: 'http:',
3757 username: '',
3758 password: '',
3759 host: 'www.example.com',
3760 hostname: 'www.example.com',
3761 port: '',
3762 pathname: '/',
3763 search: '',
3764 hash: '',
3765 },
3766 {
3767 input: 'test.txt',
3768 base: 'http://www.example.com/test',
3769 href: 'http://www.example.com/test.txt',
3770 origin: 'http://www.example.com',
3771 protocol: 'http:',
3772 username: '',
3773 password: '',
3774 host: 'www.example.com',
3775 hostname: 'www.example.com',
3776 port: '',
3777 pathname: '/test.txt',
3778 search: '',
3779 hash: '',
3780 },
3781 {
3782 input: './test.txt',
3783 base: 'http://www.example.com/test',
3784 href: 'http://www.example.com/test.txt',
3785 origin: 'http://www.example.com',
3786 protocol: 'http:',
3787 username: '',
3788 password: '',
3789 host: 'www.example.com',
3790 hostname: 'www.example.com',
3791 port: '',
3792 pathname: '/test.txt',
3793 search: '',
3794 hash: '',
3795 },
3796 {
3797 input: '../test.txt',
3798 base: 'http://www.example.com/test',
3799 href: 'http://www.example.com/test.txt',
3800 origin: 'http://www.example.com',
3801 protocol: 'http:',
3802 username: '',
3803 password: '',
3804 host: 'www.example.com',
3805 hostname: 'www.example.com',
3806 port: '',
3807 pathname: '/test.txt',
3808 search: '',
3809 hash: '',
3810 },
3811 {
3812 input: '../aaa/test.txt',
3813 base: 'http://www.example.com/test',
3814 href: 'http://www.example.com/aaa/test.txt',
3815 origin: 'http://www.example.com',
3816 protocol: 'http:',
3817 username: '',
3818 password: '',
3819 host: 'www.example.com',
3820 hostname: 'www.example.com',
3821 port: '',
3822 pathname: '/aaa/test.txt',
3823 search: '',
3824 hash: '',
3825 },
3826 {
3827 input: '../../test.txt',
3828 base: 'http://www.example.com/test',
3829 href: 'http://www.example.com/test.txt',
3830 origin: 'http://www.example.com',
3831 protocol: 'http:',
3832 username: '',
3833 password: '',
3834 host: 'www.example.com',
3835 hostname: 'www.example.com',
3836 port: '',
3837 pathname: '/test.txt',
3838 search: '',
3839 hash: '',
3840 },
3841 {
3842 input: '中/test.txt',
3843 base: 'http://www.example.com/test',
3844 href: 'http://www.example.com/%E4%B8%AD/test.txt',
3845 origin: 'http://www.example.com',
3846 protocol: 'http:',
3847 username: '',
3848 password: '',
3849 host: 'www.example.com',
3850 hostname: 'www.example.com',
3851 port: '',
3852 pathname: '/%E4%B8%AD/test.txt',
3853 search: '',
3854 hash: '',
3855 },
3856 {
3857 input: 'http://www.example2.com',
3858 base: 'http://www.example.com/test',
3859 href: 'http://www.example2.com/',
3860 origin: 'http://www.example2.com',
3861 protocol: 'http:',
3862 username: '',
3863 password: '',
3864 host: 'www.example2.com',
3865 hostname: 'www.example2.com',
3866 port: '',
3867 pathname: '/',
3868 search: '',
3869 hash: '',
3870 },
3871 {
3872 input: '//www.example2.com',
3873 base: 'http://www.example.com/test',
3874 href: 'http://www.example2.com/',
3875 origin: 'http://www.example2.com',
3876 protocol: 'http:',
3877 username: '',
3878 password: '',
3879 host: 'www.example2.com',
3880 hostname: 'www.example2.com',
3881 port: '',
3882 pathname: '/',
3883 search: '',
3884 hash: '',
3885 },
3886 {
3887 input: 'file:...',
3888 base: 'http://www.example.com/test',
3889 href: 'file:///...',
3890 protocol: 'file:',
3891 username: '',
3892 password: '',
3893 host: '',
3894 hostname: '',
3895 port: '',
3896 pathname: '/...',
3897 search: '',
3898 hash: '',
3899 },
3900 {
3901 input: 'file:..',
3902 base: 'http://www.example.com/test',
3903 href: 'file:///',
3904 protocol: 'file:',
3905 username: '',
3906 password: '',
3907 host: '',
3908 hostname: '',
3909 port: '',
3910 pathname: '/',
3911 search: '',
3912 hash: '',
3913 },
3914 {
3915 input: 'file:a',
3916 base: 'http://www.example.com/test',
3917 href: 'file:///a',
3918 protocol: 'file:',
3919 username: '',
3920 password: '',
3921 host: '',
3922 hostname: '',
3923 port: '',
3924 pathname: '/a',
3925 search: '',
3926 hash: '',
3927 },
3928 '# Based on http://trac.webkit.org/browser/trunk/LayoutTests/fast/url/host.html',
3929 'Basic canonicalization, uppercase should be converted to lowercase',
3930 {
3931 input: 'http://ExAmPlE.CoM',
3932 base: 'http://other.com/',
3933 href: 'http://example.com/',
3934 origin: 'http://example.com',
3935 protocol: 'http:',
3936 username: '',
3937 password: '',
3938 host: 'example.com',
3939 hostname: 'example.com',
3940 port: '',
3941 pathname: '/',
3942 search: '',
3943 hash: '',
3944 },
3945 {
3946 input: 'http://example example.com',
3947 base: 'http://other.com/',
3948 failure: true,
3949 },
3950 {
3951 input: 'http://Goo%20 goo%7C|.com',
3952 base: 'http://other.com/',
3953 failure: true,
3954 },
3955 {
3956 input: 'http://[]',
3957 base: 'http://other.com/',
3958 failure: true,
3959 },
3960 {
3961 input: 'http://[:]',
3962 base: 'http://other.com/',
3963 failure: true,
3964 },
3965 'U+3000 is mapped to U+0020 (space) which is disallowed',
3966 {
3967 input: 'http://GOO\u00a0\u3000goo.com',
3968 base: 'http://other.com/',
3969 failure: true,
3970 },
3971 'Other types of space (no-break, zero-width, zero-width-no-break) are name-prepped away to nothing. U+200B, U+2060, and U+FEFF, are ignored',
3972 {
3973 input: 'http://GOO\u200b\u2060\ufeffgoo.com',
3974 base: 'http://other.com/',
3975 href: 'http://googoo.com/',
3976 origin: 'http://googoo.com',
3977 protocol: 'http:',
3978 username: '',
3979 password: '',
3980 host: 'googoo.com',
3981 hostname: 'googoo.com',
3982 port: '',
3983 pathname: '/',
3984 search: '',
3985 hash: '',
3986 },
3987 'Leading and trailing C0 control or space',
3988 {
3989 input: '\u0000\u001b\u0004\u0012 http://example.com/\u001f \u000d ',
3990 base: 'about:blank',
3991 href: 'http://example.com/',
3992 origin: 'http://example.com',
3993 protocol: 'http:',
3994 username: '',
3995 password: '',
3996 host: 'example.com',
3997 hostname: 'example.com',
3998 port: '',
3999 pathname: '/',
4000 search: '',
4001 hash: '',
4002 },
4003 'Ideographic full stop (full-width period for Chinese, etc.) should be treated as a dot. U+3002 is mapped to U+002E (dot)',
4004 {
4005 input: 'http://www.foo。bar.com',
4006 base: 'http://other.com/',
4007 href: 'http://www.foo.bar.com/',
4008 origin: 'http://www.foo.bar.com',
4009 protocol: 'http:',
4010 username: '',
4011 password: '',
4012 host: 'www.foo.bar.com',
4013 hostname: 'www.foo.bar.com',
4014 port: '',
4015 pathname: '/',
4016 search: '',
4017 hash: '',
4018 },
4019 'Invalid Unicode characters should fail... U+FDD0 is disallowed; %ef%b7%90 is U+FDD0',
4020 {
4021 input: 'http://\ufdd0zyx.com',
4022 base: 'http://other.com/',
4023 failure: true,
4024 },
4025 'This is the same as previous but escaped',
4026 {
4027 input: 'http://%ef%b7%90zyx.com',
4028 base: 'http://other.com/',
4029 failure: true,
4030 },
4031 'U+FFFD',
4032 {
4033 input: 'https://\ufffd',
4034 base: 'about:blank',
4035 failure: true,
4036 },
4037 {
4038 input: 'https://%EF%BF%BD',
4039 base: 'about:blank',
4040 failure: true,
4041 },
4042 {
4043 input: 'https://x/\ufffd?\ufffd#\ufffd',
4044 base: 'about:blank',
4045 href: 'https://x/%EF%BF%BD?%EF%BF%BD#%EF%BF%BD',
4046 origin: 'https://x',
4047 protocol: 'https:',
4048 username: '',
4049 password: '',
4050 host: 'x',
4051 hostname: 'x',
4052 port: '',
4053 pathname: '/%EF%BF%BD',
4054 search: '?%EF%BF%BD',
4055 hash: '#%EF%BF%BD',
4056 },
4057 "Test name prepping, fullwidth input should be converted to ASCII and NOT IDN-ized. This is 'Go' in fullwidth UTF-8/UTF-16.",
4058 {
4059 input: 'http://Go.com',
4060 base: 'http://other.com/',
4061 href: 'http://go.com/',
4062 origin: 'http://go.com',
4063 protocol: 'http:',
4064 username: '',
4065 password: '',
4066 host: 'go.com',
4067 hostname: 'go.com',
4068 port: '',
4069 pathname: '/',
4070 search: '',
4071 hash: '',
4072 },
4073 'URL spec forbids the following. https://www.w3.org/Bugs/Public/show_bug.cgi?id=24257',
4074 {
4075 input: 'http://%41.com',
4076 base: 'http://other.com/',
4077 failure: true,
4078 },
4079 {
4080 input: 'http://%ef%bc%85%ef%bc%94%ef%bc%91.com',
4081 base: 'http://other.com/',
4082 failure: true,
4083 },
4084 '...%00 in fullwidth should fail (also as escaped UTF-8 input)',
4085 {
4086 input: 'http://%00.com',
4087 base: 'http://other.com/',
4088 failure: true,
4089 },
4090 {
4091 input: 'http://%ef%bc%85%ef%bc%90%ef%bc%90.com',
4092 base: 'http://other.com/',
4093 failure: true,
4094 },
4095 'Basic IDN support, UTF-8 and UTF-16 input should be converted to IDN',
4096 {
4097 input: 'http://你好你好',
4098 base: 'http://other.com/',
4099 href: 'http://xn--6qqa088eba/',
4100 origin: 'http://xn--6qqa088eba',
4101 protocol: 'http:',
4102 username: '',
4103 password: '',
4104 host: 'xn--6qqa088eba',
4105 hostname: 'xn--6qqa088eba',
4106 port: '',
4107 pathname: '/',
4108 search: '',
4109 hash: '',
4110 },
4111 {
4112 input: 'https://faß.ExAmPlE/',
4113 base: 'about:blank',
4114 href: 'https://xn--fa-hia.example/',
4115 origin: 'https://xn--fa-hia.example',
4116 protocol: 'https:',
4117 username: '',
4118 password: '',
4119 host: 'xn--fa-hia.example',
4120 hostname: 'xn--fa-hia.example',
4121 port: '',
4122 pathname: '/',
4123 search: '',
4124 hash: '',
4125 },
4126 {
4127 input: 'sc://faß.ExAmPlE/',
4128 base: 'about:blank',
4129 href: 'sc://fa%C3%9F.ExAmPlE/',
4130 origin: 'null',
4131 protocol: 'sc:',
4132 username: '',
4133 password: '',
4134 host: 'fa%C3%9F.ExAmPlE',
4135 hostname: 'fa%C3%9F.ExAmPlE',
4136 port: '',
4137 pathname: '/',
4138 search: '',
4139 hash: '',
4140 },
4141 'Invalid escaped characters should fail and the percents should be escaped. https://www.w3.org/Bugs/Public/show_bug.cgi?id=24191',
4142 {
4143 input: 'http://%zz%66%a.com',
4144 base: 'http://other.com/',
4145 failure: true,
4146 },
4147 'If we get an invalid character that has been escaped.',
4148 {
4149 input: 'http://%25',
4150 base: 'http://other.com/',
4151 failure: true,
4152 },
4153 {
4154 input: 'http://hello%00',
4155 base: 'http://other.com/',
4156 failure: true,
4157 },
4158 'Escaped numbers should be treated like IP addresses if they are.',
4159 {
4160 input: 'http://%30%78%63%30%2e%30%32%35%30.01',
4161 base: 'http://other.com/',
4162 href: 'http://192.168.0.1/',
4163 origin: 'http://192.168.0.1',
4164 protocol: 'http:',
4165 username: '',
4166 password: '',
4167 host: '192.168.0.1',
4168 hostname: '192.168.0.1',
4169 port: '',
4170 pathname: '/',
4171 search: '',
4172 hash: '',
4173 },
4174 {
4175 input: 'http://%30%78%63%30%2e%30%32%35%30.01%2e',
4176 base: 'http://other.com/',
4177 href: 'http://192.168.0.1/',
4178 origin: 'http://192.168.0.1',
4179 protocol: 'http:',
4180 username: '',
4181 password: '',
4182 host: '192.168.0.1',
4183 hostname: '192.168.0.1',
4184 port: '',
4185 pathname: '/',
4186 search: '',
4187 hash: '',
4188 },
4189 {
4190 input: 'http://192.168.0.257',
4191 base: 'http://other.com/',
4192 failure: true,
4193 },
4194 'Invalid escaping in hosts causes failure',
4195 {
4196 input: 'http://%3g%78%63%30%2e%30%32%35%30%2E.01',
4197 base: 'http://other.com/',
4198 failure: true,
4199 },
4200 'A space in a host causes failure',
4201 {
4202 input: 'http://192.168.0.1 hello',
4203 base: 'http://other.com/',
4204 failure: true,
4205 },
4206 {
4207 input: 'https://x x:12',
4208 base: 'about:blank',
4209 failure: true,
4210 },
4211 'Fullwidth and escaped UTF-8 fullwidth should still be treated as IP',
4212 {
4213 input: 'http://0Xc0.0250.01',
4214 base: 'http://other.com/',
4215 href: 'http://192.168.0.1/',
4216 origin: 'http://192.168.0.1',
4217 protocol: 'http:',
4218 username: '',
4219 password: '',
4220 host: '192.168.0.1',
4221 hostname: '192.168.0.1',
4222 port: '',
4223 pathname: '/',
4224 search: '',
4225 hash: '',
4226 },
4227 'Domains with empty labels',
4228 {
4229 input: 'http://./',
4230 base: 'about:blank',
4231 href: 'http://./',
4232 origin: 'http://.',
4233 protocol: 'http:',
4234 username: '',
4235 password: '',
4236 host: '.',
4237 hostname: '.',
4238 port: '',
4239 pathname: '/',
4240 search: '',
4241 hash: '',
4242 },
4243 {
4244 input: 'http://../',
4245 base: 'about:blank',
4246 href: 'http://../',
4247 origin: 'http://..',
4248 protocol: 'http:',
4249 username: '',
4250 password: '',
4251 host: '..',
4252 hostname: '..',
4253 port: '',
4254 pathname: '/',
4255 search: '',
4256 hash: '',
4257 },
4258 'Broken IPv6',
4259 {
4260 input: 'http://[www.google.com]/',
4261 base: 'about:blank',
4262 failure: true,
4263 },
4264 {
4265 input: 'http://[google.com]',
4266 base: 'http://other.com/',
4267 failure: true,
4268 },
4269 {
4270 input: 'http://[::1.2.3.4x]',
4271 base: 'http://other.com/',
4272 failure: true,
4273 },
4274 {
4275 input: 'http://[::1.2.3.]',
4276 base: 'http://other.com/',
4277 failure: true,
4278 },
4279 {
4280 input: 'http://[::1.2.]',
4281 base: 'http://other.com/',
4282 failure: true,
4283 },
4284 {
4285 input: 'http://[::1.]',
4286 base: 'http://other.com/',
4287 failure: true,
4288 },
4289 'Misc Unicode',
4290 {
4291 input: 'http://foo:💩@example.com/bar',
4292 base: 'http://other.com/',
4293 href: 'http://foo:%F0%9F%92%A9@example.com/bar',
4294 origin: 'http://example.com',
4295 protocol: 'http:',
4296 username: 'foo',
4297 password: '%F0%9F%92%A9',
4298 host: 'example.com',
4299 hostname: 'example.com',
4300 port: '',
4301 pathname: '/bar',
4302 search: '',
4303 hash: '',
4304 },
4305 '# resolving a fragment against any scheme succeeds',
4306 {
4307 input: '#',
4308 base: 'test:test',
4309 href: 'test:test#',
4310 origin: 'null',
4311 protocol: 'test:',
4312 username: '',
4313 password: '',
4314 host: '',
4315 hostname: '',
4316 port: '',
4317 pathname: 'test',
4318 search: '',
4319 hash: '',
4320 },
4321 {
4322 input: '#x',
4323 base: 'mailto:x@x.com',
4324 href: 'mailto:x@x.com#x',
4325 origin: 'null',
4326 protocol: 'mailto:',
4327 username: '',
4328 password: '',
4329 host: '',
4330 hostname: '',
4331 port: '',
4332 pathname: 'x@x.com',
4333 search: '',
4334 hash: '#x',
4335 },
4336 {
4337 input: '#x',
4338 base: 'data:,',
4339 href: 'data:,#x',
4340 origin: 'null',
4341 protocol: 'data:',
4342 username: '',
4343 password: '',
4344 host: '',
4345 hostname: '',
4346 port: '',
4347 pathname: ',',
4348 search: '',
4349 hash: '#x',
4350 },
4351 {
4352 input: '#x',
4353 base: 'about:blank',
4354 href: 'about:blank#x',
4355 origin: 'null',
4356 protocol: 'about:',
4357 username: '',
4358 password: '',
4359 host: '',
4360 hostname: '',
4361 port: '',
4362 pathname: 'blank',
4363 search: '',
4364 hash: '#x',
4365 },
4366 {
4367 input: '#',
4368 base: 'test:test?test',
4369 href: 'test:test?test#',
4370 origin: 'null',
4371 protocol: 'test:',
4372 username: '',
4373 password: '',
4374 host: '',
4375 hostname: '',
4376 port: '',
4377 pathname: 'test',
4378 search: '?test',
4379 hash: '',
4380 },
4381 '# multiple @ in authority state',
4382 {
4383 input: 'https://@test@test@example:800/',
4384 base: 'http://doesnotmatter/',
4385 href: 'https://%40test%40test@example:800/',
4386 origin: 'https://example:800',
4387 protocol: 'https:',
4388 username: '%40test%40test',
4389 password: '',
4390 host: 'example:800',
4391 hostname: 'example',
4392 port: '800',
4393 pathname: '/',
4394 search: '',
4395 hash: '',
4396 },
4397 {
4398 input: 'https://@@@example',
4399 base: 'http://doesnotmatter/',
4400 href: 'https://%40%40@example/',
4401 origin: 'https://example',
4402 protocol: 'https:',
4403 username: '%40%40',
4404 password: '',
4405 host: 'example',
4406 hostname: 'example',
4407 port: '',
4408 pathname: '/',
4409 search: '',
4410 hash: '',
4411 },
4412 'non-az-09 characters',
4413 {
4414 input: 'http://`{}:`{}@h/`{}?`{}',
4415 base: 'http://doesnotmatter/',
4416 href: 'http://%60%7B%7D:%60%7B%7D@h/%60%7B%7D?`{}',
4417 origin: 'http://h',
4418 protocol: 'http:',
4419 username: '%60%7B%7D',
4420 password: '%60%7B%7D',
4421 host: 'h',
4422 hostname: 'h',
4423 port: '',
4424 pathname: '/%60%7B%7D',
4425 search: '?`{}',
4426 hash: '',
4427 },
4428 '# Credentials in base',
4429 {
4430 input: '/some/path',
4431 base: 'http://user@example.org/smth',
4432 href: 'http://user@example.org/some/path',
4433 origin: 'http://example.org',
4434 protocol: 'http:',
4435 username: 'user',
4436 password: '',
4437 host: 'example.org',
4438 hostname: 'example.org',
4439 port: '',
4440 pathname: '/some/path',
4441 search: '',
4442 hash: '',
4443 },
4444 {
4445 input: '',
4446 base: 'http://user:pass@example.org:21/smth',
4447 href: 'http://user:pass@example.org:21/smth',
4448 origin: 'http://example.org:21',
4449 protocol: 'http:',
4450 username: 'user',
4451 password: 'pass',
4452 host: 'example.org:21',
4453 hostname: 'example.org',
4454 port: '21',
4455 pathname: '/smth',
4456 search: '',
4457 hash: '',
4458 },
4459 {
4460 input: '/some/path',
4461 base: 'http://user:pass@example.org:21/smth',
4462 href: 'http://user:pass@example.org:21/some/path',
4463 origin: 'http://example.org:21',
4464 protocol: 'http:',
4465 username: 'user',
4466 password: 'pass',
4467 host: 'example.org:21',
4468 hostname: 'example.org',
4469 port: '21',
4470 pathname: '/some/path',
4471 search: '',
4472 hash: '',
4473 },
4474 '# a set of tests designed by zcorpan for relative URLs with unknown schemes',
4475 {
4476 input: 'i',
4477 base: 'sc:sd',
4478 failure: true,
4479 },
4480 {
4481 input: 'i',
4482 base: 'sc:sd/sd',
4483 failure: true,
4484 },
4485 {
4486 input: 'i',
4487 base: 'sc:/pa/pa',
4488 href: 'sc:/pa/i',
4489 origin: 'null',
4490 protocol: 'sc:',
4491 username: '',
4492 password: '',
4493 host: '',
4494 hostname: '',
4495 port: '',
4496 pathname: '/pa/i',
4497 search: '',
4498 hash: '',
4499 },
4500 {
4501 input: 'i',
4502 base: 'sc://ho/pa',
4503 href: 'sc://ho/i',
4504 origin: 'null',
4505 protocol: 'sc:',
4506 username: '',
4507 password: '',
4508 host: 'ho',
4509 hostname: 'ho',
4510 port: '',
4511 pathname: '/i',
4512 search: '',
4513 hash: '',
4514 },
4515 {
4516 input: 'i',
4517 base: 'sc:///pa/pa',
4518 href: 'sc:///pa/i',
4519 origin: 'null',
4520 protocol: 'sc:',
4521 username: '',
4522 password: '',
4523 host: '',
4524 hostname: '',
4525 port: '',
4526 pathname: '/pa/i',
4527 search: '',
4528 hash: '',
4529 },
4530 {
4531 input: '../i',
4532 base: 'sc:sd',
4533 failure: true,
4534 },
4535 {
4536 input: '../i',
4537 base: 'sc:sd/sd',
4538 failure: true,
4539 },
4540 {
4541 input: '../i',
4542 base: 'sc:/pa/pa',
4543 href: 'sc:/i',
4544 origin: 'null',
4545 protocol: 'sc:',
4546 username: '',
4547 password: '',
4548 host: '',
4549 hostname: '',
4550 port: '',
4551 pathname: '/i',
4552 search: '',
4553 hash: '',
4554 },
4555 {
4556 input: '../i',
4557 base: 'sc://ho/pa',
4558 href: 'sc://ho/i',
4559 origin: 'null',
4560 protocol: 'sc:',
4561 username: '',
4562 password: '',
4563 host: 'ho',
4564 hostname: 'ho',
4565 port: '',
4566 pathname: '/i',
4567 search: '',
4568 hash: '',
4569 },
4570 {
4571 input: '../i',
4572 base: 'sc:///pa/pa',
4573 href: 'sc:///i',
4574 origin: 'null',
4575 protocol: 'sc:',
4576 username: '',
4577 password: '',
4578 host: '',
4579 hostname: '',
4580 port: '',
4581 pathname: '/i',
4582 search: '',
4583 hash: '',
4584 },
4585 {
4586 input: '/i',
4587 base: 'sc:sd',
4588 failure: true,
4589 },
4590 {
4591 input: '/i',
4592 base: 'sc:sd/sd',
4593 failure: true,
4594 },
4595 {
4596 input: '/i',
4597 base: 'sc:/pa/pa',
4598 href: 'sc:/i',
4599 origin: 'null',
4600 protocol: 'sc:',
4601 username: '',
4602 password: '',
4603 host: '',
4604 hostname: '',
4605 port: '',
4606 pathname: '/i',
4607 search: '',
4608 hash: '',
4609 },
4610 {
4611 input: '/i',
4612 base: 'sc://ho/pa',
4613 href: 'sc://ho/i',
4614 origin: 'null',
4615 protocol: 'sc:',
4616 username: '',
4617 password: '',
4618 host: 'ho',
4619 hostname: 'ho',
4620 port: '',
4621 pathname: '/i',
4622 search: '',
4623 hash: '',
4624 },
4625 {
4626 input: '/i',
4627 base: 'sc:///pa/pa',
4628 href: 'sc:///i',
4629 origin: 'null',
4630 protocol: 'sc:',
4631 username: '',
4632 password: '',
4633 host: '',
4634 hostname: '',
4635 port: '',
4636 pathname: '/i',
4637 search: '',
4638 hash: '',
4639 },
4640 {
4641 input: '?i',
4642 base: 'sc:sd',
4643 failure: true,
4644 },
4645 {
4646 input: '?i',
4647 base: 'sc:sd/sd',
4648 failure: true,
4649 },
4650 {
4651 input: '?i',
4652 base: 'sc:/pa/pa',
4653 href: 'sc:/pa/pa?i',
4654 origin: 'null',
4655 protocol: 'sc:',
4656 username: '',
4657 password: '',
4658 host: '',
4659 hostname: '',
4660 port: '',
4661 pathname: '/pa/pa',
4662 search: '?i',
4663 hash: '',
4664 },
4665 {
4666 input: '?i',
4667 base: 'sc://ho/pa',
4668 href: 'sc://ho/pa?i',
4669 origin: 'null',
4670 protocol: 'sc:',
4671 username: '',
4672 password: '',
4673 host: 'ho',
4674 hostname: 'ho',
4675 port: '',
4676 pathname: '/pa',
4677 search: '?i',
4678 hash: '',
4679 },
4680 {
4681 input: '?i',
4682 base: 'sc:///pa/pa',
4683 href: 'sc:///pa/pa?i',
4684 origin: 'null',
4685 protocol: 'sc:',
4686 username: '',
4687 password: '',
4688 host: '',
4689 hostname: '',
4690 port: '',
4691 pathname: '/pa/pa',
4692 search: '?i',
4693 hash: '',
4694 },
4695 {
4696 input: '#i',
4697 base: 'sc:sd',
4698 href: 'sc:sd#i',
4699 origin: 'null',
4700 protocol: 'sc:',
4701 username: '',
4702 password: '',
4703 host: '',
4704 hostname: '',
4705 port: '',
4706 pathname: 'sd',
4707 search: '',
4708 hash: '#i',
4709 },
4710 {
4711 input: '#i',
4712 base: 'sc:sd/sd',
4713 href: 'sc:sd/sd#i',
4714 origin: 'null',
4715 protocol: 'sc:',
4716 username: '',
4717 password: '',
4718 host: '',
4719 hostname: '',
4720 port: '',
4721 pathname: 'sd/sd',
4722 search: '',
4723 hash: '#i',
4724 },
4725 {
4726 input: '#i',
4727 base: 'sc:/pa/pa',
4728 href: 'sc:/pa/pa#i',
4729 origin: 'null',
4730 protocol: 'sc:',
4731 username: '',
4732 password: '',
4733 host: '',
4734 hostname: '',
4735 port: '',
4736 pathname: '/pa/pa',
4737 search: '',
4738 hash: '#i',
4739 },
4740 {
4741 input: '#i',
4742 base: 'sc://ho/pa',
4743 href: 'sc://ho/pa#i',
4744 origin: 'null',
4745 protocol: 'sc:',
4746 username: '',
4747 password: '',
4748 host: 'ho',
4749 hostname: 'ho',
4750 port: '',
4751 pathname: '/pa',
4752 search: '',
4753 hash: '#i',
4754 },
4755 {
4756 input: '#i',
4757 base: 'sc:///pa/pa',
4758 href: 'sc:///pa/pa#i',
4759 origin: 'null',
4760 protocol: 'sc:',
4761 username: '',
4762 password: '',
4763 host: '',
4764 hostname: '',
4765 port: '',
4766 pathname: '/pa/pa',
4767 search: '',
4768 hash: '#i',
4769 },
4770 '# make sure that relative URL logic works on known typically non-relative schemes too',
4771 {
4772 input: 'about:/../',
4773 base: 'about:blank',
4774 href: 'about:/',
4775 origin: 'null',
4776 protocol: 'about:',
4777 username: '',
4778 password: '',
4779 host: '',
4780 hostname: '',
4781 port: '',
4782 pathname: '/',
4783 search: '',
4784 hash: '',
4785 },
4786 {
4787 input: 'data:/../',
4788 base: 'about:blank',
4789 href: 'data:/',
4790 origin: 'null',
4791 protocol: 'data:',
4792 username: '',
4793 password: '',
4794 host: '',
4795 hostname: '',
4796 port: '',
4797 pathname: '/',
4798 search: '',
4799 hash: '',
4800 },
4801 {
4802 input: 'javascript:/../',
4803 base: 'about:blank',
4804 href: 'javascript:/',
4805 origin: 'null',
4806 protocol: 'javascript:',
4807 username: '',
4808 password: '',
4809 host: '',
4810 hostname: '',
4811 port: '',
4812 pathname: '/',
4813 search: '',
4814 hash: '',
4815 },
4816 {
4817 input: 'mailto:/../',
4818 base: 'about:blank',
4819 href: 'mailto:/',
4820 origin: 'null',
4821 protocol: 'mailto:',
4822 username: '',
4823 password: '',
4824 host: '',
4825 hostname: '',
4826 port: '',
4827 pathname: '/',
4828 search: '',
4829 hash: '',
4830 },
4831 '# unknown schemes and their hosts',
4832 {
4833 input: 'sc://ñ.test/',
4834 base: 'about:blank',
4835 href: 'sc://%C3%B1.test/',
4836 origin: 'null',
4837 protocol: 'sc:',
4838 username: '',
4839 password: '',
4840 host: '%C3%B1.test',
4841 hostname: '%C3%B1.test',
4842 port: '',
4843 pathname: '/',
4844 search: '',
4845 hash: '',
4846 },
4847 {
4848 input: 'sc://\u0000/',
4849 base: 'about:blank',
4850 failure: true,
4851 },
4852 {
4853 input: 'sc:// /',
4854 base: 'about:blank',
4855 failure: true,
4856 },
4857 {
4858 input: 'sc://%/',
4859 base: 'about:blank',
4860 href: 'sc://%/',
4861 protocol: 'sc:',
4862 username: '',
4863 password: '',
4864 host: '%',
4865 hostname: '%',
4866 port: '',
4867 pathname: '/',
4868 search: '',
4869 hash: '',
4870 },
4871 {
4872 input: 'sc://@/',
4873 base: 'about:blank',
4874 failure: true,
4875 },
4876 {
4877 input: 'sc://te@s:t@/',
4878 base: 'about:blank',
4879 failure: true,
4880 },
4881 {
4882 input: 'sc://:/',
4883 base: 'about:blank',
4884 failure: true,
4885 },
4886 {
4887 input: 'sc://:12/',
4888 base: 'about:blank',
4889 failure: true,
4890 },
4891 {
4892 input: 'sc://[/',
4893 base: 'about:blank',
4894 failure: true,
4895 },
4896 {
4897 input: 'sc://\\/',
4898 base: 'about:blank',
4899 failure: true,
4900 },
4901 {
4902 input: 'sc://]/',
4903 base: 'about:blank',
4904 failure: true,
4905 },
4906 {
4907 input: 'x',
4908 base: 'sc://ñ',
4909 href: 'sc://%C3%B1/x',
4910 origin: 'null',
4911 protocol: 'sc:',
4912 username: '',
4913 password: '',
4914 host: '%C3%B1',
4915 hostname: '%C3%B1',
4916 port: '',
4917 pathname: '/x',
4918 search: '',
4919 hash: '',
4920 },
4921 '# unknown schemes and backslashes',
4922 {
4923 input: 'sc:\\../',
4924 base: 'about:blank',
4925 href: 'sc:\\../',
4926 origin: 'null',
4927 protocol: 'sc:',
4928 username: '',
4929 password: '',
4930 host: '',
4931 hostname: '',
4932 port: '',
4933 pathname: '\\../',
4934 search: '',
4935 hash: '',
4936 },
4937 '# unknown scheme with path looking like a password',
4938 {
4939 input: 'sc::a@example.net',
4940 base: 'about:blank',
4941 href: 'sc::a@example.net',
4942 origin: 'null',
4943 protocol: 'sc:',
4944 username: '',
4945 password: '',
4946 host: '',
4947 hostname: '',
4948 port: '',
4949 pathname: ':a@example.net',
4950 search: '',
4951 hash: '',
4952 },
4953 '# unknown scheme with bogus percent-encoding',
4954 {
4955 input: 'wow:%NBD',
4956 base: 'about:blank',
4957 href: 'wow:%NBD',
4958 origin: 'null',
4959 protocol: 'wow:',
4960 username: '',
4961 password: '',
4962 host: '',
4963 hostname: '',
4964 port: '',
4965 pathname: '%NBD',
4966 search: '',
4967 hash: '',
4968 },
4969 {
4970 input: 'wow:%1G',
4971 base: 'about:blank',
4972 href: 'wow:%1G',
4973 origin: 'null',
4974 protocol: 'wow:',
4975 username: '',
4976 password: '',
4977 host: '',
4978 hostname: '',
4979 port: '',
4980 pathname: '%1G',
4981 search: '',
4982 hash: '',
4983 },
4984 '# Hosts and percent-encoding',
4985 {
4986 input: 'ftp://example.com%80/',
4987 base: 'about:blank',
4988 failure: true,
4989 },
4990 {
4991 input: 'ftp://example.com%A0/',
4992 base: 'about:blank',
4993 failure: true,
4994 },
4995 {
4996 input: 'https://example.com%80/',
4997 base: 'about:blank',
4998 failure: true,
4999 },
5000 {
5001 input: 'https://example.com%A0/',
5002 base: 'about:blank',
5003 failure: true,
5004 },
5005 {
5006 input: 'ftp://%e2%98%83',
5007 base: 'about:blank',
5008 href: 'ftp://xn--n3h/',
5009 origin: 'ftp://xn--n3h',
5010 protocol: 'ftp:',
5011 username: '',
5012 password: '',
5013 host: 'xn--n3h',
5014 hostname: 'xn--n3h',
5015 port: '',
5016 pathname: '/',
5017 search: '',
5018 hash: '',
5019 },
5020 {
5021 input: 'https://%e2%98%83',
5022 base: 'about:blank',
5023 href: 'https://xn--n3h/',
5024 origin: 'https://xn--n3h',
5025 protocol: 'https:',
5026 username: '',
5027 password: '',
5028 host: 'xn--n3h',
5029 hostname: 'xn--n3h',
5030 port: '',
5031 pathname: '/',
5032 search: '',
5033 hash: '',
5034 },
5035 '# tests from jsdom/whatwg-url designed for code coverage',
5036 {
5037 input: 'http://127.0.0.1:10100/relative_import.html',
5038 base: 'about:blank',
5039 href: 'http://127.0.0.1:10100/relative_import.html',
5040 origin: 'http://127.0.0.1:10100',
5041 protocol: 'http:',
5042 username: '',
5043 password: '',
5044 host: '127.0.0.1:10100',
5045 hostname: '127.0.0.1',
5046 port: '10100',
5047 pathname: '/relative_import.html',
5048 search: '',
5049 hash: '',
5050 },
5051 {
5052 input: 'http://facebook.com/?foo=%7B%22abc%22',
5053 base: 'about:blank',
5054 href: 'http://facebook.com/?foo=%7B%22abc%22',
5055 origin: 'http://facebook.com',
5056 protocol: 'http:',
5057 username: '',
5058 password: '',
5059 host: 'facebook.com',
5060 hostname: 'facebook.com',
5061 port: '',
5062 pathname: '/',
5063 search: '?foo=%7B%22abc%22',
5064 hash: '',
5065 },
5066 {
5067 input: 'https://localhost:3000/jqueryui@1.2.3',
5068 base: 'about:blank',
5069 href: 'https://localhost:3000/jqueryui@1.2.3',
5070 origin: 'https://localhost:3000',
5071 protocol: 'https:',
5072 username: '',
5073 password: '',
5074 host: 'localhost:3000',
5075 hostname: 'localhost',
5076 port: '3000',
5077 pathname: '/jqueryui@1.2.3',
5078 search: '',
5079 hash: '',
5080 },
5081 '# tab/LF/CR',
5082 {
5083 input:
5084 'h\tt\nt\rp://h\to\ns\rt:9\t0\n0\r0/p\ta\nt\rh?q\tu\ne\rry#f\tr\na\rg',
5085 base: 'about:blank',
5086 href: 'http://host:9000/path?query#frag',
5087 origin: 'http://host:9000',
5088 protocol: 'http:',
5089 username: '',
5090 password: '',
5091 host: 'host:9000',
5092 hostname: 'host',
5093 port: '9000',
5094 pathname: '/path',
5095 search: '?query',
5096 hash: '#frag',
5097 },
5098 '# Stringification of URL.searchParams',
5099 {
5100 input: '?a=b&c=d',
5101 base: 'http://example.org/foo/bar',
5102 href: 'http://example.org/foo/bar?a=b&c=d',
5103 origin: 'http://example.org',
5104 protocol: 'http:',
5105 username: '',
5106 password: '',
5107 host: 'example.org',
5108 hostname: 'example.org',
5109 port: '',
5110 pathname: '/foo/bar',
5111 search: '?a=b&c=d',
5112 searchParams: 'a=b&c=d',
5113 hash: '',
5114 },
5115 {
5116 input: '??a=b&c=d',
5117 base: 'http://example.org/foo/bar',
5118 href: 'http://example.org/foo/bar??a=b&c=d',
5119 origin: 'http://example.org',
5120 protocol: 'http:',
5121 username: '',
5122 password: '',
5123 host: 'example.org',
5124 hostname: 'example.org',
5125 port: '',
5126 pathname: '/foo/bar',
5127 search: '??a=b&c=d',
5128 searchParams: '%3Fa=b&c=d',
5129 hash: '',
5130 },
5131 '# Scheme only',
5132 {
5133 input: 'http:',
5134 base: 'http://example.org/foo/bar',
5135 href: 'http://example.org/foo/bar',
5136 origin: 'http://example.org',
5137 protocol: 'http:',
5138 username: '',
5139 password: '',
5140 host: 'example.org',
5141 hostname: 'example.org',
5142 port: '',
5143 pathname: '/foo/bar',
5144 search: '',
5145 searchParams: '',
5146 hash: '',
5147 },
5148 {
5149 input: 'http:',
5150 base: 'https://example.org/foo/bar',
5151 failure: true,
5152 },
5153 {
5154 input: 'sc:',
5155 base: 'https://example.org/foo/bar',
5156 href: 'sc:',
5157 origin: 'null',
5158 protocol: 'sc:',
5159 username: '',
5160 password: '',
5161 host: '',
5162 hostname: '',
5163 port: '',
5164 pathname: '',
5165 search: '',
5166 searchParams: '',
5167 hash: '',
5168 },
5169 '# Percent encoding of fragments',
5170 {
5171 input: 'http://foo.bar/baz?qux#foo\bbar',
5172 base: 'about:blank',
5173 href: 'http://foo.bar/baz?qux#foo%08bar',
5174 origin: 'http://foo.bar',
5175 protocol: 'http:',
5176 username: '',
5177 password: '',
5178 host: 'foo.bar',
5179 hostname: 'foo.bar',
5180 port: '',
5181 pathname: '/baz',
5182 search: '?qux',
5183 searchParams: 'qux=',
5184 hash: '#foo%08bar',
5185 },
5186 '# IPv4 parsing (via https://github.com/nodejs/node/pull/10317)',
5187 {
5188 input: 'http://192.168.257',
5189 base: 'http://other.com/',
5190 href: 'http://192.168.1.1/',
5191 origin: 'http://192.168.1.1',
5192 protocol: 'http:',
5193 username: '',
5194 password: '',
5195 host: '192.168.1.1',
5196 hostname: '192.168.1.1',
5197 port: '',
5198 pathname: '/',
5199 search: '',
5200 hash: '',
5201 },
5202 {
5203 input: 'http://192.168.257.com',
5204 base: 'http://other.com/',
5205 href: 'http://192.168.257.com/',
5206 origin: 'http://192.168.257.com',
5207 protocol: 'http:',
5208 username: '',
5209 password: '',
5210 host: '192.168.257.com',
5211 hostname: '192.168.257.com',
5212 port: '',
5213 pathname: '/',
5214 search: '',
5215 hash: '',
5216 },
5217 {
5218 input: 'http://256',
5219 base: 'http://other.com/',
5220 href: 'http://0.0.1.0/',
5221 origin: 'http://0.0.1.0',
5222 protocol: 'http:',
5223 username: '',
5224 password: '',
5225 host: '0.0.1.0',
5226 hostname: '0.0.1.0',
5227 port: '',
5228 pathname: '/',
5229 search: '',
5230 hash: '',
5231 },
5232 {
5233 input: 'http://256.com',
5234 base: 'http://other.com/',
5235 href: 'http://256.com/',
5236 origin: 'http://256.com',
5237 protocol: 'http:',
5238 username: '',
5239 password: '',
5240 host: '256.com',
5241 hostname: '256.com',
5242 port: '',
5243 pathname: '/',
5244 search: '',
5245 hash: '',
5246 },
5247 {
5248 input: 'http://999999999',
5249 base: 'http://other.com/',
5250 href: 'http://59.154.201.255/',
5251 origin: 'http://59.154.201.255',
5252 protocol: 'http:',
5253 username: '',
5254 password: '',
5255 host: '59.154.201.255',
5256 hostname: '59.154.201.255',
5257 port: '',
5258 pathname: '/',
5259 search: '',
5260 hash: '',
5261 },
5262 {
5263 input: 'http://999999999.com',
5264 base: 'http://other.com/',
5265 href: 'http://999999999.com/',
5266 origin: 'http://999999999.com',
5267 protocol: 'http:',
5268 username: '',
5269 password: '',
5270 host: '999999999.com',
5271 hostname: '999999999.com',
5272 port: '',
5273 pathname: '/',
5274 search: '',
5275 hash: '',
5276 },
5277 {
5278 input: 'http://10000000000',
5279 base: 'http://other.com/',
5280 failure: true,
5281 },
5282 {
5283 input: 'http://10000000000.com',
5284 base: 'http://other.com/',
5285 href: 'http://10000000000.com/',
5286 origin: 'http://10000000000.com',
5287 protocol: 'http:',
5288 username: '',
5289 password: '',
5290 host: '10000000000.com',
5291 hostname: '10000000000.com',
5292 port: '',
5293 pathname: '/',
5294 search: '',
5295 hash: '',
5296 },
5297 {
5298 input: 'http://4294967295',
5299 base: 'http://other.com/',
5300 href: 'http://255.255.255.255/',
5301 origin: 'http://255.255.255.255',
5302 protocol: 'http:',
5303 username: '',
5304 password: '',
5305 host: '255.255.255.255',
5306 hostname: '255.255.255.255',
5307 port: '',
5308 pathname: '/',
5309 search: '',
5310 hash: '',
5311 },
5312 {
5313 input: 'http://4294967296',
5314 base: 'http://other.com/',
5315 failure: true,
5316 },
5317 {
5318 input: 'http://0xffffffff',
5319 base: 'http://other.com/',
5320 href: 'http://255.255.255.255/',
5321 origin: 'http://255.255.255.255',
5322 protocol: 'http:',
5323 username: '',
5324 password: '',
5325 host: '255.255.255.255',
5326 hostname: '255.255.255.255',
5327 port: '',
5328 pathname: '/',
5329 search: '',
5330 hash: '',
5331 },
5332 {
5333 input: 'http://0xffffffff1',
5334 base: 'http://other.com/',
5335 failure: true,
5336 },
5337 {
5338 input: 'http://256.256.256.256',
5339 base: 'http://other.com/',
5340 failure: true,
5341 },
5342 {
5343 input: 'https://0x.0x.0',
5344 base: 'about:blank',
5345 href: 'https://0.0.0.0/',
5346 origin: 'https://0.0.0.0',
5347 protocol: 'https:',
5348 username: '',
5349 password: '',
5350 host: '0.0.0.0',
5351 hostname: '0.0.0.0',
5352 port: '',
5353 pathname: '/',
5354 search: '',
5355 hash: '',
5356 },
5357 'More IPv4 parsing (via https://github.com/jsdom/whatwg-url/issues/92)',
5358 {
5359 input: 'https://0x100000000/test',
5360 base: 'about:blank',
5361 failure: true,
5362 },
5363 {
5364 input: 'https://256.0.0.1/test',
5365 base: 'about:blank',
5366 failure: true,
5367 },
5368 "# file URLs containing percent-encoded Windows drive letters (shouldn't work)",
5369 {
5370 input: 'file:///C%3A/',
5371 base: 'about:blank',
5372 href: 'file:///C%3A/',
5373 protocol: 'file:',
5374 username: '',
5375 password: '',
5376 host: '',
5377 hostname: '',
5378 port: '',
5379 pathname: '/C%3A/',
5380 search: '',
5381 hash: '',
5382 },
5383 {
5384 input: 'file:///C%7C/',
5385 base: 'about:blank',
5386 href: 'file:///C%7C/',
5387 protocol: 'file:',
5388 username: '',
5389 password: '',
5390 host: '',
5391 hostname: '',
5392 port: '',
5393 pathname: '/C%7C/',
5394 search: '',
5395 hash: '',
5396 },
5397 '# file URLs relative to other file URLs (via https://github.com/jsdom/whatwg-url/pull/60)',
5398 {
5399 input: 'pix/submit.gif',
5400 base: 'file:///C:/Users/Domenic/Dropbox/GitHub/tmpvar/jsdom/test/level2/html/files/anchor.html',
5401 href: 'file:///C:/Users/Domenic/Dropbox/GitHub/tmpvar/jsdom/test/level2/html/files/pix/submit.gif',
5402 protocol: 'file:',
5403 username: '',
5404 password: '',
5405 host: '',
5406 hostname: '',
5407 port: '',
5408 pathname:
5409 '/C:/Users/Domenic/Dropbox/GitHub/tmpvar/jsdom/test/level2/html/files/pix/submit.gif',
5410 search: '',
5411 hash: '',
5412 },
5413 {
5414 input: '..',
5415 base: 'file:///C:/',
5416 href: 'file:///C:/',
5417 protocol: 'file:',
5418 username: '',
5419 password: '',
5420 host: '',
5421 hostname: '',
5422 port: '',
5423 pathname: '/C:/',
5424 search: '',
5425 hash: '',
5426 },
5427 {
5428 input: '..',
5429 base: 'file:///',
5430 href: 'file:///',
5431 protocol: 'file:',
5432 username: '',
5433 password: '',
5434 host: '',
5435 hostname: '',
5436 port: '',
5437 pathname: '/',
5438 search: '',
5439 hash: '',
5440 },
5441 '# More file URL tests by zcorpan and annevk',
5442 {
5443 input: '/',
5444 base: 'file:///C:/a/b',
5445 href: 'file:///C:/',
5446 protocol: 'file:',
5447 username: '',
5448 password: '',
5449 host: '',
5450 hostname: '',
5451 port: '',
5452 pathname: '/C:/',
5453 search: '',
5454 hash: '',
5455 },
5456 {
5457 input: '//d:',
5458 base: 'file:///C:/a/b',
5459 href: 'file:///d:',
5460 protocol: 'file:',
5461 username: '',
5462 password: '',
5463 host: '',
5464 hostname: '',
5465 port: '',
5466 pathname: '/d:',
5467 search: '',
5468 hash: '',
5469 },
5470 {
5471 input: '//d:/..',
5472 base: 'file:///C:/a/b',
5473 href: 'file:///d:/',
5474 protocol: 'file:',
5475 username: '',
5476 password: '',
5477 host: '',
5478 hostname: '',
5479 port: '',
5480 pathname: '/d:/',
5481 search: '',
5482 hash: '',
5483 },
5484 {
5485 input: '..',
5486 base: 'file:///ab:/',
5487 href: 'file:///',
5488 protocol: 'file:',
5489 username: '',
5490 password: '',
5491 host: '',
5492 hostname: '',
5493 port: '',
5494 pathname: '/',
5495 search: '',
5496 hash: '',
5497 },
5498 {
5499 input: '..',
5500 base: 'file:///1:/',
5501 href: 'file:///',
5502 protocol: 'file:',
5503 username: '',
5504 password: '',
5505 host: '',
5506 hostname: '',
5507 port: '',
5508 pathname: '/',
5509 search: '',
5510 hash: '',
5511 },
5512 {
5513 input: '',
5514 base: 'file:///test?test#test',
5515 href: 'file:///test?test',
5516 protocol: 'file:',
5517 username: '',
5518 password: '',
5519 host: '',
5520 hostname: '',
5521 port: '',
5522 pathname: '/test',
5523 search: '?test',
5524 hash: '',
5525 },
5526 {
5527 input: 'file:',
5528 base: 'file:///test?test#test',
5529 href: 'file:///test?test',
5530 protocol: 'file:',
5531 username: '',
5532 password: '',
5533 host: '',
5534 hostname: '',
5535 port: '',
5536 pathname: '/test',
5537 search: '?test',
5538 hash: '',
5539 },
5540 {
5541 input: '?x',
5542 base: 'file:///test?test#test',
5543 href: 'file:///test?x',
5544 protocol: 'file:',
5545 username: '',
5546 password: '',
5547 host: '',
5548 hostname: '',
5549 port: '',
5550 pathname: '/test',
5551 search: '?x',
5552 hash: '',
5553 },
5554 {
5555 input: 'file:?x',
5556 base: 'file:///test?test#test',
5557 href: 'file:///test?x',
5558 protocol: 'file:',
5559 username: '',
5560 password: '',
5561 host: '',
5562 hostname: '',
5563 port: '',
5564 pathname: '/test',
5565 search: '?x',
5566 hash: '',
5567 },
5568 {
5569 input: '#x',
5570 base: 'file:///test?test#test',
5571 href: 'file:///test?test#x',
5572 protocol: 'file:',
5573 username: '',
5574 password: '',
5575 host: '',
5576 hostname: '',
5577 port: '',
5578 pathname: '/test',
5579 search: '?test',
5580 hash: '#x',
5581 },
5582 {
5583 input: 'file:#x',
5584 base: 'file:///test?test#test',
5585 href: 'file:///test?test#x',
5586 protocol: 'file:',
5587 username: '',
5588 password: '',
5589 host: '',
5590 hostname: '',
5591 port: '',
5592 pathname: '/test',
5593 search: '?test',
5594 hash: '#x',
5595 },
5596 '# File URLs and many (back)slashes',
5597 {
5598 input: 'file:\\\\//',
5599 base: 'about:blank',
5600 href: 'file:////',
5601 protocol: 'file:',
5602 username: '',
5603 password: '',
5604 host: '',
5605 hostname: '',
5606 port: '',
5607 pathname: '//',
5608 search: '',
5609 hash: '',
5610 },
5611 {
5612 input: 'file:\\\\\\\\',
5613 base: 'about:blank',
5614 href: 'file:////',
5615 protocol: 'file:',
5616 username: '',
5617 password: '',
5618 host: '',
5619 hostname: '',
5620 port: '',
5621 pathname: '//',
5622 search: '',
5623 hash: '',
5624 },
5625 {
5626 input: 'file:\\\\\\\\?fox',
5627 base: 'about:blank',
5628 href: 'file:////?fox',
5629 protocol: 'file:',
5630 username: '',
5631 password: '',
5632 host: '',
5633 hostname: '',
5634 port: '',
5635 pathname: '//',
5636 search: '?fox',
5637 hash: '',
5638 },
5639 {
5640 input: 'file:\\\\\\\\#guppy',
5641 base: 'about:blank',
5642 href: 'file:////#guppy',
5643 protocol: 'file:',
5644 username: '',
5645 password: '',
5646 host: '',
5647 hostname: '',
5648 port: '',
5649 pathname: '//',
5650 search: '',
5651 hash: '#guppy',
5652 },
5653 {
5654 input: 'file://spider///',
5655 base: 'about:blank',
5656 href: 'file://spider///',
5657 protocol: 'file:',
5658 username: '',
5659 password: '',
5660 host: 'spider',
5661 hostname: 'spider',
5662 port: '',
5663 pathname: '///',
5664 search: '',
5665 hash: '',
5666 },
5667 {
5668 input: 'file:\\\\localhost//',
5669 base: 'about:blank',
5670 href: 'file:////',
5671 protocol: 'file:',
5672 username: '',
5673 password: '',
5674 host: '',
5675 hostname: '',
5676 port: '',
5677 pathname: '//',
5678 search: '',
5679 hash: '',
5680 },
5681 {
5682 input: 'file:///localhost//cat',
5683 base: 'about:blank',
5684 href: 'file:///localhost//cat',
5685 protocol: 'file:',
5686 username: '',
5687 password: '',
5688 host: '',
5689 hostname: '',
5690 port: '',
5691 pathname: '/localhost//cat',
5692 search: '',
5693 hash: '',
5694 },
5695 {
5696 input: 'file://\\/localhost//cat',
5697 base: 'about:blank',
5698 href: 'file:////localhost//cat',
5699 protocol: 'file:',
5700 username: '',
5701 password: '',
5702 host: '',
5703 hostname: '',
5704 port: '',
5705 pathname: '//localhost//cat',
5706 search: '',
5707 hash: '',
5708 },
5709 {
5710 input: 'file://localhost//a//../..//',
5711 base: 'about:blank',
5712 href: 'file://///',
5713 protocol: 'file:',
5714 username: '',
5715 password: '',
5716 host: '',
5717 hostname: '',
5718 port: '',
5719 pathname: '///',
5720 search: '',
5721 hash: '',
5722 },
5723 {
5724 input: '/////mouse',
5725 base: 'file:///elephant',
5726 href: 'file://///mouse',
5727 protocol: 'file:',
5728 username: '',
5729 password: '',
5730 host: '',
5731 hostname: '',
5732 port: '',
5733 pathname: '///mouse',
5734 search: '',
5735 hash: '',
5736 },
5737 {
5738 input: '\\//pig',
5739 base: 'file://lion/',
5740 href: 'file:///pig',
5741 protocol: 'file:',
5742 username: '',
5743 password: '',
5744 host: '',
5745 hostname: '',
5746 port: '',
5747 pathname: '/pig',
5748 search: '',
5749 hash: '',
5750 },
5751 {
5752 input: '\\/localhost//pig',
5753 base: 'file://lion/',
5754 href: 'file:////pig',
5755 protocol: 'file:',
5756 username: '',
5757 password: '',
5758 host: '',
5759 hostname: '',
5760 port: '',
5761 pathname: '//pig',
5762 search: '',
5763 hash: '',
5764 },
5765 {
5766 input: '//localhost//pig',
5767 base: 'file://lion/',
5768 href: 'file:////pig',
5769 protocol: 'file:',
5770 username: '',
5771 password: '',
5772 host: '',
5773 hostname: '',
5774 port: '',
5775 pathname: '//pig',
5776 search: '',
5777 hash: '',
5778 },
5779 {
5780 input: '/..//localhost//pig',
5781 base: 'file://lion/',
5782 href: 'file://lion//localhost//pig',
5783 protocol: 'file:',
5784 username: '',
5785 password: '',
5786 host: 'lion',
5787 hostname: 'lion',
5788 port: '',
5789 pathname: '//localhost//pig',
5790 search: '',
5791 hash: '',
5792 },
5793 {
5794 input: 'file://',
5795 base: 'file://ape/',
5796 href: 'file:///',
5797 protocol: 'file:',
5798 username: '',
5799 password: '',
5800 host: '',
5801 hostname: '',
5802 port: '',
5803 pathname: '/',
5804 search: '',
5805 hash: '',
5806 },
5807 '# File URLs with non-empty hosts',
5808 {
5809 input: '/rooibos',
5810 base: 'file://tea/',
5811 href: 'file://tea/rooibos',
5812 protocol: 'file:',
5813 username: '',
5814 password: '',
5815 host: 'tea',
5816 hostname: 'tea',
5817 port: '',
5818 pathname: '/rooibos',
5819 search: '',
5820 hash: '',
5821 },
5822 {
5823 input: '/?chai',
5824 base: 'file://tea/',
5825 href: 'file://tea/?chai',
5826 protocol: 'file:',
5827 username: '',
5828 password: '',
5829 host: 'tea',
5830 hostname: 'tea',
5831 port: '',
5832 pathname: '/',
5833 search: '?chai',
5834 hash: '',
5835 },
5836 "# Windows drive letter handling with the 'file:' base URL",
5837 {
5838 input: 'C|',
5839 base: 'file://host/dir/file',
5840 href: 'file://host/C:',
5841 protocol: 'file:',
5842 username: '',
5843 password: '',
5844 host: 'host',
5845 hostname: 'host',
5846 port: '',
5847 pathname: '/C:',
5848 search: '',
5849 hash: '',
5850 },
5851 {
5852 input: 'C|#',
5853 base: 'file://host/dir/file',
5854 href: 'file://host/C:#',
5855 protocol: 'file:',
5856 username: '',
5857 password: '',
5858 host: 'host',
5859 hostname: 'host',
5860 port: '',
5861 pathname: '/C:',
5862 search: '',
5863 hash: '',
5864 },
5865 {
5866 input: 'C|?',
5867 base: 'file://host/dir/file',
5868 href: 'file://host/C:?',
5869 protocol: 'file:',
5870 username: '',
5871 password: '',
5872 host: 'host',
5873 hostname: 'host',
5874 port: '',
5875 pathname: '/C:',
5876 search: '',
5877 hash: '',
5878 },
5879 {
5880 input: 'C|/',
5881 base: 'file://host/dir/file',
5882 href: 'file://host/C:/',
5883 protocol: 'file:',
5884 username: '',
5885 password: '',
5886 host: 'host',
5887 hostname: 'host',
5888 port: '',
5889 pathname: '/C:/',
5890 search: '',
5891 hash: '',
5892 },
5893 {
5894 input: 'C|\n/',
5895 base: 'file://host/dir/file',
5896 href: 'file://host/C:/',
5897 protocol: 'file:',
5898 username: '',
5899 password: '',
5900 host: 'host',
5901 hostname: 'host',
5902 port: '',
5903 pathname: '/C:/',
5904 search: '',
5905 hash: '',
5906 },
5907 {
5908 input: 'C|\\',
5909 base: 'file://host/dir/file',
5910 href: 'file://host/C:/',
5911 protocol: 'file:',
5912 username: '',
5913 password: '',
5914 host: 'host',
5915 hostname: 'host',
5916 port: '',
5917 pathname: '/C:/',
5918 search: '',
5919 hash: '',
5920 },
5921 {
5922 input: 'C',
5923 base: 'file://host/dir/file',
5924 href: 'file://host/dir/C',
5925 protocol: 'file:',
5926 username: '',
5927 password: '',
5928 host: 'host',
5929 hostname: 'host',
5930 port: '',
5931 pathname: '/dir/C',
5932 search: '',
5933 hash: '',
5934 },
5935 {
5936 input: 'C|a',
5937 base: 'file://host/dir/file',
5938 href: 'file://host/dir/C|a',
5939 protocol: 'file:',
5940 username: '',
5941 password: '',
5942 host: 'host',
5943 hostname: 'host',
5944 port: '',
5945 pathname: '/dir/C|a',
5946 search: '',
5947 hash: '',
5948 },
5949 '# Windows drive letter quirk with not empty host',
5950 {
5951 input: 'file://example.net/C:/',
5952 base: 'about:blank',
5953 href: 'file://example.net/C:/',
5954 protocol: 'file:',
5955 username: '',
5956 password: '',
5957 host: 'example.net',
5958 hostname: 'example.net',
5959 port: '',
5960 pathname: '/C:/',
5961 search: '',
5962 hash: '',
5963 },
5964 {
5965 input: 'file://1.2.3.4/C:/',
5966 base: 'about:blank',
5967 href: 'file://1.2.3.4/C:/',
5968 protocol: 'file:',
5969 username: '',
5970 password: '',
5971 host: '1.2.3.4',
5972 hostname: '1.2.3.4',
5973 port: '',
5974 pathname: '/C:/',
5975 search: '',
5976 hash: '',
5977 },
5978 {
5979 input: 'file://[1::8]/C:/',
5980 base: 'about:blank',
5981 href: 'file://[1::8]/C:/',
5982 protocol: 'file:',
5983 username: '',
5984 password: '',
5985 host: '[1::8]',
5986 hostname: '[1::8]',
5987 port: '',
5988 pathname: '/C:/',
5989 search: '',
5990 hash: '',
5991 },
5992 '# Windows drive letter quirk (no host)',
5993 {
5994 input: 'file:/C|/',
5995 base: 'about:blank',
5996 href: 'file:///C:/',
5997 protocol: 'file:',
5998 username: '',
5999 password: '',
6000 host: '',
6001 hostname: '',
6002 port: '',
6003 pathname: '/C:/',
6004 search: '',
6005 hash: '',
6006 },
6007 {
6008 input: 'file://C|/',
6009 base: 'about:blank',
6010 href: 'file:///C:/',
6011 protocol: 'file:',
6012 username: '',
6013 password: '',
6014 host: '',
6015 hostname: '',
6016 port: '',
6017 pathname: '/C:/',
6018 search: '',
6019 hash: '',
6020 },
6021 '# file URLs without base URL by Rimas Misevičius',
6022 {
6023 input: 'file:',
6024 base: 'about:blank',
6025 href: 'file:///',
6026 protocol: 'file:',
6027 username: '',
6028 password: '',
6029 host: '',
6030 hostname: '',
6031 port: '',
6032 pathname: '/',
6033 search: '',
6034 hash: '',
6035 },
6036 {
6037 input: 'file:?q=v',
6038 base: 'about:blank',
6039 href: 'file:///?q=v',
6040 protocol: 'file:',
6041 username: '',
6042 password: '',
6043 host: '',
6044 hostname: '',
6045 port: '',
6046 pathname: '/',
6047 search: '?q=v',
6048 hash: '',
6049 },
6050 {
6051 input: 'file:#frag',
6052 base: 'about:blank',
6053 href: 'file:///#frag',
6054 protocol: 'file:',
6055 username: '',
6056 password: '',
6057 host: '',
6058 hostname: '',
6059 port: '',
6060 pathname: '/',
6061 search: '',
6062 hash: '#frag',
6063 },
6064 '# IPv6 tests',
6065 {
6066 input: 'http://[1:0::]',
6067 base: 'http://example.net/',
6068 href: 'http://[1::]/',
6069 origin: 'http://[1::]',
6070 protocol: 'http:',
6071 username: '',
6072 password: '',
6073 host: '[1::]',
6074 hostname: '[1::]',
6075 port: '',
6076 pathname: '/',
6077 search: '',
6078 hash: '',
6079 },
6080 {
6081 input: 'http://[0:1:2:3:4:5:6:7:8]',
6082 base: 'http://example.net/',
6083 failure: true,
6084 },
6085 {
6086 input: 'https://[0::0::0]',
6087 base: 'about:blank',
6088 failure: true,
6089 },
6090 {
6091 input: 'https://[0:.0]',
6092 base: 'about:blank',
6093 failure: true,
6094 },
6095 {
6096 input: 'https://[0:0:]',
6097 base: 'about:blank',
6098 failure: true,
6099 },
6100 {
6101 input: 'https://[0:1:2:3:4:5:6:7.0.0.0.1]',
6102 base: 'about:blank',
6103 failure: true,
6104 },
6105 {
6106 input: 'https://[0:1.00.0.0.0]',
6107 base: 'about:blank',
6108 failure: true,
6109 },
6110 {
6111 input: 'https://[0:1.290.0.0.0]',
6112 base: 'about:blank',
6113 failure: true,
6114 },
6115 {
6116 input: 'https://[0:1.23.23]',
6117 base: 'about:blank',
6118 failure: true,
6119 },
6120 '# Empty host',
6121 {
6122 input: 'http://?',
6123 base: 'about:blank',
6124 failure: true,
6125 },
6126 {
6127 input: 'http://#',
6128 base: 'about:blank',
6129 failure: true,
6130 },
6131 '# Non-special-URL path tests',
6132 {
6133 input: 'sc://ñ',
6134 base: 'about:blank',
6135 href: 'sc://%C3%B1',
6136 origin: 'null',
6137 protocol: 'sc:',
6138 username: '',
6139 password: '',
6140 host: '%C3%B1',
6141 hostname: '%C3%B1',
6142 port: '',
6143 pathname: '',
6144 search: '',
6145 hash: '',
6146 },
6147 {
6148 input: 'sc://ñ?x',
6149 base: 'about:blank',
6150 href: 'sc://%C3%B1?x',
6151 origin: 'null',
6152 protocol: 'sc:',
6153 username: '',
6154 password: '',
6155 host: '%C3%B1',
6156 hostname: '%C3%B1',
6157 port: '',
6158 pathname: '',
6159 search: '?x',
6160 hash: '',
6161 },
6162 {
6163 input: 'sc://ñ#x',
6164 base: 'about:blank',
6165 href: 'sc://%C3%B1#x',
6166 origin: 'null',
6167 protocol: 'sc:',
6168 username: '',
6169 password: '',
6170 host: '%C3%B1',
6171 hostname: '%C3%B1',
6172 port: '',
6173 pathname: '',
6174 search: '',
6175 hash: '#x',
6176 },
6177 {
6178 input: '#x',
6179 base: 'sc://ñ',
6180 href: 'sc://%C3%B1#x',
6181 origin: 'null',
6182 protocol: 'sc:',
6183 username: '',
6184 password: '',
6185 host: '%C3%B1',
6186 hostname: '%C3%B1',
6187 port: '',
6188 pathname: '',
6189 search: '',
6190 hash: '#x',
6191 },
6192 {
6193 input: '?x',
6194 base: 'sc://ñ',
6195 href: 'sc://%C3%B1?x',
6196 origin: 'null',
6197 protocol: 'sc:',
6198 username: '',
6199 password: '',
6200 host: '%C3%B1',
6201 hostname: '%C3%B1',
6202 port: '',
6203 pathname: '',
6204 search: '?x',
6205 hash: '',
6206 },
6207 {
6208 input: 'sc://?',
6209 base: 'about:blank',
6210 href: 'sc://?',
6211 protocol: 'sc:',
6212 username: '',
6213 password: '',
6214 host: '',
6215 hostname: '',
6216 port: '',
6217 pathname: '',
6218 search: '',
6219 hash: '',
6220 },
6221 {
6222 input: 'sc://#',
6223 base: 'about:blank',
6224 href: 'sc://#',
6225 protocol: 'sc:',
6226 username: '',
6227 password: '',
6228 host: '',
6229 hostname: '',
6230 port: '',
6231 pathname: '',
6232 search: '',
6233 hash: '',
6234 },
6235 {
6236 input: '///',
6237 base: 'sc://x/',
6238 href: 'sc:///',
6239 protocol: 'sc:',
6240 username: '',
6241 password: '',
6242 host: '',
6243 hostname: '',
6244 port: '',
6245 pathname: '/',
6246 search: '',
6247 hash: '',
6248 },
6249 {
6250 input: '////',
6251 base: 'sc://x/',
6252 href: 'sc:////',
6253 protocol: 'sc:',
6254 username: '',
6255 password: '',
6256 host: '',
6257 hostname: '',
6258 port: '',
6259 pathname: '//',
6260 search: '',
6261 hash: '',
6262 },
6263 {
6264 input: '////x/',
6265 base: 'sc://x/',
6266 href: 'sc:////x/',
6267 protocol: 'sc:',
6268 username: '',
6269 password: '',
6270 host: '',
6271 hostname: '',
6272 port: '',
6273 pathname: '//x/',
6274 search: '',
6275 hash: '',
6276 },
6277 {
6278 input: 'tftp://foobar.com/someconfig;mode=netascii',
6279 base: 'about:blank',
6280 href: 'tftp://foobar.com/someconfig;mode=netascii',
6281 origin: 'null',
6282 protocol: 'tftp:',
6283 username: '',
6284 password: '',
6285 host: 'foobar.com',
6286 hostname: 'foobar.com',
6287 port: '',
6288 pathname: '/someconfig;mode=netascii',
6289 search: '',
6290 hash: '',
6291 },
6292 {
6293 input: 'telnet://user:pass@foobar.com:23/',
6294 base: 'about:blank',
6295 href: 'telnet://user:pass@foobar.com:23/',
6296 origin: 'null',
6297 protocol: 'telnet:',
6298 username: 'user',
6299 password: 'pass',
6300 host: 'foobar.com:23',
6301 hostname: 'foobar.com',
6302 port: '23',
6303 pathname: '/',
6304 search: '',
6305 hash: '',
6306 },
6307 {
6308 input: 'ut2004://10.10.10.10:7777/Index.ut2',
6309 base: 'about:blank',
6310 href: 'ut2004://10.10.10.10:7777/Index.ut2',
6311 origin: 'null',
6312 protocol: 'ut2004:',
6313 username: '',
6314 password: '',
6315 host: '10.10.10.10:7777',
6316 hostname: '10.10.10.10',
6317 port: '7777',
6318 pathname: '/Index.ut2',
6319 search: '',
6320 hash: '',
6321 },
6322 {
6323 input: 'redis://foo:bar@somehost:6379/0?baz=bam&qux=baz',
6324 base: 'about:blank',
6325 href: 'redis://foo:bar@somehost:6379/0?baz=bam&qux=baz',
6326 origin: 'null',
6327 protocol: 'redis:',
6328 username: 'foo',
6329 password: 'bar',
6330 host: 'somehost:6379',
6331 hostname: 'somehost',
6332 port: '6379',
6333 pathname: '/0',
6334 search: '?baz=bam&qux=baz',
6335 hash: '',
6336 },
6337 {
6338 input: 'rsync://foo@host:911/sup',
6339 base: 'about:blank',
6340 href: 'rsync://foo@host:911/sup',
6341 origin: 'null',
6342 protocol: 'rsync:',
6343 username: 'foo',
6344 password: '',
6345 host: 'host:911',
6346 hostname: 'host',
6347 port: '911',
6348 pathname: '/sup',
6349 search: '',
6350 hash: '',
6351 },
6352 {
6353 input: 'git://github.com/foo/bar.git',
6354 base: 'about:blank',
6355 href: 'git://github.com/foo/bar.git',
6356 origin: 'null',
6357 protocol: 'git:',
6358 username: '',
6359 password: '',
6360 host: 'github.com',
6361 hostname: 'github.com',
6362 port: '',
6363 pathname: '/foo/bar.git',
6364 search: '',
6365 hash: '',
6366 },
6367 {
6368 input: 'irc://myserver.com:6999/channel?passwd',
6369 base: 'about:blank',
6370 href: 'irc://myserver.com:6999/channel?passwd',
6371 origin: 'null',
6372 protocol: 'irc:',
6373 username: '',
6374 password: '',
6375 host: 'myserver.com:6999',
6376 hostname: 'myserver.com',
6377 port: '6999',
6378 pathname: '/channel',
6379 search: '?passwd',
6380 hash: '',
6381 },
6382 {
6383 input: 'dns://fw.example.org:9999/foo.bar.org?type=TXT',
6384 base: 'about:blank',
6385 href: 'dns://fw.example.org:9999/foo.bar.org?type=TXT',
6386 origin: 'null',
6387 protocol: 'dns:',
6388 username: '',
6389 password: '',
6390 host: 'fw.example.org:9999',
6391 hostname: 'fw.example.org',
6392 port: '9999',
6393 pathname: '/foo.bar.org',
6394 search: '?type=TXT',
6395 hash: '',
6396 },
6397 {
6398 input: 'ldap://localhost:389/ou=People,o=JNDITutorial',
6399 base: 'about:blank',
6400 href: 'ldap://localhost:389/ou=People,o=JNDITutorial',
6401 origin: 'null',
6402 protocol: 'ldap:',
6403 username: '',
6404 password: '',
6405 host: 'localhost:389',
6406 hostname: 'localhost',
6407 port: '389',
6408 pathname: '/ou=People,o=JNDITutorial',
6409 search: '',
6410 hash: '',
6411 },
6412 {
6413 input: 'git+https://github.com/foo/bar',
6414 base: 'about:blank',
6415 href: 'git+https://github.com/foo/bar',
6416 origin: 'null',
6417 protocol: 'git+https:',
6418 username: '',
6419 password: '',
6420 host: 'github.com',
6421 hostname: 'github.com',
6422 port: '',
6423 pathname: '/foo/bar',
6424 search: '',
6425 hash: '',
6426 },
6427 {
6428 input: 'urn:ietf:rfc:2648',
6429 base: 'about:blank',
6430 href: 'urn:ietf:rfc:2648',
6431 origin: 'null',
6432 protocol: 'urn:',
6433 username: '',
6434 password: '',
6435 host: '',
6436 hostname: '',
6437 port: '',
6438 pathname: 'ietf:rfc:2648',
6439 search: '',
6440 hash: '',
6441 },
6442 {
6443 input: 'tag:joe@example.org,2001:foo/bar',
6444 base: 'about:blank',
6445 href: 'tag:joe@example.org,2001:foo/bar',
6446 origin: 'null',
6447 protocol: 'tag:',
6448 username: '',
6449 password: '',
6450 host: '',
6451 hostname: '',
6452 port: '',
6453 pathname: 'joe@example.org,2001:foo/bar',
6454 search: '',
6455 hash: '',
6456 },
6457 '# percent encoded hosts in non-special-URLs',
6458 {
6459 input: 'non-special://%E2%80%A0/',
6460 base: 'about:blank',
6461 href: 'non-special://%E2%80%A0/',
6462 protocol: 'non-special:',
6463 username: '',
6464 password: '',
6465 host: '%E2%80%A0',
6466 hostname: '%E2%80%A0',
6467 port: '',
6468 pathname: '/',
6469 search: '',
6470 hash: '',
6471 },
6472 {
6473 input: 'non-special://H%4fSt/path',
6474 base: 'about:blank',
6475 href: 'non-special://H%4fSt/path',
6476 protocol: 'non-special:',
6477 username: '',
6478 password: '',
6479 host: 'H%4fSt',
6480 hostname: 'H%4fSt',
6481 port: '',
6482 pathname: '/path',
6483 search: '',
6484 hash: '',
6485 },
6486 '# IPv6 in non-special-URLs',
6487 {
6488 input: 'non-special://[1:2:0:0:5:0:0:0]/',
6489 base: 'about:blank',
6490 href: 'non-special://[1:2:0:0:5::]/',
6491 protocol: 'non-special:',
6492 username: '',
6493 password: '',
6494 host: '[1:2:0:0:5::]',
6495 hostname: '[1:2:0:0:5::]',
6496 port: '',
6497 pathname: '/',
6498 search: '',
6499 hash: '',
6500 },
6501 {
6502 input: 'non-special://[1:2:0:0:0:0:0:3]/',
6503 base: 'about:blank',
6504 href: 'non-special://[1:2::3]/',
6505 protocol: 'non-special:',
6506 username: '',
6507 password: '',
6508 host: '[1:2::3]',
6509 hostname: '[1:2::3]',
6510 port: '',
6511 pathname: '/',
6512 search: '',
6513 hash: '',
6514 },
6515 {
6516 input: 'non-special://[1:2::3]:80/',
6517 base: 'about:blank',
6518 href: 'non-special://[1:2::3]:80/',
6519 protocol: 'non-special:',
6520 username: '',
6521 password: '',
6522 host: '[1:2::3]:80',
6523 hostname: '[1:2::3]',
6524 port: '80',
6525 pathname: '/',
6526 search: '',
6527 hash: '',
6528 },
6529 {
6530 input: 'non-special://[:80/',
6531 base: 'about:blank',
6532 failure: true,
6533 },
6534 {
6535 input: 'blob:https://example.com:443/',
6536 base: 'about:blank',
6537 href: 'blob:https://example.com:443/',
6538 origin: 'https://example.com',
6539 protocol: 'blob:',
6540 username: '',
6541 password: '',
6542 host: '',
6543 hostname: '',
6544 port: '',
6545 pathname: 'https://example.com:443/',
6546 search: '',
6547 hash: '',
6548 },
6549 {
6550 input: 'blob:d3958f5c-0777-0845-9dcf-2cb28783acaf',
6551 base: 'about:blank',
6552 href: 'blob:d3958f5c-0777-0845-9dcf-2cb28783acaf',
6553 protocol: 'blob:',
6554 username: '',
6555 password: '',
6556 host: '',
6557 hostname: '',
6558 port: '',
6559 pathname: 'd3958f5c-0777-0845-9dcf-2cb28783acaf',
6560 search: '',
6561 hash: '',
6562 },
6563 'Invalid IPv4 radix digits',
6564 {
6565 input: 'http://0x7f.0.0.0x7g',
6566 base: 'about:blank',
6567 href: 'http://0x7f.0.0.0x7g/',
6568 origin: 'http://0x7f.0.0.0x7g',
6569 protocol: 'http:',
6570 username: '',
6571 password: '',
6572 host: '0x7f.0.0.0x7g',
6573 hostname: '0x7f.0.0.0x7g',
6574 port: '',
6575 pathname: '/',
6576 search: '',
6577 hash: '',
6578 },
6579 {
6580 input: 'http://0X7F.0.0.0X7G',
6581 base: 'about:blank',
6582 href: 'http://0x7f.0.0.0x7g/',
6583 origin: 'http://0x7f.0.0.0x7g',
6584 protocol: 'http:',
6585 username: '',
6586 password: '',
6587 host: '0x7f.0.0.0x7g',
6588 hostname: '0x7f.0.0.0x7g',
6589 port: '',
6590 pathname: '/',
6591 search: '',
6592 hash: '',
6593 },
6594 'Invalid IPv4 portion of IPv6 address',
6595 {
6596 input: 'http://[::127.0.0.0.1]',
6597 base: 'about:blank',
6598 failure: true,
6599 },
6600 'Uncompressed IPv6 addresses with 0',
6601 {
6602 input: 'http://[0:1:0:1:0:1:0:1]',
6603 base: 'about:blank',
6604 href: 'http://[0:1:0:1:0:1:0:1]/',
6605 origin: 'http://[0:1:0:1:0:1:0:1]',
6606 protocol: 'http:',
6607 username: '',
6608 password: '',
6609 host: '[0:1:0:1:0:1:0:1]',
6610 hostname: '[0:1:0:1:0:1:0:1]',
6611 port: '',
6612 pathname: '/',
6613 search: '',
6614 hash: '',
6615 },
6616 {
6617 input: 'http://[1:0:1:0:1:0:1:0]',
6618 base: 'about:blank',
6619 href: 'http://[1:0:1:0:1:0:1:0]/',
6620 origin: 'http://[1:0:1:0:1:0:1:0]',
6621 protocol: 'http:',
6622 username: '',
6623 password: '',
6624 host: '[1:0:1:0:1:0:1:0]',
6625 hostname: '[1:0:1:0:1:0:1:0]',
6626 port: '',
6627 pathname: '/',
6628 search: '',
6629 hash: '',
6630 },
6631 'Percent-encoded query and fragment',
6632 {
6633 input: 'http://example.org/test?\u0022',
6634 base: 'about:blank',
6635 href: 'http://example.org/test?%22',
6636 origin: 'http://example.org',
6637 protocol: 'http:',
6638 username: '',
6639 password: '',
6640 host: 'example.org',
6641 hostname: 'example.org',
6642 port: '',
6643 pathname: '/test',
6644 search: '?%22',
6645 hash: '',
6646 },
6647 {
6648 input: 'http://example.org/test?\u0023',
6649 base: 'about:blank',
6650 href: 'http://example.org/test?#',
6651 origin: 'http://example.org',
6652 protocol: 'http:',
6653 username: '',
6654 password: '',
6655 host: 'example.org',
6656 hostname: 'example.org',
6657 port: '',
6658 pathname: '/test',
6659 search: '',
6660 hash: '',
6661 },
6662 {
6663 input: 'http://example.org/test?\u003C',
6664 base: 'about:blank',
6665 href: 'http://example.org/test?%3C',
6666 origin: 'http://example.org',
6667 protocol: 'http:',
6668 username: '',
6669 password: '',
6670 host: 'example.org',
6671 hostname: 'example.org',
6672 port: '',
6673 pathname: '/test',
6674 search: '?%3C',
6675 hash: '',
6676 },
6677 {
6678 input: 'http://example.org/test?\u003E',
6679 base: 'about:blank',
6680 href: 'http://example.org/test?%3E',
6681 origin: 'http://example.org',
6682 protocol: 'http:',
6683 username: '',
6684 password: '',
6685 host: 'example.org',
6686 hostname: 'example.org',
6687 port: '',
6688 pathname: '/test',
6689 search: '?%3E',
6690 hash: '',
6691 },
6692 {
6693 input: 'http://example.org/test?\u2323',
6694 base: 'about:blank',
6695 href: 'http://example.org/test?%E2%8C%A3',
6696 origin: 'http://example.org',
6697 protocol: 'http:',
6698 username: '',
6699 password: '',
6700 host: 'example.org',
6701 hostname: 'example.org',
6702 port: '',
6703 pathname: '/test',
6704 search: '?%E2%8C%A3',
6705 hash: '',
6706 },
6707 {
6708 input: 'http://example.org/test?%23%23',
6709 base: 'about:blank',
6710 href: 'http://example.org/test?%23%23',
6711 origin: 'http://example.org',
6712 protocol: 'http:',
6713 username: '',
6714 password: '',
6715 host: 'example.org',
6716 hostname: 'example.org',
6717 port: '',
6718 pathname: '/test',
6719 search: '?%23%23',
6720 hash: '',
6721 },
6722 {
6723 input: 'http://example.org/test?%GH',
6724 base: 'about:blank',
6725 href: 'http://example.org/test?%GH',
6726 origin: 'http://example.org',
6727 protocol: 'http:',
6728 username: '',
6729 password: '',
6730 host: 'example.org',
6731 hostname: 'example.org',
6732 port: '',
6733 pathname: '/test',
6734 search: '?%GH',
6735 hash: '',
6736 },
6737 {
6738 input: 'http://example.org/test?a#%EF',
6739 base: 'about:blank',
6740 href: 'http://example.org/test?a#%EF',
6741 origin: 'http://example.org',
6742 protocol: 'http:',
6743 username: '',
6744 password: '',
6745 host: 'example.org',
6746 hostname: 'example.org',
6747 port: '',
6748 pathname: '/test',
6749 search: '?a',
6750 hash: '#%EF',
6751 },
6752 {
6753 input: 'http://example.org/test?a#%GH',
6754 base: 'about:blank',
6755 href: 'http://example.org/test?a#%GH',
6756 origin: 'http://example.org',
6757 protocol: 'http:',
6758 username: '',
6759 password: '',
6760 host: 'example.org',
6761 hostname: 'example.org',
6762 port: '',
6763 pathname: '/test',
6764 search: '?a',
6765 hash: '#%GH',
6766 },
6767 'Bad bases',
6768 {
6769 input: 'test-a.html',
6770 base: 'a',
6771 failure: true,
6772 },
6773 {
6774 input: 'test-a-slash.html',
6775 base: 'a/',
6776 failure: true,
6777 },
6778 {
6779 input: 'test-a-slash-slash.html',
6780 base: 'a//',
6781 failure: true,
6782 },
6783 {
6784 input: 'test-a-colon.html',
6785 base: 'a:',
6786 failure: true,
6787 },
6788 {
6789 input: 'test-a-colon-slash.html',
6790 base: 'a:/',
6791 href: 'a:/test-a-colon-slash.html',
6792 protocol: 'a:',
6793 username: '',
6794 password: '',
6795 host: '',
6796 hostname: '',
6797 port: '',
6798 pathname: '/test-a-colon-slash.html',
6799 search: '',
6800 hash: '',
6801 },
6802 {
6803 input: 'test-a-colon-slash-slash.html',
6804 base: 'a://',
6805 href: 'a:///test-a-colon-slash-slash.html',
6806 protocol: 'a:',
6807 username: '',
6808 password: '',
6809 host: '',
6810 hostname: '',
6811 port: '',
6812 pathname: '/test-a-colon-slash-slash.html',
6813 search: '',
6814 hash: '',
6815 },
6816 {
6817 input: 'test-a-colon-b.html',
6818 base: 'a:b',
6819 failure: true,
6820 },
6821 {
6822 input: 'test-a-colon-slash-b.html',
6823 base: 'a:/b',
6824 href: 'a:/test-a-colon-slash-b.html',
6825 protocol: 'a:',
6826 username: '',
6827 password: '',
6828 host: '',
6829 hostname: '',
6830 port: '',
6831 pathname: '/test-a-colon-slash-b.html',
6832 search: '',
6833 hash: '',
6834 },
6835 {
6836 input: 'test-a-colon-slash-slash-b.html',
6837 base: 'a://b',
6838 href: 'a://b/test-a-colon-slash-slash-b.html',
6839 protocol: 'a:',
6840 username: '',
6841 password: '',
6842 host: 'b',
6843 hostname: 'b',
6844 port: '',
6845 pathname: '/test-a-colon-slash-slash-b.html',
6846 search: '',
6847 hash: '',
6848 },
6849 'Null code point in fragment',
6850 {
6851 input: 'http://example.org/test?a#b\u0000c',
6852 base: 'about:blank',
6853 href: 'http://example.org/test?a#b%00c',
6854 origin: 'http://example.org',
6855 protocol: 'http:',
6856 username: '',
6857 password: '',
6858 host: 'example.org',
6859 hostname: 'example.org',
6860 port: '',
6861 pathname: '/test',
6862 search: '?a',
6863 hash: '#b%00c',
6864 },
6865 ];
6866 
6867 cases.forEach((test) => {
6868 if (typeof test === 'string') return;
6869 if (test.failure) {
6870 throws(() => {
6871 new URL(test.input, test.base || 'about:blank');
6872 });
6873 return;
6874 }
6875 const url = new URL(test.input, test.base || 'about:blank');
6876 strictEqual(url.href, test.href);
6877 strictEqual(url.protocol, test.protocol);
6878 strictEqual(url.username, test.username);
6879 strictEqual(url.password, test.password);
6880 strictEqual(url.host, test.host);
6881 strictEqual(url.hostname, test.hostname);
6882 strictEqual(url.port, test.port);
6883 strictEqual(url.pathname, test.pathname);
6884 strictEqual(url.search, test.search);
6885 if ('searchParams' in test) {
6886 strictEqual(url.searchParams.toString(), test.searchParams);
6887 }
6888 strictEqual(url.hash, test.hash);
6889 if (test.origin == null) {
6890 strictEqual(url.origin, 'null');
6891 } else {
6892 strictEqual(url.origin, test.origin);
6893 }
6894 });
6895 },
6896};
6897 
6898export const wptTestURLSearchParamsConstructor = {
6899 test() {
6900 let params = new URLSearchParams();
6901 strictEqual(params + '', '');
6902 params = new URLSearchParams('');
6903 strictEqual(params + '', '');
6904 params = new URLSearchParams('a=b');
6905 strictEqual(params + '', 'a=b');
6906 params = new URLSearchParams(params);
6907 strictEqual(params + '', 'a=b');
6908 
6909 {
6910 const params = new URLSearchParams();
6911 strictEqual(params.toString(), '');
6912 }
6913 
6914 {
6915 const params = new URLSearchParams(DOMException);
6916 strictEqual(
6917 params.toString(),
6918 'INDEX_SIZE_ERR=1&DOMSTRING_SIZE_ERR=2&HIERARCHY_REQUEST_ERR=3&WRONG_DOCUMENT_ERR=4&INVALID_CHARACTER_ERR=5&NO_DATA_ALLOWED_ERR=6&NO_MODIFICATION_ALLOWED_ERR=7&NOT_FOUND_ERR=8&NOT_SUPPORTED_ERR=9&INUSE_ATTRIBUTE_ERR=10&INVALID_STATE_ERR=11&SYNTAX_ERR=12&INVALID_MODIFICATION_ERR=13&NAMESPACE_ERR=14&INVALID_ACCESS_ERR=15&VALIDATION_ERR=16&TYPE_MISMATCH_ERR=17&SECURITY_ERR=18&NETWORK_ERR=19&ABORT_ERR=20&URL_MISMATCH_ERR=21&QUOTA_EXCEEDED_ERR=22&TIMEOUT_ERR=23&INVALID_NODE_TYPE_ERR=24&DATA_CLONE_ERR=25'
6919 );
6920 }
6921 
6922 {
6923 const params = new URLSearchParams('');
6924 strictEqual(params.__proto__, URLSearchParams.prototype);
6925 }
6926 
6927 {
6928 const params = new URLSearchParams({});
6929 strictEqual(params + '', '');
6930 }
6931 
6932 {
6933 let params = new URLSearchParams('a=b');
6934 ok(params.has('a'));
6935 ok(!params.has('b'));
6936 params = new URLSearchParams('a=b&c');
6937 ok(params.has('a'));
6938 ok(params.has('c'));
6939 params = new URLSearchParams('&a&&& &&&&&a+b=& c&m%c3%b8%c3%b8');
6940 ok(params.has('a'));
6941 ok(params.has('a b'));
6942 ok(params.has(' '));
6943 ok(!params.has('c'));
6944 ok(params.has(' c'));
6945 ok(params.has('møø'));
6946 }
6947 
6948 {
6949 const seed = new URLSearchParams('a=b&c=d');
6950 const params = new URLSearchParams(seed);
6951 strictEqual(params.get('a'), 'b');
6952 strictEqual(params.get('c'), 'd');
6953 ok(!params.has('d'));
6954 // The name-value pairs are copied when created; later updates
6955 // should not be observable.
6956 seed.append('e', 'f');
6957 ok(!params.has('e'));
6958 params.append('g', 'h');
6959 ok(!seed.has('g'));
6960 }
6961 
6962 {
6963 let params = new URLSearchParams('a=b+c');
6964 strictEqual(params.get('a'), 'b c');
6965 params = new URLSearchParams('a+b=c');
6966 strictEqual(params.get('a b'), 'c');
6967 }
6968 
6969 {
6970 const testValue = '+15555555555';
6971 const params = new URLSearchParams();
6972 params.set('query', testValue);
6973 const newParams = new URLSearchParams(params.toString());
6974 
6975 strictEqual(params.toString(), 'query=%2B15555555555');
6976 strictEqual(params.get('query'), testValue);
6977 strictEqual(newParams.get('query'), testValue);
6978 }
6979 
6980 {
6981 let params = new URLSearchParams('a=b c');
6982 strictEqual(params.get('a'), 'b c');
6983 params = new URLSearchParams('a b=c');
6984 strictEqual(params.get('a b'), 'c');
6985 }
6986 
6987 {
6988 let params = new URLSearchParams('a=b%20c');
6989 strictEqual(params.get('a'), 'b c');
6990 params = new URLSearchParams('a%20b=c');
6991 strictEqual(params.get('a b'), 'c');
6992 }
6993 
6994 {
6995 let params = new URLSearchParams('a=b\0c');
6996 strictEqual(params.get('a'), 'b\0c');
6997 params = new URLSearchParams('a\0b=c');
6998 strictEqual(params.get('a\0b'), 'c');
6999 }
7000 
7001 {
7002 let params = new URLSearchParams('a=b%00c');
7003 strictEqual(params.get('a'), 'b\0c');
7004 params = new URLSearchParams('a%00b=c');
7005 strictEqual(params.get('a\0b'), 'c');
7006 }
7007 
7008 {
7009 let params = new URLSearchParams('a=b\u2384');
7010 strictEqual(params.get('a'), 'b\u2384');
7011 params = new URLSearchParams('a\u2384b=c');
7012 strictEqual(params.get('a\u2384b'), 'c');
7013 }
7014 
7015 {
7016 let params = new URLSearchParams('a=b%e2%8e%84');
7017 strictEqual(params.get('a'), 'b\u2384');
7018 params = new URLSearchParams('a%e2%8e%84b=c');
7019 strictEqual(params.get('a\u2384b'), 'c');
7020 }
7021 
7022 {
7023 let params = new URLSearchParams('a=b\uD83D\uDCA9c');
7024 strictEqual(params.get('a'), 'b\uD83D\uDCA9c');
7025 params = new URLSearchParams('a\uD83D\uDCA9b=c');
7026 strictEqual(params.get('a\uD83D\uDCA9b'), 'c');
7027 }
7028 
7029 {
7030 let params = new URLSearchParams('a=b%f0%9f%92%a9c');
7031 strictEqual(params.get('a'), 'b\uD83D\uDCA9c');
7032 params = new URLSearchParams('a%f0%9f%92%a9b=c');
7033 strictEqual(params.get('a\uD83D\uDCA9b'), 'c');
7034 }
7035 
7036 {
7037 let params = new URLSearchParams([]);
7038 params = new URLSearchParams([
7039 ['a', 'b'],
7040 ['c', 'd'],
7041 ]);
7042 strictEqual(params.get('a'), 'b');
7043 strictEqual(params.get('c'), 'd');
7044 throws(() => new URLSearchParams([[1]]));
7045 throws(() => new URLSearchParams([[1, 2, 3]]));
7046 }
7047 
7048 {
7049 let params = new URLSearchParams('a=a/b~');
7050 strictEqual(params.toString(), 'a=a%2Fb%7E');
7051 
7052 let url = new URL('https://example.org?a=a/b~');
7053 strictEqual(url.search, '?a=a/b~');
7054 strictEqual(url.searchParams.toString(), 'a=a%2Fb%7E');
7055 }
7056 
7057 [
7058 { input: { '+': '%C2' }, output: [['+', '%C2']], name: 'object with +' },
7059 {
7060 input: { c: 'x', a: '?' },
7061 output: [
7062 ['c', 'x'],
7063 ['a', '?'],
7064 ],
7065 name: 'object with two keys',
7066 },
7067 {
7068 input: [
7069 ['c', 'x'],
7070 ['a', '?'],
7071 ],
7072 output: [
7073 ['c', 'x'],
7074 ['a', '?'],
7075 ],
7076 name: 'array with two keys',
7077 },
7078 ].forEach((val) => {
7079 let params = new URLSearchParams(val.input);
7080 let i = 0;
7081 for (let param of params) {
7082 deepStrictEqual(param, val.output[i]);
7083 i++;
7084 }
7085 });
7086 
7087 {
7088 const params = new URLSearchParams();
7089 params[Symbol.iterator] = function* () {
7090 yield ['a', 'b'];
7091 };
7092 let params2 = new URLSearchParams(params);
7093 strictEqual(params2.get('a'), 'b');
7094 }
7095 },
7096};
7097 
7098export const urlSetSearch = {
7099 test() {
7100 const url = new URL('http://example.com?foo=bar&baz=qux');
7101 url.search = '?quux=corge&grault=garply';
7102 const result = [];
7103 for (let param of url.searchParams) {
7104 result.push(param.join(':'));
7105 }
7106 deepStrictEqual(result, ['quux:corge', 'grault:garply']);
7107 },
7108};
7109 
7110export const urlSegfaultRegression = {
7111 test() {
7112 let url = new URL('http://example.org/?foo=bar&baz=qux');
7113 // Setting certain properties would once zero out an internal reference count, causing a
7114 // nondeterministic crash during URL/URLSearchParams destruction. It triggered an assertion
7115 // under debug mode when the `searchParams` property was accessed, which this test is designed
7116 // to express.
7117 url.protocol = 'http:';
7118 strictEqual(url.searchParams.toString(), 'foo=bar&baz=qux');
7119 },
7120};
7121 
7122// ======================================================================================
7123 
7124export const urlPatternBasics = {
7125 test() {
7126 const urlPattern = new URLPattern();
7127 
7128 // The standard attributes exist as they should and are readonly
7129 strictEqual(urlPattern.protocol, '*');
7130 strictEqual(urlPattern.username, '*');
7131 strictEqual(urlPattern.password, '*');
7132 strictEqual(urlPattern.hostname, '*');
7133 strictEqual(urlPattern.port, '*');
7134 strictEqual(urlPattern.pathname, '*');
7135 strictEqual(urlPattern.search, '*');
7136 strictEqual(urlPattern.hash, '*');
7137 
7138 strictEqual(typeof urlPattern.exec, 'function');
7139 strictEqual(typeof urlPattern.test, 'function');
7140 
7141 {
7142 // URLPattern can be correctly subclassed.
7143 let count = 0;
7144 class MyURLPattern extends URLPattern {
7145 get protocol() {
7146 count++;
7147 return super.protocol;
7148 }
7149 get username() {
7150 count++;
7151 return super.username;
7152 }
7153 get password() {
7154 count++;
7155 return super.password;
7156 }
7157 get hostname() {
7158 count++;
7159 return super.hostname;
7160 }
7161 get port() {
7162 count++;
7163 return super.port;
7164 }
7165 get pathname() {
7166 count++;
7167 return super.pathname;
7168 }
7169 get search() {
7170 count++;
7171 return super.search;
7172 }
7173 get hash() {
7174 count++;
7175 return super.hash;
7176 }
7177 test() {
7178 return true;
7179 }
7180 exec() {
7181 return true;
7182 }
7183 }
7184 
7185 const myPattern = new MyURLPattern();
7186 strictEqual(myPattern.protocol, '*');
7187 strictEqual(myPattern.username, '*');
7188 strictEqual(myPattern.password, '*');
7189 strictEqual(myPattern.hostname, '*');
7190 strictEqual(myPattern.port, '*');
7191 strictEqual(myPattern.pathname, '*');
7192 strictEqual(myPattern.search, '*');
7193 strictEqual(myPattern.hash, '*');
7194 strictEqual(myPattern.exec(), true);
7195 strictEqual(myPattern.test(), true);
7196 strictEqual(count, 8);
7197 }
7198 },
7199};
7200 
7201export const urlParseStatic = {
7202 test() {
7203 const url = URL.parse('http://example.org');
7204 strictEqual(url.protocol, 'http:');
7205 strictEqual(url.host, 'example.org');
7206 
7207 const url2 = URL.parse('foo', 'http://example.org');
7208 strictEqual(url2.protocol, 'http:');
7209 strictEqual(url2.host, 'example.org');
7210 strictEqual(url2.pathname, '/foo');
7211 
7212 // Unlike `new URL(...)` the `URL.parse(...)` function does not throw on invalid URLs
7213 // (which is the key point)
7214 strictEqual(URL.parse('not valid'), null);
7215 },
7216};
7217 
7218export const urlSearchParamsPipe = {
7219 test() {
7220 const url = new URL('http://example.com/?a=b%7Cc');
7221 strictEqual(url.search, '?a=b%7Cc');
7222 strictEqual(url.searchParams.toString(), 'a=b%7Cc');
7223 },
7224};
7225 
7226export const urlPatternFun = {
7227 test() {
7228 const v3 = new Uint16Array(57578);
7229 const v4 = {};
7230 v4.username = v3;
7231 new URLPattern(v4);
7232 },
7233};
7234 
7235export const urlPatternExecWithNestedRegexGroups = {
7236 test() {
7237 // Regression test: a pattern whose value contains its own capturing groups
7238 // (e.g. a named group like (?<foo>x)) would cause an out-of-bounds access
7239 // in execRegex because the regex match array is larger than the nameList.
7240 // The unnamed regex group gets auto-named "0" by the URLPattern parser.
7241 const pattern = new URLPattern({ pathname: '/:a/((?<foo>x))' });
7242 const result = pattern.exec({ pathname: '/1/x' });
7243 strictEqual(result !== null, true);
7244 
7245 const groups = result.pathname.groups;
7246 strictEqual(groups.a, '1');
7247 strictEqual(groups['0'], 'x');
7248 // Should only have the two named parts from the URL pattern (not regex named groups).
7249 deepStrictEqual(Object.keys(groups), ['0', 'a']);
7250 },
7251};