Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

URL: URLSearchParams's size #38655

Merged
merged 1 commit into from
Feb 23, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions url/urlsearchparams-size.any.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
test(() => {
const params = new URLSearchParams("a=1&b=2&a=3");
assert_equals(params.size, 3);

params.delete("a");
assert_equals(params.size, 1);
}, "URLSearchParams's size and deletion");

test(() => {
const params = new URLSearchParams("a=1&b=2&a=3");
assert_equals(params.size, 3);

params.append("b", "4");
assert_equals(params.size, 4);
}, "URLSearchParams's size and addition");

test(() => {
const url = new URL("http://localhost/query?a=1&b=2&a=3");
assert_equals(url.searchParams.size, 3);

params.delete("a");
assert_equals(url.searchParams.size, 1);

params.append("b", 4);
assert_equals(url.searchParams.size, 2);
}, "URLSearchParams's size when obtained from a URL");

test(() => {
const url = new URL("http://localhost/query?a=1&b=2&a=3");
assert_equals(url.searchParams.size, 3);

url.search = "?";
assert_equals(url.searchParams.size, 0);
}, "URLSearchParams's size when obtained from a URL and using .search");