| OLD | NEW |
| 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 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 = expectAsync((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 if (xhr.readyState == HttpRequest.DONE) { |
| 94 if (xhr.readyState == HttpRequest.DONE) { | 94 validate(JSON.decode(xhr.response)); |
| 95 validate(JSON.decode(xhr.response)); | 95 } |
| 96 } | |
| 97 }); | |
| 98 }); | 96 }); |
| 99 xhr.send(); | 97 xhr.send(); |
| 100 }); | 98 }); |
| 101 | 99 |
| 102 test('XHR.getWithCredentials Cross-domain', () { | 100 test('XHR.getWithCredentials Cross-domain', () { |
| 103 var url = '$host/root_dart/tests/html/xhr_cross_origin_data.txt'; | 101 var url = '$host/root_dart/tests/html/xhr_cross_origin_data.txt'; |
| 104 return HttpRequest.request(url, withCredentials: true).then((xhr) { | 102 return HttpRequest.request(url, withCredentials: true).then((xhr) { |
| 105 var data = JSON.decode(xhr.response); | 103 var data = JSON.decode(xhr.response); |
| 106 expect(data, contains('feed')); | 104 expect(data, contains('feed')); |
| 107 expect(data['feed'], contains('entry')); | 105 expect(data['feed'], contains('entry')); |
| 108 expect(data, isMap); | 106 expect(data, isMap); |
| 109 }); | 107 }); |
| 110 }); | 108 }); |
| 111 }); | 109 }); |
| 112 } | 110 } |
| OLD | NEW |