OLD | NEW |
---|---|
(Empty) | |
1 <!doctype html> | |
2 <html> | |
3 <head> | |
4 <meta charset="utf8"> | |
5 <link rel="help" href="http://url.spec.whatwg.org/#dom-urlsearchparams-append"> | |
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(); | |
12 params.append('a', 'b'); | |
13 assert_equals(params + '', 'a=b'); | |
14 params.append('a', 'b'); | |
15 assert_equals(params + '', 'a=b&a=b'); | |
16 params.append('a', 'c'); | |
17 assert_equals(params + '', 'a=b&a=b&a=c'); | |
18 }, 'Append same name'); | |
19 | |
20 test(function() { | |
21 var params = new URLSearchParams(); | |
22 params.append('', ''); | |
23 assert_equals(params + '', '='); | |
24 params.append('', ''); | |
25 assert_equals(params + '', '=&='); | |
26 }, 'Append empty strings'); | |
27 | |
28 test(function() { | |
29 var params = new URLSearchParams(); | |
30 params.append(null, null); | |
31 assert_equals(params + '', 'null=null'); | |
32 params.append(null, null); | |
33 assert_equals(params + '', 'null=null&null=null'); | |
34 }, 'Append null'); | |
35 | |
36 test(function() { | |
37 var params = new URLSearchParams(); | |
38 params.append('first', 1); | |
39 params.append('second', 2); | |
40 params.append('third', ''); | |
41 params.append('first', 10); | |
42 assert_true(params.has('first'), 'Search params object has name "first"'); | |
43 assert_equals(params.get('first'), '1', 'Search params object has name "firs t" with value "1"'); | |
44 assert_equals(params.get('second'), '2', 'Search params object has name "sec ond" with value "2"'); | |
45 assert_equals(params.get('third'), '', 'Search params object has name "secon d" with value "2"'); | |
sof
2015/11/15 09:04:11
Not your doing, but copy & paste gone wrong - coul
Mike West
2015/11/16 08:57:57
Indeed!
| |
46 params.append('first', 10); | |
47 assert_equals(params.get('first'), '1', 'Search params object has name "firs t" with value "1"'); | |
48 }, 'Append multiple'); | |
49 </script> | |
50 </head> | |
51 </html> | |
OLD | NEW |