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 |
17 url.search = ''; | 16 url.search = ''; |
18 assert_equals(url.search, ''); | 17 assert_equals(url.search, ''); |
19 | 18 |
20 url.search = '?'; | 19 url.search = '?'; |
21 assert_equals(url.search, ''); | 20 assert_equals(url.search, ''); |
22 | 21 |
23 url.search = 'a'; | 22 url.search = 'a'; |
24 assert_equals(url.search, '?a'); | 23 assert_equals(url.search, '?a'); |
25 | 24 |
26 url.search = '?a'; | 25 url.search = '?b'; |
27 assert_equals(url.search, '?a'); | 26 assert_equals(url.search, '?b'); |
28 | 27 |
29 url.search = 'a#b'; | 28 url.search = 'a#b'; |
30 assert_equals(url.search, '?a%23b'); | 29 assert_equals(url.search, '?a%23b'); |
31 | 30 |
32 url.search = 'a?b'; | 31 url.search = 'a?b'; |
33 assert_equals(url.search, '?a?b'); | 32 assert_equals(url.search, '?a?b'); |
34 }, 'Basic search'); | 33 }, 'Basic search'); |
35 | 34 |
36 test(function() { | 35 test(function() { |
37 var url = new URL('mailto:foo@bar.com'); | 36 var url = new URL('mailto:foo@bar.com'); |
38 assert_equals(url.search, ''); | 37 assert_equals(url.search, ''); |
39 | 38 |
40 url.search = 'a'; | 39 url.search = 'a'; |
41 assert_equals(url.search, '?a'); | 40 assert_equals(url.search, '?a'); |
42 }, 'non hierarchical'); | 41 }, 'non hierarchical'); |
43 | 42 |
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 | |
54 </script> | 52 </script> |
OLD | NEW |