Skip to content

Commit c6a0368

Browse files
committed
add a searchParamsSetHref test according to href setter change
1 parent 033eb82 commit c6a0368

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

src/tests/url/url.html

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,23 @@
6464
testing.expectEqual(null, url.searchParams.get('a'));
6565
</script>
6666

67+
<script id=searchParamsSetHref>
68+
url = new URL("https://foo.bar");
69+
const searchParams = url.searchParams;
70+
71+
// SearchParams should be empty.
72+
testing.expectEqual(0, searchParams.size);
73+
74+
url.href = "https://lightpanda.io?over=9000&light=panda";
75+
// It won't hurt to check href and host too.
76+
testing.expectEqual("https://lightpanda.io/?over=9000&light=panda", url.href);
77+
testing.expectEqual("lightpanda.io", url.host);
78+
// SearchParams should be updated too when URL is set.
79+
testing.expectEqual(2, searchParams.size);
80+
testing.expectEqual("9000", searchParams.get("over"));
81+
testing.expectEqual("panda", searchParams.get("light"));
82+
</script>
83+
6784
<script id=base>
6885
url = new URL('over?9000', 'https://lightpanda.io');
6986
testing.expectEqual("https://lightpanda.io/over?9000", url.href);

0 commit comments

Comments
 (0)