Skip to content

Commit

Permalink
Bug 1831582 [wpt PR 39865] - URLSearchParams: add tests for two-argum…
Browse files Browse the repository at this point in the history
…ent delete() and has(), a=testonly

Automatic update from web-platform-tests
URLSearchParams: add tests for two-argument delete() and has()

For whatwg/url#735.
--

wpt-commits: c4726447f3bad1c71244fb99c98738ff0354a034
wpt-pr: 39865
  • Loading branch information
annevk authored and moz-wptsync-bot committed May 21, 2023
1 parent 8a8c460 commit 2dcbb59
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
9 changes: 9 additions & 0 deletions testing/web-platform/tests/url/urlsearchparams-delete.any.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,12 @@ test(() => {
assert_equals(url.pathname, 'space ');
assert_equals(url.href, 'data:space #test');
}, 'Changing the query of a URL with an opaque path can impact the path if the URL has no fragment');

test(() => {
const params = new URLSearchParams();
params.append('a', 'b');
params.append('a', 'c');
params.append('a', 'd');
params.delete('a', 'c');
assert_equals(params.toString(), 'a=b&a=d');
}, "Two-argument delete()");
13 changes: 13 additions & 0 deletions testing/web-platform/tests/url/urlsearchparams-has.any.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,16 @@ test(function() {
params.delete('first');
assert_false(params.has('first'), 'Search params object has no name "first"');
}, 'has() following delete()');

test(() => {
const params = new URLSearchParams("a=b&a=d&c&e&");
assert_true(params.has('a', 'b'));
assert_false(params.has('a', 'c'));
assert_true(params.has('a', 'd'));
assert_true(params.has('e', ''));
params.append('first', null);
assert_false(params.has('first', ''));
assert_true(params.has('first', 'null'));
params.delete('a', 'b');
assert_true(params.has('a', 'd'));
}, "Two-argument has()");

0 comments on commit 2dcbb59

Please sign in to comment.