Chromium Code Reviews| Index: tests/html/xhr_test.dart |
| diff --git a/tests/html/xhr_test.dart b/tests/html/xhr_test.dart |
| index d590acec6f227117f48a4e5c8f6bc69f4c84529a..0a1f77a18dfa8662e20e4c05331fd66038720127 100644 |
| --- a/tests/html/xhr_test.dart |
| +++ b/tests/html/xhr_test.dart |
| @@ -5,6 +5,7 @@ |
| library XHRTest; |
| import '../../pkg/unittest/lib/unittest.dart'; |
| import '../../pkg/unittest/lib/html_individual_config.dart'; |
| +import 'dart:async'; |
| import 'dart:html'; |
| import 'dart:json' as json; |
| @@ -20,7 +21,7 @@ main() { |
| void validate200Response(xhr) { |
| expect(xhr.status, equals(200)); |
| - var data = json.parse(xhr.response); |
| + var data = json.parse(xhr.responseText); |
| expect(data, contains('feed')); |
| expect(data['feed'], contains('entry')); |
| expect(data, isMap); |
| @@ -37,31 +38,54 @@ main() { |
| }); |
| }); |
| - group('xhr', () { |
| - test('XHR No file', () { |
| - HttpRequest xhr = new HttpRequest(); |
| - xhr.open("GET", "NonExistingFile", true); |
| - xhr.onReadyStateChange.listen(expectAsyncUntil1((event) { |
| - if (xhr.readyState == HttpRequest.DONE) { |
| - validate404(xhr); |
| - } |
| - }, () => xhr.readyState == HttpRequest.DONE)); |
| - xhr.send(); |
| + group('supported_onProgress', () { |
| + test('XHR.request onProgress', () { |
|
Emily Fortuna
2013/02/14 21:56:23
this doesn't actually perform a supported check ..
blois
2013/02/14 23:22:45
Yeah, I was thinking that it was sufficient to jus
|
| + var progressCalled = false; |
| + HttpRequest.request(url, |
| + onProgress: (_) { |
| + progressCalled = true; |
| + }).then(expectAsync1( |
| + (xhr) { |
| + expect(xhr.readyState, equals(HttpRequest.DONE)); |
| + expect(progressCalled, isTrue); |
| + validate200Response(xhr); |
| + })); |
| }); |
| + }); |
| + group('supported_onLoadEnd', () { |
| test('XHR file', () { |
| + var loadEndCalled = false; |
| + |
| var xhr = new HttpRequest(); |
| xhr.open('GET', url, true); |
| xhr.onReadyStateChange.listen(expectAsyncUntil1((e) { |
| if (xhr.readyState == HttpRequest.DONE) { |
| validate200Response(xhr); |
| + |
| + Timer.run(expectAsync0(() { |
| + expect(loadEndCalled, true); |
| + })); |
| } |
| }, () => xhr.readyState == HttpRequest.DONE)); |
| - xhr.onLoadEnd.listen(expectAsync1((ProgressEvent e) { |
| - expect(e.currentTarget, xhr); |
| - expect(e.target, xhr); |
| - })); |
| + |
| + xhr.onLoadEnd.listen((ProgressEvent e) { |
| + loadEndCalled = true; |
| + }); |
| + xhr.send(); |
| + }); |
| + }); |
| + |
| + group('xhr', () { |
| + test('XHR No file', () { |
| + HttpRequest xhr = new HttpRequest(); |
| + xhr.open("GET", "NonExistingFile", true); |
| + xhr.onReadyStateChange.listen(expectAsyncUntil1((event) { |
| + if (xhr.readyState == HttpRequest.DONE) { |
| + validate404(xhr); |
| + } |
| + }, () => xhr.readyState == HttpRequest.DONE)); |
| xhr.send(); |
| }); |
| @@ -82,19 +106,6 @@ main() { |
| })); |
| }); |
| - test('XHR.request onProgress', () { |
| - var progressCalled = false; |
| - HttpRequest.request(url, |
| - onProgress: (_) { |
| - progressCalled = true; |
| - }).then(expectAsync1( |
| - (xhr) { |
| - expect(xhr.readyState, equals(HttpRequest.DONE)); |
| - expect(progressCalled, isTrue); |
| - validate200Response(xhr); |
| - })); |
| - }); |
| - |
| test('XHR.request withCredentials No file', () { |
| HttpRequest.request('NonExistingFile', withCredentials: true).then( |
| (_) { fail('Request should not have succeeded.'); }, |