| Index: tests/html/xhr_test.dart
|
| diff --git a/tests/html/xhr_test.dart b/tests/html/xhr_test.dart
|
| index b5ea6c1cb0a1dfb6947581edf24f5e42d9311888..288f068f6d46046f461357643e869bc55c655c90 100644
|
| --- a/tests/html/xhr_test.dart
|
| +++ b/tests/html/xhr_test.dart
|
| @@ -10,24 +10,68 @@ import 'dart:json';
|
|
|
| main() {
|
| useHtmlConfiguration();
|
| + var url = "../../../../tests/html/xhr_cross_origin_data.txt";
|
|
|
| test('XHR No file', () {
|
| HttpRequest xhr = new HttpRequest();
|
| xhr.open("GET", "NonExistingFile", true);
|
| - xhr.on.readyStateChange.add(expectAsync1((event) {
|
| + xhr.on.readyStateChange.add(expectAsyncUntil1((event) {
|
| if (xhr.readyState == HttpRequest.DONE) {
|
| - expect(xhr.status, equals(0));
|
| + expect(xhr.status, equals(404));
|
| expect(xhr.responseText, equals(''));
|
| }
|
| - }));
|
| + }, () => xhr.readyState == HttpRequest.DONE));
|
| + xhr.send();
|
| + });
|
| +
|
| + test('XHR file', () {
|
| + var xhr = new HttpRequest();
|
| + xhr.open('GET', url, true);
|
| + xhr.on.readyStateChange.add(expectAsyncUntil1((e) {
|
| + if (xhr.readyState == HttpRequest.DONE) {
|
| + expect(xhr.status, equals(200));
|
| + var data = JSON.parse(xhr.response);
|
| + expect(data, contains('feed'));
|
| + expect(data['feed'], contains('entry'));
|
| + expect(data, isMap);
|
| + }
|
| + }, () => xhr.readyState == HttpRequest.DONE));
|
| xhr.send();
|
| });
|
|
|
| test('XHR.get No file', () {
|
| new HttpRequest.get("NonExistingFile", expectAsync1((xhr) {
|
| expect(xhr.readyState, equals(HttpRequest.DONE));
|
| - expect(xhr.status, equals(0));
|
| + expect(xhr.status, equals(404));
|
| expect(xhr.responseText, equals(''));
|
| }));
|
| });
|
| +
|
| + test('XHR.get file', () {
|
| + var xhr = new HttpRequest.get(url, expectAsync1((xhr) {
|
| + expect(xhr.readyState, equals(HttpRequest.DONE));
|
| + expect(xhr.status, equals(200));
|
| + var data = JSON.parse(xhr.response);
|
| + expect(data, contains('feed'));
|
| + expect(data['feed'], contains('entry'));
|
| + expect(data, isMap);
|
| + }));
|
| + });
|
| +
|
| + test('XHR.getWithCredentials No file', () {
|
| + new HttpRequest.getWithCredentials("NonExistingFile", expectAsync1((xhr) {
|
| + expect(xhr.status, equals(404));
|
| + expect(xhr.responseText, equals(''));
|
| + }));
|
| + });
|
| +
|
| + test('XHR.getWithCredentials file', () {
|
| + new HttpRequest.getWithCredentials(url, expectAsync1((xhr) {
|
| + expect(xhr.status, equals(200));
|
| + var data = JSON.parse(xhr.response);
|
| + expect(data, contains('feed'));
|
| + expect(data['feed'], contains('entry'));
|
| + expect(data, isMap);
|
| + }));
|
| + });
|
| }
|
|
|