11cb0ef41Sopenharmony_ci'use strict';
21cb0ef41Sopenharmony_ci
31cb0ef41Sopenharmony_ci// Tests below are not from WPT.
41cb0ef41Sopenharmony_ci
51cb0ef41Sopenharmony_cirequire('../common');
61cb0ef41Sopenharmony_ciconst assert = require('assert');
71cb0ef41Sopenharmony_ci
81cb0ef41Sopenharmony_ci{
91cb0ef41Sopenharmony_ci  const params = new URLSearchParams();
101cb0ef41Sopenharmony_ci  assert.throws(() => {
111cb0ef41Sopenharmony_ci    params.delete.call(undefined);
121cb0ef41Sopenharmony_ci  }, {
131cb0ef41Sopenharmony_ci    code: 'ERR_INVALID_THIS',
141cb0ef41Sopenharmony_ci    name: 'TypeError',
151cb0ef41Sopenharmony_ci    message: 'Value of "this" must be of type URLSearchParams'
161cb0ef41Sopenharmony_ci  });
171cb0ef41Sopenharmony_ci  assert.throws(() => {
181cb0ef41Sopenharmony_ci    params.delete();
191cb0ef41Sopenharmony_ci  }, {
201cb0ef41Sopenharmony_ci    code: 'ERR_MISSING_ARGS',
211cb0ef41Sopenharmony_ci    name: 'TypeError',
221cb0ef41Sopenharmony_ci    message: 'The "name" argument must be specified'
231cb0ef41Sopenharmony_ci  });
241cb0ef41Sopenharmony_ci
251cb0ef41Sopenharmony_ci  const obj = {
261cb0ef41Sopenharmony_ci    toString() { throw new Error('toString'); },
271cb0ef41Sopenharmony_ci    valueOf() { throw new Error('valueOf'); }
281cb0ef41Sopenharmony_ci  };
291cb0ef41Sopenharmony_ci  const sym = Symbol();
301cb0ef41Sopenharmony_ci  assert.throws(() => params.delete(obj), /^Error: toString$/);
311cb0ef41Sopenharmony_ci  assert.throws(() => params.delete(sym),
321cb0ef41Sopenharmony_ci                /^TypeError: Cannot convert a Symbol value to a string$/);
331cb0ef41Sopenharmony_ci}
341cb0ef41Sopenharmony_ci
351cb0ef41Sopenharmony_ci// https://github.com/nodejs/node/issues/10480
361cb0ef41Sopenharmony_ci// Emptying searchParams should correctly update url's query
371cb0ef41Sopenharmony_ci{
381cb0ef41Sopenharmony_ci  const url = new URL('http://domain?var=1&var=2&var=3');
391cb0ef41Sopenharmony_ci  for (const param of url.searchParams.keys()) {
401cb0ef41Sopenharmony_ci    url.searchParams.delete(param);
411cb0ef41Sopenharmony_ci  }
421cb0ef41Sopenharmony_ci  assert.strictEqual(url.searchParams.toString(), '');
431cb0ef41Sopenharmony_ci  assert.strictEqual(url.search, '');
441cb0ef41Sopenharmony_ci  assert.strictEqual(url.href, 'http://domain/');
451cb0ef41Sopenharmony_ci}
46