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 } | 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 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 return fetch('/fetch/resources/non-ascii.txt') | 120 return fetch('/fetch/resources/non-ascii.txt') |
121 .then(function(response) { | 121 .then(function(response) { |
122 return response.text(); | 122 return response.text(); |
123 }) | 123 }) |
124 .then(function(text) { | 124 .then(function(text) { |
125 assert_equals(text, '\u4e2d\u6587 Gem\u00fcse\n'); | 125 assert_equals(text, '\u4e2d\u6587 Gem\u00fcse\n'); |
126 }) | 126 }) |
127 }, 'NonAsciiTextTest'); | 127 }, 'NonAsciiTextTest'); |
128 | 128 |
129 promise_test(function(test) { | 129 promise_test(function(test) { |
| 130 return fetch('/fetch/resources/bom-utf-8.php') |
| 131 .then(function(response) { return response.text(); }) |
| 132 .then(function(text) { |
| 133 assert_equals(text, '\u4e09\u6751\u304b\u306a\u5b50', |
| 134 'utf-8 string with BOM is decoded as utf-8 and ' + |
| 135 'BOM is not included in the decoded result.'); |
| 136 }) |
| 137 }, 'BOMUTF8Test'); |
| 138 |
| 139 promise_test(function(test) { |
| 140 return fetch('/fetch/resources/bom-utf-16le.php') |
| 141 .then(function(response) { return response.text(); }) |
| 142 .then(function(text) { |
| 143 assert_equals(text, '\ufffd\ufffd\tNQgK0j0P[', |
| 144 'utf-16le string is decoded as if utf-8 ' + |
| 145 'even if the data has utf-16le BOM.'); |
| 146 }) |
| 147 }, 'BOMUTF16LETest'); |
| 148 |
| 149 promise_test(function(test) { |
| 150 return fetch('/fetch/resources/bom-utf-16be.php') |
| 151 .then(function(response) { return response.text(); }) |
| 152 .then(function(text) { |
| 153 assert_equals(text, '\ufffd\ufffdN\tgQ0K0j[P', |
| 154 'utf-16be string is decoded as if utf-8 ' + |
| 155 'even if the data has utf-16be BOM.'); |
| 156 }) |
| 157 }, 'BOMUTF16BETest'); |
| 158 |
| 159 promise_test(function(test) { |
130 var expected = ''; | 160 var expected = ''; |
131 for (var i = 0; i < 100; ++i) | 161 for (var i = 0; i < 100; ++i) |
132 expected += i; | 162 expected += i; |
133 | 163 |
134 var decoder = new TextDecoder(); | 164 var decoder = new TextDecoder(); |
135 var actual = ''; | 165 var actual = ''; |
136 var response; | 166 var response; |
137 var reader; | 167 var reader; |
138 return fetch('/fetch/resources/progressive.php') | 168 return fetch('/fetch/resources/progressive.php') |
139 .then(function(res) { | 169 .then(function(res) { |
(...skipping 14 matching lines...) Expand all Loading... |
154 reader.releaseLock(); | 184 reader.releaseLock(); |
155 return response.arrayBuffer(); | 185 return response.arrayBuffer(); |
156 }) | 186 }) |
157 .then(function(buffer) { | 187 .then(function(buffer) { |
158 actual += decoder.decode(buffer); | 188 actual += decoder.decode(buffer); |
159 assert_equals(actual, expected); | 189 assert_equals(actual, expected); |
160 }) | 190 }) |
161 }, 'PartiallyReadFromStreamAndReadArrayBufferTest'); | 191 }, 'PartiallyReadFromStreamAndReadArrayBufferTest'); |
162 | 192 |
163 done(); | 193 done(); |
OLD | NEW |