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; |
11 | 11 |
12 void fail(message) { | 12 void fail(message) { |
13 guardAsync(() { | 13 guardAsync(() { |
14 expect(false, isTrue, reason: message); | 14 expect(false, isTrue, reason: message); |
15 }); | 15 }); |
16 } | 16 } |
17 | 17 |
18 main() { | 18 main() { |
19 useHtmlIndividualConfiguration(); | 19 useHtmlIndividualConfiguration(); |
20 var url = "/tests/html/xhr_cross_origin_data.txt"; | 20 var url = "/root_dart/tests/html/xhr_cross_origin_data.txt"; |
21 | 21 |
22 void validate200Response(xhr) { | 22 void validate200Response(xhr) { |
23 expect(xhr.status, equals(200)); | 23 expect(xhr.status, equals(200)); |
24 var data = json.parse(xhr.responseText); | 24 var data = json.parse(xhr.responseText); |
25 expect(data, contains('feed')); | 25 expect(data, contains('feed')); |
26 expect(data['feed'], contains('entry')); | 26 expect(data['feed'], contains('entry')); |
27 expect(data, isMap); | 27 expect(data, isMap); |
28 } | 28 } |
29 | 29 |
30 void validate404(xhr) { | 30 void validate404(xhr) { |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 test('HttpRequestProgressEvent', () { | 157 test('HttpRequestProgressEvent', () { |
158 var expectation = HttpRequestProgressEvent.supported ? | 158 var expectation = HttpRequestProgressEvent.supported ? |
159 returnsNormally : throws; | 159 returnsNormally : throws; |
160 expect(() { | 160 expect(() { |
161 var event = new Event.eventType('XMLHttpRequestProgressEvent', ''); | 161 var event = new Event.eventType('XMLHttpRequestProgressEvent', ''); |
162 expect(event is HttpRequestProgressEvent, isTrue); | 162 expect(event is HttpRequestProgressEvent, isTrue); |
163 }, expectation); | 163 }, expectation); |
164 }); | 164 }); |
165 }); | 165 }); |
166 } | 166 } |
OLD | NEW |