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; |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 }); | 135 }); |
136 | 136 |
137 test('XHR.getString No file', () { | 137 test('XHR.getString No file', () { |
138 HttpRequest.getString('NonExistingFile').then( | 138 HttpRequest.getString('NonExistingFile').then( |
139 (_) { fail('Succeeded for non-existing file.'); }, | 139 (_) { fail('Succeeded for non-existing file.'); }, |
140 onError: expectAsync1((e) { | 140 onError: expectAsync1((e) { |
141 validate404(e.error.target); | 141 validate404(e.error.target); |
142 })); | 142 })); |
143 }); | 143 }); |
144 | 144 |
145 // TODO(antonm): enable again. | |
146 if (false) | |
147 test('XHR.request responseType arraybuffer', () { | 145 test('XHR.request responseType arraybuffer', () { |
148 if (ArrayBuffer.supported) { | 146 if (ArrayBuffer.supported) { |
149 HttpRequest.request(url, responseType: 'arraybuffer').then( | 147 HttpRequest.request(url, responseType: 'arraybuffer').then( |
150 expectAsync1((xhr) { | 148 expectAsync1((xhr) { |
151 expect(xhr.status, equals(200)); | 149 expect(xhr.status, equals(200)); |
152 var arrayBuffer = xhr.response; | 150 var arrayBuffer = xhr.response; |
153 expect(arrayBuffer, new isInstanceOf<ArrayBuffer>()); | 151 expect(arrayBuffer, new isInstanceOf<ArrayBuffer>()); |
154 expect(arrayBuffer, isNotNull); | 152 expect(arrayBuffer, isNotNull); |
155 })); | 153 })); |
156 } | 154 } |
157 }); | 155 }); |
158 | 156 |
159 test('HttpRequestProgressEvent', () { | 157 test('HttpRequestProgressEvent', () { |
160 var expectation = HttpRequestProgressEvent.supported ? | 158 var expectation = HttpRequestProgressEvent.supported ? |
161 returnsNormally : throws; | 159 returnsNormally : throws; |
162 expect(() { | 160 expect(() { |
163 var event = new Event.eventType('XMLHttpRequestProgressEvent', ''); | 161 var event = new Event.eventType('XMLHttpRequestProgressEvent', ''); |
164 expect(event is HttpRequestProgressEvent, isTrue); | 162 expect(event is HttpRequestProgressEvent, isTrue); |
165 }, expectation); | 163 }, expectation); |
166 }); | 164 }); |
167 }); | 165 }); |
168 | 166 |
169 // TODO(antonm): enable again. | 167 group('xhr_requestBlob', () { |
170 /* | 168 test('XHR.request responseType blob', () { |
171 *groupXX('xhr_requestBlob', () { | 169 if (ArrayBuffer.supported) { |
172 * testXX('XHR.request responseType blob', () { | 170 return HttpRequest.request(url, responseType: 'blob').then( |
173 * if (ArrayBuffer.supported) { | 171 (xhr) { |
174 * return HttpRequest.request(url, responseType: 'blob').then( | 172 expect(xhr.status, equals(200)); |
175 * (xhr) { | 173 var blob = xhr.response; |
176 * expect(xhr.status, equals(200)); | 174 expect(blob is Blob, isTrue); |
177 * var blob = xhr.response; | 175 expect(blob, isNotNull); |
178 * expect(blob is Blob, isTrue); | 176 }); |
179 * expect(blob, isNotNull); | 177 } |
180 * }); | 178 }); |
181 * } | 179 }); |
182 * }); | |
183 *}); | |
184 */ | |
185 } | 180 } |
OLD | NEW |