OLD | NEW |
1 <!DOCTYPE HTML> | 1 <!DOCTYPE HTML> |
2 <link rel="help" href="http://url.spec.whatwg.org/#dom-url-search"> | 2 <link rel="help" href="http://url.spec.whatwg.org/#dom-url-search"> |
3 <script src="../../resources/testharness.js"></script> | 3 <script src="../../resources/testharness.js"></script> |
4 <script src="../../resources/testharnessreport.js"></script> | 4 <script src="../../resources/testharnessreport.js"></script> |
5 <script> | 5 <script> |
6 | |
7 test(function() { | 6 test(function() { |
8 var url = new URL('http://www.domain.com/'); | 7 var url = new URL('http://www.domain.com/'); |
9 assert_equals(url.search, ''); | 8 assert_equals(url.search, ''); |
10 | 9 |
11 url = new URL('http://www.domain.com/?'); | 10 url = new URL('http://www.domain.com/?'); |
12 assert_equals(url.search, ''); | 11 assert_equals(url.search, ''); |
13 | 12 |
14 url = new URL('http://www.domain.com/?a'); | 13 url = new URL('http://www.domain.com/?a'); |
15 assert_equals(url.search, '?a'); | 14 assert_equals(url.search, '?a'); |
16 | 15 |
(...skipping 27 matching lines...) Expand all Loading... |
44 test(function() { | 43 test(function() { |
45 var url = new URL('http://abc.de:8080/path/file?query#fragment'); | 44 var url = new URL('http://abc.de:8080/path/file?query#fragment'); |
46 url.href = 'invalid'; | 45 url.href = 'invalid'; |
47 assert_equals(url.search, ''); | 46 assert_equals(url.search, ''); |
48 | 47 |
49 url.search = 'changed'; | 48 url.search = 'changed'; |
50 assert_equals(url.search, ''); | 49 assert_equals(url.search, ''); |
51 assert_equals(url.href, 'invalid'); | 50 assert_equals(url.href, 'invalid'); |
52 }, 'search property invalid URL'); | 51 }, 'search property invalid URL'); |
53 | 52 |
| 53 test(function() { |
| 54 var url = new URL('http://example.org/file?a=b&c=d'); |
| 55 var searchParams = url.searchParams; |
| 56 assert_true(searchParams != null); |
| 57 assert_equals(searchParams.toString(), "a=b&c=d"); |
| 58 |
| 59 url.search = 'e=f&g=h'; |
| 60 assert_equals(searchParams.toString(), "e=f&g=h"); |
| 61 |
| 62 searchParams.append('i', ' j '); |
| 63 assert_equals(url.search, "?e=f&g=h&i=+j+"); |
| 64 |
| 65 searchParams.set('e', 'updated'); |
| 66 assert_equals(url.search, "?e=updated&g=h&i=+j+"); |
| 67 |
| 68 assert_throws({name: "TypeError"}, function() { url.searchParams = {}; }); |
| 69 |
| 70 }, 'search and searchParams'); |
54 </script> | 71 </script> |
OLD | NEW |