OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 library XHRTest; | 5 library XHRTest; |
6 import '../../pkg/unittest/lib/unittest.dart'; | 6 import '../../pkg/unittest/lib/unittest.dart'; |
7 import '../../pkg/unittest/lib/html_individual_config.dart'; | 7 import '../../pkg/unittest/lib/html_individual_config.dart'; |
8 import 'dart:async'; | 8 import 'dart:async'; |
9 import 'dart:html'; | 9 import 'dart:html'; |
10 import 'dart:json' as json; | 10 import 'dart:json' as json; |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
192 '${window.location.protocol}//${window.location.host}/echo'); | 192 '${window.location.protocol}//${window.location.host}/echo'); |
193 | 193 |
194 // 10MB of payload data w/ a bit of data to make sure it | 194 // 10MB of payload data w/ a bit of data to make sure it |
195 // doesn't get compressed to nil. | 195 // doesn't get compressed to nil. |
196 var data = new Uint8List(10 * 1024 * 1024); | 196 var data = new Uint8List(10 * 1024 * 1024); |
197 for (var i = 0; i < data.length; ++i) { | 197 for (var i = 0; i < data.length; ++i) { |
198 data[i] = i & 0xFF; | 198 data[i] = i & 0xFF; |
199 } | 199 } |
200 xhr.send(data); | 200 xhr.send(data); |
201 | 201 |
202 return xhr.onLoadEnd.first.then((_) { | 202 return xhr.onLoad.first.then((_) { |
203 expect(progressCalled, isTrue); | 203 expect(progressCalled, isTrue); |
204 }); | 204 }); |
205 }); | 205 }); |
206 } | 206 } |
207 }); | 207 }); |
208 | 208 |
209 group('xhr_requestBlob', () { | 209 group('xhr_requestBlob', () { |
210 test('XHR.request responseType blob', () { | 210 test('XHR.request responseType blob', () { |
211 if (Platform.supportsTypedData) { | 211 if (Platform.supportsTypedData) { |
212 return HttpRequest.request(url, responseType: 'blob').then( | 212 return HttpRequest.request(url, responseType: 'blob').then( |
213 (xhr) { | 213 (xhr) { |
214 expect(xhr.status, equals(200)); | 214 expect(xhr.status, equals(200)); |
215 var blob = xhr.response; | 215 var blob = xhr.response; |
216 expect(blob is Blob, isTrue); | 216 expect(blob is Blob, isTrue); |
217 expect(blob, isNotNull); | 217 expect(blob, isNotNull); |
218 }); | 218 }); |
219 } | 219 } |
220 }); | 220 }); |
221 }); | 221 }); |
222 } | 222 } |
OLD | NEW |