OLD | NEW |
---|---|
1 <!doctype html> | 1 <!doctype html> |
2 <html> | 2 <html> |
3 <head> | 3 <head> |
4 <meta charset="utf8"> | 4 <meta charset="utf8"> |
5 <link rel="help" href="https://url.spec.whatwg.org/#urlsearchparams"> | 5 <link rel="help" href="https://url.spec.whatwg.org/#urlsearchparams"> |
6 <script src="../../resources/testharness.js"></script> | 6 <script src="../../resources/testharness.js"></script> |
7 <script src="../../resources/testharnessreport.js"></script> | 7 <script src="../../resources/testharnessreport.js"></script> |
8 <script src="resources/testharness-extras.js"></script> | 8 <script src="resources/testharness-extras.js"></script> |
9 <script> | 9 <script> |
10 function assert_type_error(f, msg) { | 10 function assert_type_error(f, msg) { |
(...skipping 15 matching lines...) Expand all Loading... | |
26 | 26 |
27 test(function() { | 27 test(function() { |
28 var params = new URLSearchParams(); | 28 var params = new URLSearchParams(); |
29 assert_equals(params + '', ''); | 29 assert_equals(params + '', ''); |
30 params = new URLSearchParams(''); | 30 params = new URLSearchParams(''); |
31 assert_equals(params + '', ''); | 31 assert_equals(params + '', ''); |
32 params = new URLSearchParams('a=b'); | 32 params = new URLSearchParams('a=b'); |
33 assert_equals(params + '', 'a=b'); | 33 assert_equals(params + '', 'a=b'); |
34 params = new URLSearchParams(params); | 34 params = new URLSearchParams(params); |
35 assert_equals(params + '', 'a=b'); | 35 assert_equals(params + '', 'a=b'); |
36 | |
37 // Leading '?' should be ignored. | |
38 params = new URLSearchParams('?a=b'); | |
39 assert_equals(params + '', 'a=b'); | |
40 | |
41 // Encoding '?' aligns with Firefox, spec doesn't insist it is encoded. | |
philipj_slow
2016/04/21 13:13:50
'?' is 0x3F and I end up in https://url.spec.whatw
sof
2016/04/21 13:19:10
You want to consider parsing first, I think -- htt
philipj_slow
2016/04/21 13:38:07
Starting at the URLSearchParams constructor I end
| |
42 params = new URLSearchParams('??a=b'); | |
43 assert_equals(params + '', '%3Fa=b'); | |
44 params = new URLSearchParams('?'); | |
45 assert_equals(params + '', ''); | |
46 params = new URLSearchParams('??'); | |
47 assert_equals(params + '', '%3F='); | |
36 }, 'Basic URLSearchParams construction'); | 48 }, 'Basic URLSearchParams construction'); |
37 | 49 |
38 test(function() { | 50 test(function() { |
39 assert_type_error(function () { URLSearchParams(); }, 'Failed to construct \ 'URLSearchParams\': Please use the \'new\' operator, this DOM object constructor cannot be called as a function.'); | 51 assert_type_error(function () { URLSearchParams(); }, 'Failed to construct \ 'URLSearchParams\': Please use the \'new\' operator, this DOM object constructor cannot be called as a function.'); |
40 | 52 |
41 var params = new URLSearchParams(''); | 53 var params = new URLSearchParams(''); |
42 assert_not_equals(params, null, 'constructor returned non-null value.'); | 54 assert_not_equals(params, null, 'constructor returned non-null value.'); |
43 assert_equals(params.__proto__, URLSearchParams.prototype, 'expected URLSear chParams.prototype as prototype.'); | 55 assert_equals(params.__proto__, URLSearchParams.prototype, 'expected URLSear chParams.prototype as prototype.'); |
44 params = new URLSearchParams({}); | 56 params = new URLSearchParams({}); |
45 assert_equals(params + '', '%5Bobject+Object%5D='); | 57 assert_equals(params + '', '%5Bobject+Object%5D='); |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
154 assert_equals(params.toString(), '='); | 166 assert_equals(params.toString(), '='); |
155 }, 'Parse ='); | 167 }, 'Parse ='); |
156 | 168 |
157 test(function() { | 169 test(function() { |
158 var params = new URLSearchParams('foobar=a\nb'); | 170 var params = new URLSearchParams('foobar=a\nb'); |
159 assert_equals(params.toString(), 'foobar=a%0Ab'); | 171 assert_equals(params.toString(), 'foobar=a%0Ab'); |
160 }, 'Parse \\n'); | 172 }, 'Parse \\n'); |
161 </script> | 173 </script> |
162 </head> | 174 </head> |
163 </html> | 175 </html> |
OLD | NEW |