| 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 import 'dart:typeddata'; |
| 11 | 12 |
| 12 void fail(message) { | 13 void fail(message) { |
| 13 guardAsync(() { | 14 guardAsync(() { |
| 14 expect(false, isTrue, reason: message); | 15 expect(false, isTrue, reason: message); |
| 15 }); | 16 }); |
| 16 } | 17 } |
| 17 | 18 |
| 18 main() { | 19 main() { |
| 19 useHtmlIndividualConfiguration(); | 20 useHtmlIndividualConfiguration(); |
| 20 var url = "/root_dart/tests/html/xhr_cross_origin_data.txt"; | 21 var url = "/root_dart/tests/html/xhr_cross_origin_data.txt"; |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 onError: expectAsync1((error) { | 141 onError: expectAsync1((error) { |
| 141 validate404(error.target); | 142 validate404(error.target); |
| 142 })); | 143 })); |
| 143 }); | 144 }); |
| 144 | 145 |
| 145 test('XHR.request responseType arraybuffer', () { | 146 test('XHR.request responseType arraybuffer', () { |
| 146 if (Platform.supportsTypedData) { | 147 if (Platform.supportsTypedData) { |
| 147 HttpRequest.request(url, responseType: 'arraybuffer').then( | 148 HttpRequest.request(url, responseType: 'arraybuffer').then( |
| 148 expectAsync1((xhr) { | 149 expectAsync1((xhr) { |
| 149 expect(xhr.status, equals(200)); | 150 expect(xhr.status, equals(200)); |
| 150 var arrayBuffer = xhr.response; | 151 var byteBuffer = xhr.response; |
| 151 expect(arrayBuffer, new isInstanceOf<ArrayBuffer>()); | 152 expect(byteBuffer, new isInstanceOf<ByteBuffer>()); |
| 152 expect(arrayBuffer, isNotNull); | 153 expect(byteBuffer, isNotNull); |
| 153 })); | 154 })); |
| 154 } | 155 } |
| 155 }); | 156 }); |
| 156 | 157 |
| 157 test('HttpRequestProgressEvent', () { | 158 test('HttpRequestProgressEvent', () { |
| 158 var expectation = HttpRequestProgressEvent.supported ? | 159 var expectation = HttpRequestProgressEvent.supported ? |
| 159 returnsNormally : throws; | 160 returnsNormally : throws; |
| 160 expect(() { | 161 expect(() { |
| 161 var event = new Event.eventType('XMLHttpRequestProgressEvent', ''); | 162 var event = new Event.eventType('XMLHttpRequestProgressEvent', ''); |
| 162 expect(event is HttpRequestProgressEvent, isTrue); | 163 expect(event is HttpRequestProgressEvent, isTrue); |
| 163 }, expectation); | 164 }, expectation); |
| 164 }); | 165 }); |
| 165 }); | 166 }); |
| 166 | 167 |
| 167 group('xhr_requestBlob', () { | 168 group('xhr_requestBlob', () { |
| 168 test('XHR.request responseType blob', () { | 169 test('XHR.request responseType blob', () { |
| 169 if (Platform.supportsTypedData) { | 170 if (Platform.supportsTypedData) { |
| 170 return HttpRequest.request(url, responseType: 'blob').then( | 171 return HttpRequest.request(url, responseType: 'blob').then( |
| 171 (xhr) { | 172 (xhr) { |
| 172 expect(xhr.status, equals(200)); | 173 expect(xhr.status, equals(200)); |
| 173 var blob = xhr.response; | 174 var blob = xhr.response; |
| 174 expect(blob is Blob, isTrue); | 175 expect(blob is Blob, isTrue); |
| 175 expect(blob, isNotNull); | 176 expect(blob, isNotNull); |
| 176 }); | 177 }); |
| 177 } | 178 } |
| 178 }); | 179 }); |
| 179 }); | 180 }); |
| 180 } | 181 } |
| OLD | NEW |