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

Unified Diff: tests/html/xhr_cross_origin_test.dart

Issue 12707003: Revert the revert. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 9 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
« no previous file with comments | « tests/html/html.status ('k') | tools/dom/templates/html/impl/impl_XMLHttpRequest.darttemplate » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/html/xhr_cross_origin_test.dart
diff --git a/tests/html/xhr_cross_origin_test.dart b/tests/html/xhr_cross_origin_test.dart
index 77500467fef5ee23445d6d76791a6daa210a7895..cb56240317d654bb84b42d85b718bc9a035c473f 100644
--- a/tests/html/xhr_cross_origin_test.dart
+++ b/tests/html/xhr_cross_origin_test.dart
@@ -4,7 +4,7 @@
library XHRCrossOriginTest;
import '../../pkg/unittest/lib/unittest.dart';
-import '../../pkg/unittest/lib/html_config.dart';
+import '../../pkg/unittest/lib/html_individual_config.dart';
import 'dart:html';
import 'dart:json' as json;
@@ -25,47 +25,69 @@ int get crossOriginPort {
}
main() {
- useHtmlConfiguration();
+ useHtmlIndividualConfiguration();
- var port = crossOriginPort;
- var host = '${window.location.protocol}//${window.location.hostname}:$port';
-
- test('XHR Cross-domain', () {
- var url = '$host/root_dart/tests/html/xhr_cross_origin_data.txt';
- var xhr = new HttpRequest();
- xhr.open('GET', url, async: true);
- var validate = expectAsync1((data) {
- expect(data, contains('feed'));
- expect(data['feed'], contains('entry'));
- expect(data, isMap);
+ group('supported', () {
+ test('supported', () {
+ expect(HttpRequest.supportsCrossOrigin, isTrue);
});
- xhr.onReadyStateChange.listen((e) {
- guardAsync(() {
- if (xhr.readyState == HttpRequest.DONE) {
- validate(json.parse(xhr.response));
- }
+ });
+
+ group('functional', () {
+
+ var port = crossOriginPort;
+ var host = '${window.location.protocol}//${window.location.hostname}:$port';
+
+ test('XHR.get Cross-domain', () {
+ var gotError = false;
+ var url = '$host/root_dart/tests/html/xhr_cross_origin_data.txt';
+ return HttpRequest.request(url).then((xhr) {
+ var data = json.parse(xhr.response);
+ expect(data, contains('feed'));
+ expect(data['feed'], contains('entry'));
+ expect(data, isMap);
+ }).catchError((error) {}, test: (error) {
+ gotError = true;
+ // Consume errors when not supporting cross origin.
+ return !HttpRequest.supportsCrossOrigin;
+ }).whenComplete(() {
+ // Expect that we got an error when cross origin is not supported.
+ expect(gotError, !HttpRequest.supportsCrossOrigin);
});
});
- xhr.send();
- });
- test('XHR.get Cross-domain', () {
- var url = '$host/root_dart/tests/html/xhr_cross_origin_data.txt';
- HttpRequest.request(url).then(expectAsync1((xhr) {
- var data = json.parse(xhr.response);
- expect(data, contains('feed'));
- expect(data['feed'], contains('entry'));
- expect(data, isMap);
- }));
- });
+ // Skip the rest if not supported.
+ if (!HttpRequest.supportsCrossOrigin) {
+ return;
+ }
- test('XHR.getWithCredentials Cross-domain', () {
- var url = '$host/root_dart/tests/html/xhr_cross_origin_data.txt';
- HttpRequest.request(url, withCredentials: true).then(expectAsync1((xhr) {
- var data = json.parse(xhr.response);
- expect(data, contains('feed'));
- expect(data['feed'], contains('entry'));
- expect(data, isMap);
- }));
+ test('XHR Cross-domain', () {
+ var url = '$host/root_dart/tests/html/xhr_cross_origin_data.txt';
+ var xhr = new HttpRequest();
+ xhr.open('GET', url, async: true);
+ var validate = expectAsync1((data) {
+ expect(data, contains('feed'));
+ expect(data['feed'], contains('entry'));
+ expect(data, isMap);
+ });
+ xhr.onReadyStateChange.listen((e) {
+ guardAsync(() {
+ if (xhr.readyState == HttpRequest.DONE) {
+ validate(json.parse(xhr.response));
+ }
+ });
+ });
+ xhr.send();
+ });
+
+ test('XHR.getWithCredentials Cross-domain', () {
+ var url = '$host/root_dart/tests/html/xhr_cross_origin_data.txt';
+ return HttpRequest.request(url, withCredentials: true).then((xhr) {
+ var data = json.parse(xhr.response);
+ expect(data, contains('feed'));
+ expect(data['feed'], contains('entry'));
+ expect(data, isMap);
+ });
+ });
});
}
« no previous file with comments | « tests/html/html.status ('k') | tools/dom/templates/html/impl/impl_XMLHttpRequest.darttemplate » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698