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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/LayoutTests/fast/domurl/urlsearchparams-stringifier.html
diff --git a/third_party/WebKit/LayoutTests/fast/domurl/urlsearchparams-stringifier.html b/third_party/WebKit/LayoutTests/fast/domurl/urlsearchparams-stringifier.html
new file mode 100644
index 0000000000000000000000000000000000000000..0ad49567f6dcec78b5106d281f8dce404d3b8fe0
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/fast/domurl/urlsearchparams-stringifier.html
@@ -0,0 +1,123 @@
+<!doctype html>
+<html>
+<head>
+<meta charset="utf8">
+<link rel="help" href="http://url.spec.whatwg.org/#dom-urlsearchparams-set">
+<script src="../../resources/testharness.js"></script>
+<script src="../../resources/testharnessreport.js"></script>
+<script src="resources/testharness-extras.js"></script>
+<script>
+test(function() {
+ var params = new URLSearchParams();
+ params.append('a', 'b c');
+ assert_equals(params + '', 'a=b+c');
+ params.delete('a');
+ params.append('a b', 'c');
+ assert_equals(params + '', 'a+b=c');
+}, 'Serialize space');
+
+test(function() {
+ var params = new URLSearchParams();
+ params.append('a', '');
+ assert_equals(params + '', 'a=');
+ params.append('a', '');
+ assert_equals(params + '', 'a=&a=');
+ params.append('', 'b');
+ assert_equals(params + '', 'a=&a=&=b');
+ params.append('', '');
+ assert_equals(params + '', 'a=&a=&=b&=');
+ params.append('', '');
+ assert_equals(params + '', 'a=&a=&=b&=&=');
+}, 'Serialize empty value');
+
+test(function() {
+ var params = new URLSearchParams();
+ params.append('', 'b');
+ assert_equals(params + '', '=b');
+ params.append('', 'b');
+ assert_equals(params + '', '=b&=b');
+}, 'Serialize empty name');
+
+test(function() {
+ var params = new URLSearchParams();
+ params.append('', '');
+ assert_equals(params + '', '=');
+ params.append('', '');
+ assert_equals(params + '', '=&=');
+}, 'Serialize empty name and value');
+
+test(function() {
+ var params = new URLSearchParams();
+ params.append('a', 'b+c');
+ assert_equals(params + '', 'a=b%2Bc');
+ params.delete('a');
+ params.append('a+b', 'c');
+ assert_equals(params + '', 'a%2Bb=c');
+}, 'Serialize +');
+
+test(function() {
+ var params = new URLSearchParams();
+ params.append('=', 'a');
+ assert_equals(params + '', '%3D=a');
+ params.append('b', '=');
+ assert_equals(params + '', '%3D=a&b=%3D');
+}, 'Serialize =');
+
+test(function() {
+ var params = new URLSearchParams();
+ params.append('&', 'a');
+ assert_equals(params + '', '%26=a');
+ params.append('b', '&');
+ assert_equals(params + '', '%26=a&b=%26');
+}, 'Serialize &');
+
+test(function() {
+ var params = new URLSearchParams();
+ params.append('a', '*-._');
+ assert_equals(params + '', 'a=*-._');
+ params.delete('a');
+ params.append('*-._', 'c');
+ assert_equals(params + '', '*-._=c');
+}, 'Serialize *-._');
+
+test(function() {
+ var params = new URLSearchParams();
+ params.append('a', 'b%c');
+ assert_equals(params + '', 'a=b%25c');
+ params.delete('a');
+ params.append('a%b', 'c');
+ assert_equals(params + '', 'a%25b=c');
+}, 'Serialize %');
+
+test(function() {
+ var params = new URLSearchParams();
+ params.append('a', 'b\0c');
+ assert_equals(params + '', 'a=b%00c');
+ params.delete('a');
+ params.append('a\0b', 'c');
+ assert_equals(params + '', 'a%00b=c');
+}, 'Serialize \\0');
+
+test(function() {
+ var params = new URLSearchParams();
+ params.append('a', 'b\uD83D\uDCA9c');
+ assert_equals(params + '', 'a=b%F0%9F%92%A9c');
+ params.delete('a');
+ params.append('a\uD83D\uDCA9b', 'c');
+ assert_equals(params + '', 'a%F0%9F%92%A9b=c');
+}, 'Serialize \uD83D\uDCA9'); // Unicode Character 'PILE OF POO' (U+1F4A9)
+
+test(function() {
+ var params;
+ params = new URLSearchParams('a=b&c=d&&e&&');
+ assert_equals(params.toString(), 'a=b&c=d&e=');
+ params = new URLSearchParams('a = b &a=b&c=d%20');
+ assert_equals(params.toString(), 'a+=+b+&a=b&c=d+');
+ // The lone '=' _does_ survive the roundtrip.
+ params = new URLSearchParams('a=&a=b');
+ assert_equals(params.toString(), 'a=&a=b');
+}, 'URLSearchParams.toString');
+</script>
+</head>
+</html>
+

Powered by Google App Engine
This is Rietveld 408576698