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-set"> |
| 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.set('a', 'B'); |
| 13 assert_equals(params + '', 'a=B&c=d'); |
| 14 params = new URLSearchParams('a=b&c=d&a=e'); |
| 15 params.set('a', 'B'); |
| 16 assert_equals(params + '', 'a=B&c=d') |
| 17 params.set('e', 'f'); |
| 18 assert_equals(params + '', 'a=B&c=d&e=f') |
| 19 }, 'set() basics'); |
| 20 |
| 21 test(function() { |
| 22 var params = new URLSearchParams('a=1&a=2&a=3'); |
| 23 assert_true(params.has('a'), 'Search params object has name "a"'); |
| 24 assert_equals(params.get('a'), '1', 'Search params object has name "a" with
value "1"'); |
| 25 params.set('first', 4); |
| 26 assert_true(params.has('a'), 'Search params object has name "a"'); |
| 27 assert_equals(params.get('a'), '1', 'Search params object has name "a" with
value "1"'); |
| 28 assert_equals(params + '', 'a=1&a=2&a=3&first=4'); |
| 29 params.set('a', 4); |
| 30 assert_true(params.has('a'), 'Search params object has name "a"'); |
| 31 assert_equals(params.get('a'), '4', 'Search params object has name "a" with
value "4"'); |
| 32 assert_equals(params + '', 'a=4&first=4'); |
| 33 }, 'set() replaces multiple values'); |
| 34 </script> |
| 35 </head> |
| 36 </html> |
| 37 |
OLD | NEW |