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

Side by Side Diff: tests/html/xhr_cross_origin_test.dart

Issue 218273002: Upgrading tests with unittest deprecations (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 8 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library XHRCrossOriginTest; 5 library XHRCrossOriginTest;
6 import '../../pkg/unittest/lib/unittest.dart'; 6 import '../../pkg/unittest/lib/unittest.dart';
7 import '../../pkg/unittest/lib/html_individual_config.dart'; 7 import '../../pkg/unittest/lib/html_individual_config.dart';
8 import 'dart:html'; 8 import 'dart:html';
9 import "dart:convert"; 9 import "dart:convert";
10 10
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 77
78 // Skip the rest if not supported. 78 // Skip the rest if not supported.
79 if (!HttpRequest.supportsCrossOrigin) { 79 if (!HttpRequest.supportsCrossOrigin) {
80 return; 80 return;
81 } 81 }
82 82
83 test('XHR Cross-domain', () { 83 test('XHR Cross-domain', () {
84 var url = '$host/root_dart/tests/html/xhr_cross_origin_data.txt'; 84 var url = '$host/root_dart/tests/html/xhr_cross_origin_data.txt';
85 var xhr = new HttpRequest(); 85 var xhr = new HttpRequest();
86 xhr.open('GET', url, async: true); 86 xhr.open('GET', url, async: true);
87 var validate = expectAsync1((data) { 87 var validate = expectAsync((data) {
88 expect(data, contains('feed')); 88 expect(data, contains('feed'));
89 expect(data['feed'], contains('entry')); 89 expect(data['feed'], contains('entry'));
90 expect(data, isMap); 90 expect(data, isMap);
91 }); 91 });
92 xhr.onReadyStateChange.listen((e) { 92 xhr.onReadyStateChange.listen((e) {
93 guardAsync(() { 93 guardAsync(() {
94 if (xhr.readyState == HttpRequest.DONE) { 94 if (xhr.readyState == HttpRequest.DONE) {
95 validate(JSON.decode(xhr.response)); 95 validate(JSON.decode(xhr.response));
96 } 96 }
97 }); 97 });
98 }); 98 });
99 xhr.send(); 99 xhr.send();
100 }); 100 });
101 101
102 test('XHR.getWithCredentials Cross-domain', () { 102 test('XHR.getWithCredentials Cross-domain', () {
103 var url = '$host/root_dart/tests/html/xhr_cross_origin_data.txt'; 103 var url = '$host/root_dart/tests/html/xhr_cross_origin_data.txt';
104 return HttpRequest.request(url, withCredentials: true).then((xhr) { 104 return HttpRequest.request(url, withCredentials: true).then((xhr) {
105 var data = JSON.decode(xhr.response); 105 var data = JSON.decode(xhr.response);
106 expect(data, contains('feed')); 106 expect(data, contains('feed'));
107 expect(data['feed'], contains('entry')); 107 expect(data['feed'], contains('entry'));
108 expect(data, isMap); 108 expect(data, isMap);
109 }); 109 });
110 }); 110 });
111 }); 111 });
112 } 112 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698