OLD | NEW |
1 if (self.importScripts) { | 1 if (self.importScripts) { |
2 importScripts('../resources/fetch-test-helpers.js'); | 2 importScripts('../resources/fetch-test-helpers.js'); |
3 importScripts('/streams/resources/rs-utils.js'); | 3 importScripts('/streams/resources/rs-utils.js'); |
4 } | 4 } |
5 | 5 |
6 function isLocked(stream) { | 6 function isLocked(stream) { |
7 try { | 7 try { |
8 var reader = stream.getReader(); | 8 var reader = stream.getReader(); |
9 reader.releaseLock(); | 9 reader.releaseLock(); |
10 return false; | 10 return false; |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 assert_false(response.bodyUsed); | 157 assert_false(response.bodyUsed); |
158 var p = response.text(); | 158 var p = response.text(); |
159 assert_true(response.bodyUsed); | 159 assert_true(response.bodyUsed); |
160 return p; | 160 return p; |
161 }) | 161 }) |
162 .then(function(text) { | 162 .then(function(text) { |
163 assert_equals(text, '\u4e2d\u6587 Gem\u00fcse\n'); | 163 assert_equals(text, '\u4e2d\u6587 Gem\u00fcse\n'); |
164 }) | 164 }) |
165 }, 'NonAsciiTextTest'); | 165 }, 'NonAsciiTextTest'); |
166 | 166 |
| 167 promise_test(function(test) { |
| 168 return fetch('/fetch/resources/bom-utf-8.php') |
| 169 .then(function(response) { return response.text(); }) |
| 170 .then(function(text) { |
| 171 assert_equals(text, '\u4e09\u6751\u304b\u306a\u5b50', |
| 172 'utf-8 string with BOM is decoded as utf-8 and ' + |
| 173 'BOM is not included in the decoded result.'); |
| 174 }) |
| 175 }, 'BOMUTF8Test'); |
| 176 |
| 177 promise_test(function(test) { |
| 178 return fetch('/fetch/resources/bom-utf-16le.php') |
| 179 .then(function(response) { return response.text(); }) |
| 180 .then(function(text) { |
| 181 assert_equals(text, '\ufffd\ufffd\tNQgK0j0P[', |
| 182 'utf-16le string is decoded as if utf-8 ' + |
| 183 'even if the data has utf-16le BOM.'); |
| 184 }) |
| 185 }, 'BOMUTF16LETest'); |
| 186 |
| 187 promise_test(function(test) { |
| 188 return fetch('/fetch/resources/bom-utf-16be.php') |
| 189 .then(function(response) { return response.text(); }) |
| 190 .then(function(text) { |
| 191 assert_equals(text, '\ufffd\ufffdN\tgQ0K0j[P', |
| 192 'utf-16be string is decoded as if utf-8 ' + |
| 193 'even if the data has utf-16be BOM.'); |
| 194 }) |
| 195 }, 'BOMUTF16BETest'); |
| 196 |
167 test(t => { | 197 test(t => { |
168 var req = new Request('/'); | 198 var req = new Request('/'); |
169 assert_false(req.bodyUsed); | 199 assert_false(req.bodyUsed); |
170 req.text(); | 200 req.text(); |
171 assert_false(req.bodyUsed); | 201 assert_false(req.bodyUsed); |
172 }, 'BodyUsedShouldNotBeSetForNullBody'); | 202 }, 'BodyUsedShouldNotBeSetForNullBody'); |
173 | 203 |
174 test(t => { | 204 test(t => { |
175 var req = new Request('/', {method: 'POST', body: ''}); | 205 var req = new Request('/', {method: 'POST', body: ''}); |
176 assert_false(req.bodyUsed); | 206 assert_false(req.bodyUsed); |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
254 | 284 |
255 promise_test(t => { | 285 promise_test(t => { |
256 var res = new Response(''); | 286 var res = new Response(''); |
257 res.body.getReader(); | 287 res.body.getReader(); |
258 return res.text().then(unreached_fulfillment(t), e => { | 288 return res.text().then(unreached_fulfillment(t), e => { |
259 assert_equals(e.name, 'TypeError'); | 289 assert_equals(e.name, 'TypeError'); |
260 }); | 290 }); |
261 }, 'Locked => text'); | 291 }, 'Locked => text'); |
262 | 292 |
263 done(); | 293 done(); |
OLD | NEW |