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 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
139 HttpRequest.getString('NonExistingFile').then( | 139 HttpRequest.getString('NonExistingFile').then( |
140 (_) { fail('Succeeded for non-existing file.'); }, | 140 (_) { fail('Succeeded for non-existing file.'); }, |
141 onError: expectAsync1((error) { | 141 onError: expectAsync1((error) { |
142 validate404(error.target); | 142 validate404(error.target); |
143 })); | 143 })); |
144 }); | 144 }); |
145 | 145 |
146 test('XHR.request responseType arraybuffer', () { | 146 test('XHR.request responseType arraybuffer', () { |
147 if (Platform.supportsTypedData) { | 147 if (Platform.supportsTypedData) { |
148 HttpRequest.request(url, responseType: 'arraybuffer', | 148 HttpRequest.request(url, responseType: 'arraybuffer', |
149 mimeType: 'application/binary', | |
150 requestHeaders: {'Content-Type': 'text/xml'}).then( | 149 requestHeaders: {'Content-Type': 'text/xml'}).then( |
151 expectAsync1((xhr) { | 150 expectAsync1((xhr) { |
152 expect(xhr.status, equals(200)); | 151 expect(xhr.status, equals(200)); |
153 var byteBuffer = xhr.response; | 152 var byteBuffer = xhr.response; |
154 expect(byteBuffer, new isInstanceOf<ByteBuffer>()); | 153 expect(byteBuffer, new isInstanceOf<ByteBuffer>()); |
155 expect(byteBuffer, isNotNull); | 154 expect(byteBuffer, isNotNull); |
156 })); | 155 })); |
157 } | 156 } |
158 }); | 157 }); |
159 | 158 |
160 test('HttpRequestProgressEvent', () { | 159 test('HttpRequestProgressEvent', () { |
161 var expectation = HttpRequestProgressEvent.supported ? | 160 var expectation = HttpRequestProgressEvent.supported ? |
162 returnsNormally : throws; | 161 returnsNormally : throws; |
163 expect(() { | 162 expect(() { |
164 var event = new Event.eventType('XMLHttpRequestProgressEvent', ''); | 163 var event = new Event.eventType('XMLHttpRequestProgressEvent', ''); |
165 expect(event is HttpRequestProgressEvent, isTrue); | 164 expect(event is HttpRequestProgressEvent, isTrue); |
166 }, expectation); | 165 }, expectation); |
167 }); | 166 }); |
168 }); | 167 }); |
169 | 168 |
170 group('xhr_requestBlob', () { | 169 group('xhr_requestBlob', () { |
171 test('XHR.request responseType blob', () { | 170 test('XHR.request responseType blob', () { |
172 if (Platform.supportsTypedData) { | 171 if (Platform.supportsTypedData) { |
173 return HttpRequest.request(url, responseType: 'blob').then( | 172 return HttpRequest.request(url, responseType: 'blob', |
| 173 mimeType: 'application/binary').then( |
174 (xhr) { | 174 (xhr) { |
175 expect(xhr.status, equals(200)); | 175 expect(xhr.status, equals(200)); |
176 var blob = xhr.response; | 176 var blob = xhr.response; |
177 expect(blob is Blob, isTrue); | 177 expect(blob is Blob, isTrue); |
178 expect(blob, isNotNull); | 178 expect(blob, isNotNull); |
179 }); | 179 }); |
180 } | 180 } |
181 }); | 181 }); |
182 }); | 182 }); |
183 } | 183 } |
OLD | NEW |