OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE html> |
| 2 <link rel="help" href="http://url.spec.whatwg.org/#interface-urlsearchparams-set
"> |
| 3 <script src="../../resources/testharness.js"></script> |
| 4 <script src="../../resources/testharnessreport.js"></script> |
| 5 <script> |
| 6 test(function() { |
| 7 var params = new URLSearchParams("a=b&c=d"); |
| 8 params.set("a", "B"); |
| 9 assert_equals(params + "", "a=B&c=d"); |
| 10 params = new URLSearchParams("a=b&c=d&a=e"); |
| 11 params.set("a", "B"); |
| 12 assert_equals(params + "", "a=B&c=d") |
| 13 params.set("e", "f"); |
| 14 assert_equals(params + "", "a=B&c=d&e=f") |
| 15 }, "Set basics"); |
| 16 |
| 17 test(function() { |
| 18 var params = new URLSearchParams("a=1&a=2&a=3"); |
| 19 assert_true(params.has("a"), "Search params object has name 'a'"); |
| 20 assert_equals(params.get("a"), "1", "Search params object has name 'a' with
value '1'"); |
| 21 params.set("first", 4); |
| 22 assert_true(params.has("a"), "Search params object has name 'a'"); |
| 23 assert_equals(params.get("a"), "1", "Search params object has name 'a' with
value '1'"); |
| 24 params.set("a", 4); |
| 25 assert_true(params.has("a"), "Search params object has name 'a'"); |
| 26 assert_equals(params.get("a"), "4", "Search params object has name 'a' with
value '4'"); |
| 27 }, "URLSearchParams.set"); |
| 28 </script> |
OLD | NEW |