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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 HttpRequest xhr = new HttpRequest(); | 57 HttpRequest xhr = new HttpRequest(); |
58 xhr.open("GET", "NonExistingFile", async: true); | 58 xhr.open("GET", "NonExistingFile", async: true); |
59 xhr.onReadyStateChange.listen(expectAsyncUntil((event) { | 59 xhr.onReadyStateChange.listen(expectAsyncUntil((event) { |
60 if (xhr.readyState == HttpRequest.DONE) { | 60 if (xhr.readyState == HttpRequest.DONE) { |
61 validate404(xhr); | 61 validate404(xhr); |
62 } | 62 } |
63 }, () => xhr.readyState == HttpRequest.DONE)); | 63 }, () => xhr.readyState == HttpRequest.DONE)); |
64 xhr.send(); | 64 xhr.send(); |
65 }); | 65 }); |
66 | 66 |
67 test('XHR file', () { | 67 test('XHR_file', () { |
68 var loadEndCalled = false; | 68 var loadEndCalled = false; |
69 | 69 |
70 var xhr = new HttpRequest(); | 70 var xhr = new HttpRequest(); |
71 xhr.open('GET', url, async: true); | 71 xhr.open('GET', url, async: true); |
72 xhr.onReadyStateChange.listen(expectAsyncUntil((e) { | 72 xhr.onReadyStateChange.listen(expectAsyncUntil((e) { |
73 if (xhr.readyState == HttpRequest.DONE) { | 73 if (xhr.readyState == HttpRequest.DONE) { |
74 validate200Response(xhr); | 74 validate200Response(xhr); |
75 | 75 |
76 Timer.run(expectAsync(() { | 76 Timer.run(expectAsync(() { |
77 expect(loadEndCalled, HttpRequest.supportsLoadEndEvent); | 77 expect(loadEndCalled, HttpRequest.supportsLoadEndEvent); |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
250 (xhr) { | 250 (xhr) { |
251 var contentTypeHeader = xhr.responseHeaders['content-type']; | 251 var contentTypeHeader = xhr.responseHeaders['content-type']; |
252 expect(contentTypeHeader, isNotNull); | 252 expect(contentTypeHeader, isNotNull); |
253 // Should be like: 'text/plain; charset=utf-8' | 253 // Should be like: 'text/plain; charset=utf-8' |
254 expect(contentTypeHeader.contains('text/plain'), isTrue); | 254 expect(contentTypeHeader.contains('text/plain'), isTrue); |
255 expect(contentTypeHeader.contains('charset=utf-8'), isTrue); | 255 expect(contentTypeHeader.contains('charset=utf-8'), isTrue); |
256 }); | 256 }); |
257 }); | 257 }); |
258 }); | 258 }); |
259 } | 259 } |
OLD | NEW |