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 17 matching lines...) Expand all Loading... |
28 group('supported_HttpRequestProgressEvent', () { | 28 group('supported_HttpRequestProgressEvent', () { |
29 test('supported', () { | 29 test('supported', () { |
30 expect(HttpRequestProgressEvent.supported, isTrue); | 30 expect(HttpRequestProgressEvent.supported, isTrue); |
31 }); | 31 }); |
32 }); | 32 }); |
33 | 33 |
34 group('xhr', () { | 34 group('xhr', () { |
35 test('XHR No file', () { | 35 test('XHR No file', () { |
36 HttpRequest xhr = new HttpRequest(); | 36 HttpRequest xhr = new HttpRequest(); |
37 xhr.open("GET", "NonExistingFile", true); | 37 xhr.open("GET", "NonExistingFile", true); |
38 xhr.on.readyStateChange.add(expectAsyncUntil1((event) { | 38 xhr.onReadyStateChange.listen(expectAsyncUntil1((event) { |
39 if (xhr.readyState == HttpRequest.DONE) { | 39 if (xhr.readyState == HttpRequest.DONE) { |
40 validate404(xhr); | 40 validate404(xhr); |
41 } | 41 } |
42 }, () => xhr.readyState == HttpRequest.DONE)); | 42 }, () => xhr.readyState == HttpRequest.DONE)); |
43 xhr.send(); | 43 xhr.send(); |
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.onReadyStateChange.listen(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 xhr.send(); | 54 xhr.send(); |
55 }); | 55 }); |
56 | 56 |
57 test('XHR.get No file', () { | 57 test('XHR.get No file', () { |
58 new HttpRequest.get("NonExistingFile", expectAsync1((xhr) { | 58 new HttpRequest.get("NonExistingFile", expectAsync1((xhr) { |
59 expect(xhr.readyState, equals(HttpRequest.DONE)); | 59 expect(xhr.readyState, equals(HttpRequest.DONE)); |
(...skipping 25 matching lines...) Expand all Loading... |
85 test('HttpRequestProgressEvent', () { | 85 test('HttpRequestProgressEvent', () { |
86 var expectation = HttpRequestProgressEvent.supported ? | 86 var expectation = HttpRequestProgressEvent.supported ? |
87 returnsNormally : throws; | 87 returnsNormally : throws; |
88 expect(() { | 88 expect(() { |
89 var event = new Event.eventType('XMLHttpRequestProgressEvent', ''); | 89 var event = new Event.eventType('XMLHttpRequestProgressEvent', ''); |
90 expect(event is HttpRequestProgressEvent, isTrue); | 90 expect(event is HttpRequestProgressEvent, isTrue); |
91 }, expectation); | 91 }, expectation); |
92 }); | 92 }); |
93 }); | 93 }); |
94 } | 94 } |
OLD | NEW |