OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE html> |
| 2 <link rel="help" href="http://url.spec.whatwg.org/#dom-urlsearchparams-get"> |
| 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 assert_equals(params.get('a'), 'b'); |
| 9 assert_equals(params.get('c'), 'd'); |
| 10 assert_equals(params.get('e'), null); |
| 11 params = new URLSearchParams('a=b&c=d&a=e'); |
| 12 assert_equals(params.get('a'), 'b'); |
| 13 params = new URLSearchParams('=b&c=d'); |
| 14 assert_equals(params.get(''), 'b'); |
| 15 params = new URLSearchParams('a=&c=d&a=e'); |
| 16 assert_equals(params.get('a'), ''); |
| 17 }, 'Get basics'); |
| 18 |
| 19 test(function() { |
| 20 var params = new URLSearchParams('first=second&third&&'); |
| 21 assert_true(params != null, 'constructor returned non-null value.'); |
| 22 assert_true(params.has('first'), 'Search params object has name "first"'); |
| 23 assert_equals(params.get('first'), 'second', 'Search params object has name
"first" with value "second"'); |
| 24 assert_equals(params.get('third'), '', 'Search params object has name "third
" with the empty value.'); |
| 25 assert_equals(params.get('fourth'), null, 'Search params object has no "four
th" name and value.'); |
| 26 }, 'More get() basics'); |
| 27 </script> |
OLD | NEW |