Andrew Top | 61a8495 | 2019-04-30 15:07:33 -0700 | [diff] [blame] | 1 | <!doctype html> |
| 2 | <html> |
| 3 | <head> |
| 4 | <meta charset="utf8"> |
| 5 | <link rel="help" href="http://url.spec.whatwg.org/#dom-urlsearchparams-get"> |
| 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 | assert_equals(params.get('a'), 'b'); |
| 13 | assert_equals(params.get('c'), 'd'); |
| 14 | assert_equals(params.get('e'), null); |
| 15 | params = new URLSearchParams('a=b&c=d&a=e'); |
| 16 | assert_equals(params.get('a'), 'b'); |
| 17 | params = new URLSearchParams('=b&c=d'); |
| 18 | assert_equals(params.get(''), 'b'); |
| 19 | params = new URLSearchParams('a=&c=d&a=e'); |
| 20 | assert_equals(params.get('a'), ''); |
| 21 | }, 'Get basics'); |
| 22 | |
| 23 | test(function() { |
| 24 | var params = new URLSearchParams('first=second&third&&'); |
| 25 | assert_true(params != null, 'constructor returned non-null value.'); |
| 26 | assert_true(params.has('first'), 'Search params object has name "first"'); |
| 27 | assert_equals(params.get('first'), 'second', 'Search params object has name "first" with value "second"'); |
| 28 | assert_equals(params.get('third'), '', 'Search params object has name "third" with the empty value.'); |
| 29 | assert_equals(params.get('fourth'), null, 'Search params object has no "fourth" name and value.'); |
| 30 | }, 'More get() basics'); |
| 31 | </script> |
| 32 | </head> |
| 33 | </html> |