Chromium Code Reviews| 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 d39af2c85e388bcfdb6e6e60f0f352ff50b9f429..a6f64719d348349855feadb96baf5e1cb4fa7d23 100644 |
| --- a/tests/html/xhr_cross_origin_test.dart |
| +++ b/tests/html/xhr_cross_origin_test.dart |
| @@ -8,11 +8,29 @@ import '../../pkg/unittest/lib/html_config.dart'; |
| import 'dart:html'; |
| import 'dart:json'; |
| +/** |
| + * Examine the value of "crossOriginPort" as passed in from the url from |
| + * [window.location] to determine what the cross-origin port is for |
| + * this test. |
| + */ |
| + // TODO(efortuna): If we need to use this function frequently, make a |
| + // url_analyzer library that is part of test.dart that these tests can import. |
| +int get getCrossOriginPort { |
|
Siggi Cherem (dart-lang)
2013/01/05 00:31:10
nit: get rid of the 'get' prefix in the name. Simp
|
| + var searchUrl = window.location.search; |
| + var crossOriginStr = 'crossOriginPort='; |
| + var index = searchUrl.indexOf(crossOriginStr); |
| + var nextArg = searchUrl.indexOf('&', index); |
| + return int.parse(searchUrl.substring(index + crossOriginStr.length, |
| + nextArg == -1 ? searchUrl.length : nextArg)); |
| +} |
| + |
| main() { |
| useHtmlConfiguration(); |
| + var port = getCrossOriginPort; |
| + |
| test('XHR Cross-domain', () { |
| - var url = "http://localhost:9876/tests/html/xhr_cross_origin_data.txt"; |
| + var url = "http://localhost:$port/tests/html/xhr_cross_origin_data.txt"; |
| var xhr = new HttpRequest(); |
| xhr.open('GET', url, true); |
| var validate = expectAsync1((data) { |
| @@ -31,7 +49,7 @@ main() { |
| }); |
| test('XHR.get Cross-domain', () { |
| - var url = "http://localhost:9876/tests/html/xhr_cross_origin_data.txt"; |
| + var url = "http://localhost:$port/tests/html/xhr_cross_origin_data.txt"; |
| new HttpRequest.get(url, expectAsync1((xhr) { |
| var data = JSON.parse(xhr.response); |
| expect(data, contains('feed')); |
| @@ -39,4 +57,14 @@ main() { |
| expect(data, isMap); |
| })); |
| }); |
| + |
| + test('XHR.getWithCredentials Cross-domain', () { |
| + var url = "http://localhost:$port/tests/html/xhr_cross_origin_data.txt"; |
| + new HttpRequest.getWithCredentials(url, expectAsync1((xhr) { |
| + var data = JSON.parse(xhr.response); |
| + expect(data, contains('feed')); |
| + expect(data['feed'], contains('entry')); |
| + expect(data, isMap); |
| + })); |
| + }); |
| } |