@@ -501,163 +501,10 @@ const ValueIterable = iterator.Iterable(kv.ValueIterator, "URLSearchParamsValueI
501501const EntryIterable = iterator .Iterable (kv .EntryIterator , "URLSearchParamsEntryIterator" );
502502
503503const testing = @import ("../../testing.zig" );
504- test "Browser.URL" {
505- var runner = try testing .jsRunner (testing .tracking_allocator , .{});
506- defer runner .deinit ();
507-
508- try runner .testCases (&.{
509- .{ "var url = new URL('https://foo.bar/path?query#fragment')" , "undefined" },
510- .{ "url.origin" , "https://foo.bar" },
511- .{ "url.href" , "https://foo.bar/path?query#fragment" },
512- .{ "url.protocol" , "https:" },
513- .{ "url.username" , "" },
514- .{ "url.password" , "" },
515- .{ "url.host" , "foo.bar" },
516- .{ "url.hostname" , "foo.bar" },
517- .{ "url.port" , "" },
518- .{ "url.pathname" , "/path" },
519- .{ "url.search" , "?query" },
520- .{ "url.hash" , "#fragment" },
521- .{ "url.searchParams.get('query')" , "" },
522-
523- .{ "url.search = 'hello=world'" , null },
524- .{ "url.searchParams.size" , "1" },
525- .{ "url.searchParams.get('hello')" , "world" },
526-
527- .{ "url.search = '?over=9000'" , null },
528- .{ "url.searchParams.size" , "1" },
529- .{ "url.searchParams.get('over')" , "9000" },
530-
531- .{ "url.search = ''" , null },
532- .{ "url.searchParams.size" , "0" },
533-
534- .{ " const url2 = new URL(url);" , null },
535- .{ "url2.href" , "https://foo.bar/path#fragment" },
536-
537- .{ " try { new URL(document.createElement('a')); } catch (e) { e }" , "TypeError: invalid argument" },
538-
539- .{ " let a = document.createElement('a');" , null },
540- .{ " a.href = 'https://www.lightpanda.io/over?9000=!!';" , null },
541- .{ " const url3 = new URL(a);" , null },
542- .{ "url3.href" , "https://www.lightpanda.io/over?9000=%21%21" },
543- }, .{});
544-
545- try runner .testCases (&.{
546- .{ "var url = new URL('https://foo.bar/path?a=~&b=%7E#fragment')" , "undefined" },
547- .{ "url.searchParams.get('a')" , "~" },
548- .{ "url.searchParams.get('b')" , "~" },
549- .{ "url.searchParams.append('c', 'foo')" , "undefined" },
550- .{ "url.searchParams.get('c')" , "foo" },
551- .{ "url.searchParams.getAll('c').length" , "1" },
552- .{ "url.searchParams.getAll('c')[0]" , "foo" },
553- .{ "url.searchParams.size" , "3" },
554-
555- // search is dynamic
556- .{ "url.search" , "?a=~&b=~&c=foo" },
557- // href is dynamic
558- .{ "url.href" , "https://foo.bar/path?a=~&b=~&c=foo#fragment" },
559-
560- .{ "url.searchParams.delete('c', 'foo')" , "undefined" },
561- .{ "url.searchParams.get('c')" , "null" },
562- .{ "url.searchParams.delete('a')" , "undefined" },
563- .{ "url.searchParams.get('a')" , "null" },
564- }, .{});
565-
566- try runner .testCases (&.{
567- .{ "var url = new URL('over?9000', 'https://lightpanda.io')" , null },
568- .{ "url.href" , "https://lightpanda.io/over?9000" },
569- }, .{});
570-
571- try runner .testCases (&.{
572- .{ "let sk = new URL('sveltekit-internal://')" , null },
573- .{ "sk.protocol" , "sveltekit-internal:" },
574- .{ "sk.host" , "" },
575- .{ "sk.hostname" , "" },
576- .{ "sk.href" , "sveltekit-internal://" },
577- }, .{});
504+ test "Browser: URL" {
505+ try testing .htmlRunner ("url/url.html" );
578506}
579507
580- test "Browser.URLSearchParams" {
581- var runner = try testing .jsRunner (testing .tracking_allocator , .{});
582- defer runner .deinit ();
583- try runner .testCases (&.{
584- .{ "let usp = new URLSearchParams()" , null },
585- .{ "usp.get('a')" , "null" },
586- .{ "usp.has('a')" , "false" },
587- .{ "usp.getAll('a')" , "" },
588- .{ "usp.delete('a')" , "undefined" },
589-
590- .{ "usp.set('a', 1)" , "undefined" },
591- .{ "usp.has('a')" , "true" },
592- .{ "usp.get('a')" , "1" },
593- .{ "usp.getAll('a')" , "1" },
594-
595- .{ "usp.append('a', 2)" , "undefined" },
596- .{ "usp.has('a')" , "true" },
597- .{ "usp.get('a')" , "1" },
598- .{ "usp.getAll('a')" , "1,2" },
599-
600- .{ "usp.append('b', '3')" , "undefined" },
601- .{ "usp.has('a')" , "true" },
602- .{ "usp.get('a')" , "1" },
603- .{ "usp.getAll('a')" , "1,2" },
604- .{ "usp.has('b')" , "true" },
605- .{ "usp.get('b')" , "3" },
606- .{ "usp.getAll('b')" , "3" },
607-
608- .{ "let acc = [];" , null },
609- .{ "for (const key of usp.keys()) { acc.push(key) }; acc;" , "a,a,b" },
610-
611- .{ "acc = [];" , null },
612- .{ "for (const value of usp.values()) { acc.push(value) }; acc;" , "1,2,3" },
613-
614- .{ "acc = [];" , null },
615- .{ "for (const entry of usp.entries()) { acc.push(entry) }; acc;" , "a,1,a,2,b,3" },
616-
617- .{ "acc = [];" , null },
618- .{ "for (const entry of usp) { acc.push(entry) }; acc;" , "a,1,a,2,b,3" },
619-
620- .{ "usp.delete('a')" , "undefined" },
621- .{ "usp.has('a')" , "false" },
622- .{ "usp.has('b')" , "true" },
623-
624- .{ "acc = [];" , null },
625- .{ "for (const key of usp.keys()) { acc.push(key) }; acc;" , "b" },
626-
627- .{ "acc = [];" , null },
628- .{ "for (const value of usp.values()) { acc.push(value) }; acc;" , "3" },
629-
630- .{ "acc = [];" , null },
631- .{ "for (const entry of usp.entries()) { acc.push(entry) }; acc;" , "b,3" },
632-
633- .{ "acc = [];" , null },
634- .{ "for (const entry of usp) { acc.push(entry) }; acc;" , "b,3" },
635- }, .{});
636-
637- try runner .testCases (&.{
638- .{ "usp = new URLSearchParams('?hello')" , null },
639- .{ "usp.get('hello')" , "" },
640-
641- .{ "usp = new URLSearchParams('?abc=')" , null },
642- .{ "usp.get('abc')" , "" },
643-
644- .{ "usp = new URLSearchParams('?abc=123&')" , null },
645- .{ "usp.get('abc')" , "123" },
646- .{ "usp.size" , "1" },
647-
648- .{ "var fd = new FormData()" , null },
649- .{ "fd.append('a', '1')" , null },
650- .{ "fd.append('a', '2')" , null },
651- .{ "fd.append('b', '3')" , null },
652- .{ "ups = new URLSearchParams(fd)" , null },
653- .{ "ups.size" , "3" },
654- .{ "ups.getAll('a')" , "1,2" },
655- .{ "ups.getAll('b')" , "3" },
656- .{ "fd.delete('a')" , null }, // the two aren't linked, it created a copy
657- .{ "ups.size" , "3" },
658- .{ "ups = new URLSearchParams({over: 9000, spice: 'flow'})" , null },
659- .{ "ups.size" , "2" },
660- .{ "ups.getAll('over')" , "9000" },
661- .{ "ups.getAll('spice')" , "flow" },
662- }, .{});
508+ test "Browser: URLSearchParams" {
509+ try testing .htmlRunner ("url/url_search_params.html" );
663510}
0 commit comments