Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1207)

Unified Diff: tests/html/xhr_test.dart

Issue 11641005: Add cross-origin test with credentials. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 12 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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);
+ }));
+ });
}

Powered by Google App Engine
This is Rietveld 408576698