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

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

Issue 2725593003: Construct URLSearchParams from sequence initializer. (Closed)
Patch Set: style update Created 3 years, 9 months 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
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 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 params = new URLSearchParams('a%f0%9f%92%a9b=c'); 162 params = new URLSearchParams('a%f0%9f%92%a9b=c');
163 assert_equals(params.get('a\uD83D\uDCA9b'), 'c'); 163 assert_equals(params.get('a\uD83D\uDCA9b'), 'c');
164 }, 'Parse %f0%9f%92%a9'); // Unicode Character 'PILE OF POO' (U+1F4A9) 164 }, 'Parse %f0%9f%92%a9'); // Unicode Character 'PILE OF POO' (U+1F4A9)
165 165
166 test(function() { 166 test(function() {
167 var params = new URLSearchParams('='); 167 var params = new URLSearchParams('=');
168 assert_equals(params.toString(), '='); 168 assert_equals(params.toString(), '=');
169 }, 'Parse ='); 169 }, 'Parse =');
170 170
171 test(function() { 171 test(function() {
172 var params = new URLSearchParams('foobar=a\nb'); 172 let params = new URLSearchParams([]);
173 assert_equals(params.toString(), 'foobar=a%0Ab'); 173 assert_true(params !== null, 'Empty sequence');
174 }, 'Parse \\n'); 174 assert_equals(params.toString(), '');
175
176 params = new URLSearchParams([[1, 2], ['a', 'b']]);
177 assert_equals(params.toString(), '1=2&a=b');
178
179 assert_type_error(() => { new URLSearchParams([[1, 2, 3]]) },
180 "Sequence elements must be pairs");
181 }, 'sequence initializer');
182
175 </script> 183 </script>
176 </head> 184 </head>
177 </html> 185 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698