OLD | NEW |
(Empty) | |
| 1 <!doctype html> |
| 2 <html> |
| 3 <head> |
| 4 <meta charset="utf8"> |
| 5 <link rel="help" href="http://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 params.set('a', 4); |
| 29 assert_true(params.has('a'), 'Search params object has name "a"'); |
| 30 assert_equals(params.get('a'), '4', 'Search params object has name "a" with
value "4"'); |
| 31 }, 'URLSearchParams.set'); |
| 32 </script> |
| 33 </head> |
| 34 </html> |
| 35 |
OLD | NEW |