Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(325)

Side by Side Diff: third_party/WebKit/LayoutTests/fast/domurl/urlsearchparams-stringifier.html

Issue 1442643008: Implement 'URLSearchParams' (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 <!doctype html>
2 <html>
3 <head>
4 <meta charset="utf8">
5 <link rel="help" href="http://url.spec.whatwg.org/#dom-urlsearchparams-set">
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 c');
13 assert_equals(params + '', 'a=b+c');
14 params.delete('a');
15 params.append('a b', 'c');
16 assert_equals(params + '', 'a+b=c');
17 }, 'Serialize space');
18
19 test(function() {
20 var params = new URLSearchParams();
21 params.append('a', '');
22 assert_equals(params + '', 'a=');
23 params.append('a', '');
24 assert_equals(params + '', 'a=&a=');
25 params.append('', 'b');
26 assert_equals(params + '', 'a=&a=&=b');
27 params.append('', '');
28 assert_equals(params + '', 'a=&a=&=b&=');
29 params.append('', '');
30 assert_equals(params + '', 'a=&a=&=b&=&=');
31 }, 'Serialize empty value');
32
33 test(function() {
34 var params = new URLSearchParams();
35 params.append('', 'b');
36 assert_equals(params + '', '=b');
37 params.append('', 'b');
38 assert_equals(params + '', '=b&=b');
39 }, 'Serialize empty name');
40
41 test(function() {
42 var params = new URLSearchParams();
43 params.append('', '');
44 assert_equals(params + '', '=');
45 params.append('', '');
46 assert_equals(params + '', '=&=');
47 }, 'Serialize empty name and value');
48
49 test(function() {
50 var params = new URLSearchParams();
51 params.append('a', 'b+c');
52 assert_equals(params + '', 'a=b%2Bc');
53 params.delete('a');
54 params.append('a+b', 'c');
55 assert_equals(params + '', 'a%2Bb=c');
56 }, 'Serialize +');
57
58 test(function() {
59 var params = new URLSearchParams();
60 params.append('=', 'a');
61 assert_equals(params + '', '%3D=a');
62 params.append('b', '=');
63 assert_equals(params + '', '%3D=a&b=%3D');
64 }, 'Serialize =');
65
66 test(function() {
67 var params = new URLSearchParams();
68 params.append('&', 'a');
69 assert_equals(params + '', '%26=a');
70 params.append('b', '&');
71 assert_equals(params + '', '%26=a&b=%26');
72 }, 'Serialize &');
73
74 test(function() {
75 var params = new URLSearchParams();
76 params.append('a', '*-._');
77 assert_equals(params + '', 'a=*-._');
78 params.delete('a');
79 params.append('*-._', 'c');
80 assert_equals(params + '', '*-._=c');
81 }, 'Serialize *-._');
82
83 test(function() {
84 var params = new URLSearchParams();
85 params.append('a', 'b%c');
86 assert_equals(params + '', 'a=b%25c');
87 params.delete('a');
88 params.append('a%b', 'c');
89 assert_equals(params + '', 'a%25b=c');
90 }, 'Serialize %');
91
92 test(function() {
93 var params = new URLSearchParams();
94 params.append('a', 'b\0c');
95 assert_equals(params + '', 'a=b%00c');
96 params.delete('a');
97 params.append('a\0b', 'c');
98 assert_equals(params + '', 'a%00b=c');
99 }, 'Serialize \\0');
100
101 test(function() {
102 var params = new URLSearchParams();
103 params.append('a', 'b\uD83D\uDCA9c');
104 assert_equals(params + '', 'a=b%F0%9F%92%A9c');
105 params.delete('a');
106 params.append('a\uD83D\uDCA9b', 'c');
107 assert_equals(params + '', 'a%F0%9F%92%A9b=c');
108 }, 'Serialize \uD83D\uDCA9'); // Unicode Character 'PILE OF POO' (U+1F4A9)
109
110 test(function() {
111 var params;
112 params = new URLSearchParams('a=b&c=d&&e&&');
113 assert_equals(params.toString(), 'a=b&c=d&e=');
114 params = new URLSearchParams('a = b &a=b&c=d%20');
115 assert_equals(params.toString(), 'a+=+b+&a=b&c=d+');
116 // The lone '=' _does_ survive the roundtrip.
117 params = new URLSearchParams('a=&a=b');
118 assert_equals(params.toString(), 'a=&a=b');
119 }, 'URLSearchParams.toString');
120 </script>
121 </head>
122 </html>
123
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698