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

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

Issue 1998563002: Fix URLSearchParams to use the right encoding algorithm (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 4 years, 6 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
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/fast/domurl/urlsearchparams-stringifier-expected.txt » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/#dom-urlsearchparams-set"> 5 <link rel="help" href="https://url.spec.whatwg.org/#dom-urlsearchparams-set">
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 test(function() { 10 test(function() {
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 var ret = ""; 89 var ret = "";
90 for (var i = 0; i < bytes.length; i++) { 90 for (var i = 0; i < bytes.length; i++) {
91 ret += "%" + intToHex(bytes[i]); 91 ret += "%" + intToHex(bytes[i]);
92 } 92 }
93 return ret; 93 return ret;
94 } 94 }
95 95
96 for (var i = 0x00; i < 0xFF; i++) { 96 for (var i = 0x00; i < 0xFF; i++) {
97 // Not all bytes can appear in valid UTF-8, so some bytes aren't covered. 97 // Not all bytes can appear in valid UTF-8, so some bytes aren't covered.
98 // TODO(mkwst): We fail to properly encode a few bytes: https://crbug.com/55 7063 98 // TODO(mkwst): We fail to properly encode a few bytes: https://crbug.com/55 7063
99 var expected = urlEncodedSerialize(i);
99 test(function() { 100 test(function() {
100 var params = new URLSearchParams(); 101 var params = new URLSearchParams();
101 params.append('' + i, String.fromCodePoint(i)); 102 params.append('' + i, String.fromCodePoint(i));
102 assert_equals(params + '', '' + i + '=' + urlEncodedSerialize(i)); 103 assert_equals(params + '', '' + i + '=' + expected);
103 }, "Serialize U+00" + intToHex(i) + " -> '" + String.fromCodePoint(i) + "'") ; 104 }, "Serialize U+00" + intToHex(i) + " -> '" + expected + "'");
104 } 105 }
105 106
106 test(function() { 107 test(function() {
107 var params = new URLSearchParams(); 108 var params = new URLSearchParams();
109 params.append('a', '\r');
110 assert_equals(params + '', 'a=%0D');
111 }, 'Serialize \\r');
112
113 test(function() {
114 var params = new URLSearchParams();
115 params.append('a', '\n');
116 assert_equals(params + '', 'a=%0A');
117 }, 'Serialize \\n');
118
119 test(function() {
120 var params = new URLSearchParams();
121 params.append('a', '\r\n');
122 assert_equals(params + '', 'a=%0D%0A');
123 }, 'Serialize \\r\\n');
124
125 test(function() {
126 var params = new URLSearchParams();
108 params.append('a', 'b%c'); 127 params.append('a', 'b%c');
109 assert_equals(params + '', 'a=b%25c'); 128 assert_equals(params + '', 'a=b%25c');
110 params.delete('a'); 129 params.delete('a');
111 params.append('a%b', 'c'); 130 params.append('a%b', 'c');
112 assert_equals(params + '', 'a%25b=c'); 131 assert_equals(params + '', 'a%25b=c');
113 }, 'Serialize %'); 132 }, 'Serialize %');
114 133
115 test(function() { 134 test(function() {
116 var params = new URLSearchParams(); 135 var params = new URLSearchParams();
117 params.append('a', 'b\0c'); 136 params.append('a', 'b\0c');
(...skipping 18 matching lines...) Expand all
136 assert_equals(params.toString(), 'a=b&c=d&e='); 155 assert_equals(params.toString(), 'a=b&c=d&e=');
137 params = new URLSearchParams('a = b &a=b&c=d%20'); 156 params = new URLSearchParams('a = b &a=b&c=d%20');
138 assert_equals(params.toString(), 'a+=+b+&a=b&c=d+'); 157 assert_equals(params.toString(), 'a+=+b+&a=b&c=d+');
139 // The lone '=' _does_ survive the roundtrip. 158 // The lone '=' _does_ survive the roundtrip.
140 params = new URLSearchParams('a=&a=b'); 159 params = new URLSearchParams('a=&a=b');
141 assert_equals(params.toString(), 'a=&a=b'); 160 assert_equals(params.toString(), 'a=&a=b');
142 }, 'URLSearchParams.toString'); 161 }, 'URLSearchParams.toString');
143 </script> 162 </script>
144 </head> 163 </head>
145 </html> 164 </html>
146
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/fast/domurl/urlsearchparams-stringifier-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698