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 'dart:async'; | 6 import 'dart:async'; |
7 import 'dart:convert'; | 7 import 'dart:convert'; |
8 import 'dart:html'; | 8 import 'dart:html'; |
9 import 'dart:typed_data'; | 9 import 'dart:typed_data'; |
10 import 'package:unittest/html_individual_config.dart'; | 10 import 'package:unittest/html_individual_config.dart'; |
(...skipping 10 matching lines...) Expand all Loading... | |
21 void validate200Response(xhr) { | 21 void validate200Response(xhr) { |
22 expect(xhr.status, equals(200)); | 22 expect(xhr.status, equals(200)); |
23 var data = JSON.decode(xhr.responseText); | 23 var data = JSON.decode(xhr.responseText); |
24 expect(data, contains('feed')); | 24 expect(data, contains('feed')); |
25 expect(data['feed'], contains('entry')); | 25 expect(data['feed'], contains('entry')); |
26 expect(data, isMap); | 26 expect(data, isMap); |
27 } | 27 } |
28 | 28 |
29 void validate404(xhr) { | 29 void validate404(xhr) { |
30 expect(xhr.status, equals(404)); | 30 expect(xhr.status, equals(404)); |
31 expect(xhr.responseText, equals('')); | 31 // We cannot say much about xhr.responseText, most HTTP servers will |
Emily Fortuna
2014/05/27 15:55:35
Don't we know that the response text is always ''
ahe
2014/05/27 15:59:10
One might think that, but I just changed it to inc
| |
32 // include an HTML page explaining the error to a human. | |
33 String responseText = xhr.responseText; | |
34 expect(responseText, isNotNull); | |
32 } | 35 } |
33 | 36 |
34 group('supported_onProgress', () { | 37 group('supported_onProgress', () { |
35 test('supported', () { | 38 test('supported', () { |
36 expect(HttpRequest.supportsProgressEvent, isTrue); | 39 expect(HttpRequest.supportsProgressEvent, isTrue); |
37 }); | 40 }); |
38 }); | 41 }); |
39 | 42 |
40 group('supported_onLoadEnd', () { | 43 group('supported_onLoadEnd', () { |
41 test('supported', () { | 44 test('supported', () { |
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
246 return HttpRequest.request(url).then( | 249 return HttpRequest.request(url).then( |
247 (xhr) { | 250 (xhr) { |
248 var serverHeader = xhr.responseHeaders['server']; | 251 var serverHeader = xhr.responseHeaders['server']; |
249 expect(serverHeader, isNotNull); | 252 expect(serverHeader, isNotNull); |
250 // Should be like: 'Dart/0.1 (dart:io)' | 253 // Should be like: 'Dart/0.1 (dart:io)' |
251 expect(serverHeader.startsWith('Dart/'), isTrue); | 254 expect(serverHeader.startsWith('Dart/'), isTrue); |
252 }); | 255 }); |
253 }); | 256 }); |
254 }); | 257 }); |
255 } | 258 } |
OLD | NEW |