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

Side by Side Diff: third_party/WebKit/LayoutTests/http/tests/fetch/script-tests/body-mixin.js

Issue 1470893002: [Fetch] Always use utf-8 for decoding in text() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove numerical enum value comparison. Created 5 years 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 if (self.importScripts) { 1 if (self.importScripts) {
2 importScripts('../resources/fetch-test-helpers.js'); 2 importScripts('../resources/fetch-test-helpers.js');
3 } 3 }
4 4
5 function readStream(reader, values) { 5 function readStream(reader, values) {
6 reader.read().then(function(r) { 6 reader.read().then(function(r) {
7 if (!r.done) { 7 if (!r.done) {
8 values.push(r.value); 8 values.push(r.value);
9 readStream(reader, values); 9 readStream(reader, values);
10 } 10 }
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 assert_false(response.bodyUsed); 167 assert_false(response.bodyUsed);
168 var p = response.text(); 168 var p = response.text();
169 assert_true(response.bodyUsed); 169 assert_true(response.bodyUsed);
170 return p; 170 return p;
171 }) 171 })
172 .then(function(text) { 172 .then(function(text) {
173 assert_equals(text, '\u4e2d\u6587 Gem\u00fcse\n'); 173 assert_equals(text, '\u4e2d\u6587 Gem\u00fcse\n');
174 }) 174 })
175 }, 'NonAsciiTextTest'); 175 }, 'NonAsciiTextTest');
176 176
177 promise_test(function(test) {
178 return fetch('/fetch/resources/bom-utf-8.php')
179 .then(function(response) { return response.text(); })
180 .then(function(text) {
181 assert_equals(text, '\u4e09\u6751\u304b\u306a\u5b50',
182 'utf-8 string with BOM is decoded as utf-8 and ' +
183 'BOM is not included in the decoded result.');
184 })
185 }, 'BOMUTF8Test');
186
187 promise_test(function(test) {
188 return fetch('/fetch/resources/bom-utf-16le.php')
189 .then(function(response) { return response.text(); })
190 .then(function(text) {
191 assert_equals(text, '\ufffd\ufffd\tNQgK0j0P[',
192 'utf-16le string is decoded as if utf-8 ' +
193 'even if the data has utf-16le BOM.');
194 })
195 }, 'BOMUTF16LETest');
196
197 promise_test(function(test) {
198 return fetch('/fetch/resources/bom-utf-16be.php')
199 .then(function(response) { return response.text(); })
200 .then(function(text) {
201 assert_equals(text, '\ufffd\ufffdN\tgQ0K0j[P',
202 'utf-16be string is decoded as if utf-8 ' +
203 'even if the data has utf-16be BOM.');
204 })
205 }, 'BOMUTF16BETest');
206
177 test(t => { 207 test(t => {
178 var req = new Request('/'); 208 var req = new Request('/');
179 assert_false(req.bodyUsed); 209 assert_false(req.bodyUsed);
180 req.text(); 210 req.text();
181 assert_false(req.bodyUsed); 211 assert_false(req.bodyUsed);
182 }, 'BodyUsedShouldNotBeSetForNullBody'); 212 }, 'BodyUsedShouldNotBeSetForNullBody');
183 213
184 test(t => { 214 test(t => {
185 var req = new Request('/', {method: 'POST', body: ''}); 215 var req = new Request('/', {method: 'POST', body: ''});
186 assert_false(req.bodyUsed); 216 assert_false(req.bodyUsed);
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
264 294
265 promise_test(t => { 295 promise_test(t => {
266 var res = new Response(''); 296 var res = new Response('');
267 res.body.getReader(); 297 res.body.getReader();
268 return res.text().then(unreached_fulfillment(t), e => { 298 return res.text().then(unreached_fulfillment(t), e => {
269 assert_equals(e.name, 'TypeError'); 299 assert_equals(e.name, 'TypeError');
270 }); 300 });
271 }, 'Locked => text'); 301 }, 'Locked => text');
272 302
273 done(); 303 done();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698