diff --git a/ext/url/00_url.js b/ext/url/00_url.js index 2a238eae16e986..65cde2ce27e376 100644 --- a/ext/url/00_url.js +++ b/ext/url/00_url.js @@ -169,19 +169,31 @@ class URLSearchParams { /** * @param {string} name + * @param {string} [value] */ - delete(name) { + delete(name, value = undefined) { webidl.assertBranded(this, URLSearchParamsPrototype); const prefix = "Failed to execute 'append' on 'URLSearchParams'"; webidl.requiredArguments(arguments.length, 1, prefix); name = webidl.converters.USVString(name, prefix, "Argument 1"); const list = this[_list]; let i = 0; - while (i < list.length) { - if (list[i][0] === name) { - ArrayPrototypeSplice(list, i, 1); - } else { - i++; + if (value === undefined) { + while (i < list.length) { + if (list[i][0] === name) { + ArrayPrototypeSplice(list, i, 1); + } else { + i++; + } + } + } else { + value = webidl.converters.USVString(value, prefix, "Argument 2"); + while (i < list.length) { + if (list[i][0] === name && list[i][1] === value) { + ArrayPrototypeSplice(list, i, 1); + } else { + i++; + } } } this.#updateUrlSearch(); @@ -228,13 +240,21 @@ class URLSearchParams { /** * @param {string} name + * @param {string} [value] * @return {boolean} */ - has(name) { + has(name, value = undefined) { webidl.assertBranded(this, URLSearchParamsPrototype); const prefix = "Failed to execute 'has' on 'URLSearchParams'"; webidl.requiredArguments(arguments.length, 1, prefix); name = webidl.converters.USVString(name, prefix, "Argument 1"); + if (value !== undefined) { + value = webidl.converters.USVString(value, prefix, "Argument 2"); + return ArrayPrototypeSome( + this[_list], + (entry) => entry[0] === name && entry[1] === value, + ); + } return ArrayPrototypeSome(this[_list], (entry) => entry[0] === name); } diff --git a/tools/wpt/expectation.json b/tools/wpt/expectation.json index 535372179351d3..908c9498eed370 100644 --- a/tools/wpt/expectation.json +++ b/tools/wpt/expectation.json @@ -3205,12 +3205,10 @@ "urlsearchparams-constructor.any.html": true, "urlsearchparams-constructor.any.worker.html": true, "urlsearchparams-delete.any.html": [ - "Changing the query of a URL with an opaque path can impact the path", - "Two-argument delete()" + "Changing the query of a URL with an opaque path can impact the path" ], "urlsearchparams-delete.any.worker.html": [ - "Changing the query of a URL with an opaque path can impact the path", - "Two-argument delete()" + "Changing the query of a URL with an opaque path can impact the path" ], "urlsearchparams-foreach.any.html": true, "urlsearchparams-foreach.any.worker.html": true, @@ -3218,12 +3216,8 @@ "urlsearchparams-get.any.worker.html": true, "urlsearchparams-getall.any.html": true, "urlsearchparams-getall.any.worker.html": true, - "urlsearchparams-has.any.html": [ - "Two-argument has()" - ], - "urlsearchparams-has.any.worker.html": [ - "Two-argument has()" - ], + "urlsearchparams-has.any.html": true, + "urlsearchparams-has.any.worker.html": true, "urlsearchparams-set.any.html": true, "urlsearchparams-set.any.worker.html": true, "urlsearchparams-size.any.html": true,