@@ -8,7 +8,7 @@ const { test, assert_equals, assert_true, assert_false } =
8
8
9
9
/* The following tests are copied from WPT. Modifications to them should be
10
10
upstreamed first. Refs:
11
- https://github.com/w3c/web-platform-tests/blob/8791bed /url/urlsearchparams-delete.html
11
+ https://github.com/w3c/web-platform-tests/blob/70a0898763 /url/urlsearchparams-delete.html
12
12
License: http://www.w3.org/Consortium/Legal/2008/04-testsuite-copyright.html
13
13
*/
14
14
/* eslint-disable */
@@ -42,6 +42,21 @@ test(function() {
42
42
params . delete ( 'first' ) ;
43
43
assert_false ( params . has ( 'first' ) , 'Search params object has no "first" name' ) ;
44
44
} , 'Deleting appended multiple' ) ;
45
+
46
+ test ( function ( ) {
47
+ var url = new URL ( 'http://example.com/?param1¶m2' ) ;
48
+ url . searchParams . delete ( 'param1' ) ;
49
+ url . searchParams . delete ( 'param2' ) ;
50
+ assert_equals ( url . href , 'http://example.com/' , 'url.href does not have ?' ) ;
51
+ assert_equals ( url . search , '' , 'url.search does not have ?' ) ;
52
+ } , 'Deleting all params removes ? from URL' ) ;
53
+
54
+ test ( function ( ) {
55
+ var url = new URL ( 'http://example.com/?' ) ;
56
+ url . searchParams . delete ( 'param1' ) ;
57
+ assert_equals ( url . href , 'http://example.com/' , 'url.href does not have ?' ) ;
58
+ assert_equals ( url . search , '' , 'url.search does not have ?' ) ;
59
+ } , 'Removing non-existent param removes ? from URL' ) ;
45
60
/* eslint-enable */
46
61
47
62
// Tests below are not from WPT.
0 commit comments