OLD | NEW |
(Empty) | |
| 1 <!doctype html> |
| 2 <html> |
| 3 <head> |
| 4 <meta charset="utf8"> |
| 5 <link rel="help" href="https://url.spec.whatwg.org/#dom-urlsearchparams-delete"> |
| 6 <script src="../../resources/testharness.js"></script> |
| 7 <script src="../../resources/testharnessreport.js"></script> |
| 8 <script src="resources/testharness-extras.js"></script> |
| 9 <script> |
| 10 test(function() { |
| 11 var params = new URLSearchParams('a=b&c=d'); |
| 12 params.delete('a'); |
| 13 assert_equals(params + '', 'c=d'); |
| 14 params = new URLSearchParams('a=a&b=b&a=a&c=c'); |
| 15 params.delete('a'); |
| 16 assert_equals(params + '', 'b=b&c=c'); |
| 17 params = new URLSearchParams('a=a&=&b=b&c=c'); |
| 18 params.delete(''); |
| 19 assert_equals(params + '', 'a=a&b=b&c=c'); |
| 20 params = new URLSearchParams('a=a&null=null&b=b'); |
| 21 params.delete(null); |
| 22 assert_equals(params + '', 'a=a&b=b'); |
| 23 params = new URLSearchParams('a=a&undefined=undefined&b=b'); |
| 24 params.delete(undefined); |
| 25 assert_equals(params + '', 'a=a&b=b'); |
| 26 }, 'Delete basics'); |
| 27 |
| 28 test(function() { |
| 29 var params = new URLSearchParams(); |
| 30 params.append('first', 1); |
| 31 assert_true(params.has('first'), 'Search params object has name "first"'); |
| 32 assert_equals(params.get('first'), '1', 'Search params object has name "firs
t" with value "1"'); |
| 33 params.delete('first'); |
| 34 assert_false(params.has('first'), 'Search params object has no "first" name'
); |
| 35 params.append('first', 1); |
| 36 params.append('first', 10); |
| 37 params.delete('first'); |
| 38 assert_false(params.has('first'), 'Search params object has no "first" name'
); |
| 39 }, 'Deleting appended multiple'); |
| 40 </script> |
| 41 </head> |
| 42 </html> |
OLD | NEW |