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:html'; | 8 import 'dart:html'; |
9 import 'dart:json' as json; | 9 import 'dart:json' as json; |
10 | 10 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 }); | 44 }); |
45 | 45 |
46 test('XHR file', () { | 46 test('XHR file', () { |
47 var xhr = new HttpRequest(); | 47 var xhr = new HttpRequest(); |
48 xhr.open('GET', url, true); | 48 xhr.open('GET', url, true); |
49 xhr.on.readyStateChange.add(expectAsyncUntil1((e) { | 49 xhr.on.readyStateChange.add(expectAsyncUntil1((e) { |
50 if (xhr.readyState == HttpRequest.DONE) { | 50 if (xhr.readyState == HttpRequest.DONE) { |
51 validate200Response(xhr); | 51 validate200Response(xhr); |
52 } | 52 } |
53 }, () => xhr.readyState == HttpRequest.DONE)); | 53 }, () => xhr.readyState == HttpRequest.DONE)); |
| 54 |
| 55 xhr.onLoadEnd.listen(expectAsync1((ProgressEvent e) { |
| 56 expect(e.currentTarget, xhr); |
| 57 expect(e.target, xhr); |
| 58 })); |
54 xhr.send(); | 59 xhr.send(); |
55 }); | 60 }); |
56 | 61 |
57 test('XHR.get No file', () { | 62 test('XHR.get No file', () { |
58 new HttpRequest.get("NonExistingFile", expectAsync1((xhr) { | 63 new HttpRequest.get("NonExistingFile", expectAsync1((xhr) { |
59 expect(xhr.readyState, equals(HttpRequest.DONE)); | 64 expect(xhr.readyState, equals(HttpRequest.DONE)); |
60 validate404(xhr); | 65 validate404(xhr); |
61 })); | 66 })); |
62 }); | 67 }); |
63 | 68 |
(...skipping 21 matching lines...) Expand all Loading... |
85 test('HttpRequestProgressEvent', () { | 90 test('HttpRequestProgressEvent', () { |
86 var expectation = HttpRequestProgressEvent.supported ? | 91 var expectation = HttpRequestProgressEvent.supported ? |
87 returnsNormally : throws; | 92 returnsNormally : throws; |
88 expect(() { | 93 expect(() { |
89 var event = new Event.eventType('XMLHttpRequestProgressEvent', ''); | 94 var event = new Event.eventType('XMLHttpRequestProgressEvent', ''); |
90 expect(event is HttpRequestProgressEvent, isTrue); | 95 expect(event is HttpRequestProgressEvent, isTrue); |
91 }, expectation); | 96 }, expectation); |
92 }); | 97 }); |
93 }); | 98 }); |
94 } | 99 } |
OLD | NEW |