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

Unified Diff: tests/html/xhr_test.dart

Issue 23454012: Adding conversion support for JSON XHR requests. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 3 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/scripts/generator.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/html/xhr_test.dart
diff --git a/tests/html/xhr_test.dart b/tests/html/xhr_test.dart
index b5c538b890047c85cd14be2f9f1ca9f49b15b0d1..989488807a0dceea856de92e58b70aed610500d0 100644
--- a/tests/html/xhr_test.dart
+++ b/tests/html/xhr_test.dart
@@ -3,12 +3,12 @@
// BSD-style license that can be found in the LICENSE file.
library XHRTest;
-import '../../pkg/unittest/lib/unittest.dart';
-import '../../pkg/unittest/lib/html_individual_config.dart';
import 'dart:async';
+import 'dart:convert';
import 'dart:html';
-import "dart:convert";
import 'dart:typed_data';
+import 'package:unittest/html_individual_config.dart';
+import 'package:unittest/unittest.dart';
void fail(message) {
guardAsync(() {
@@ -225,7 +225,6 @@ main() {
expect(xhr.responseText, encodedData);
});
});
-
});
group('xhr_requestBlob', () {
@@ -241,4 +240,25 @@ main() {
}
});
});
+
+ group('json', () {
+ test('xhr responseType json', () {
+ var url = '${window.location.protocol}//${window.location.host}/echo';
+ var data = {
+ 'key': 'value',
+ 'a': 'b',
+ 'one': 2,
+ };
+
+ HttpRequest.request(url,
+ method: 'POST',
+ sendData: JSON.encode(data),
+ responseType: 'json').then(
+ expectAsync1((xhr) {
+ expect(xhr.status, equals(200));
+ var json = xhr.response;
+ expect(json, equals(data));
+ }));
+ });
+ });
}
« no previous file with comments | « tests/html/html.status ('k') | tools/dom/scripts/generator.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698