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

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

Issue 12625006: Fixing IE10 CORS test. (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 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_config.dart'; 7 import '../../pkg/unittest/lib/html_config.dart';
8 import 'dart:html'; 8 import 'dart:html';
9 import 'dart:json' as json; 9 import 'dart:json' as json;
10 10
(...skipping 10 matching lines...) Expand all
21 var index = searchUrl.indexOf(crossOriginStr); 21 var index = searchUrl.indexOf(crossOriginStr);
22 var nextArg = searchUrl.indexOf('&', index); 22 var nextArg = searchUrl.indexOf('&', index);
23 return int.parse(searchUrl.substring(index + crossOriginStr.length, 23 return int.parse(searchUrl.substring(index + crossOriginStr.length,
24 nextArg == -1 ? searchUrl.length : nextArg)); 24 nextArg == -1 ? searchUrl.length : nextArg));
25 } 25 }
26 26
27 main() { 27 main() {
28 useHtmlConfiguration(); 28 useHtmlConfiguration();
29 29
30 var port = crossOriginPort; 30 var port = crossOriginPort;
31 var host = '${window.location.protocol}//${window.location.hostname}:$port';
31 32
32 test('XHR Cross-domain', () { 33 test('XHR Cross-domain', () {
33 var url = "http://localhost:$port/" 34 var url = '$host/root_dart/tests/html/xhr_cross_origin_data.txt';
34 "root_dart/tests/html/xhr_cross_origin_data.txt";
35 var xhr = new HttpRequest(); 35 var xhr = new HttpRequest();
36 xhr.open('GET', url, async: true); 36 xhr.open('GET', url, async: true);
37 xhr.withCredentials = true;
37 var validate = expectAsync1((data) { 38 var validate = expectAsync1((data) {
38 expect(data, contains('feed')); 39 expect(data, contains('feed'));
39 expect(data['feed'], contains('entry')); 40 expect(data['feed'], contains('entry'));
40 expect(data, isMap); 41 expect(data, isMap);
41 }); 42 });
42 xhr.onReadyStateChange.listen((e) { 43 xhr.onReadyStateChange.listen((e) {
43 guardAsync(() { 44 guardAsync(() {
44 if (xhr.readyState == HttpRequest.DONE) { 45 if (xhr.readyState == HttpRequest.DONE) {
45 validate(json.parse(xhr.response)); 46 validate(json.parse(xhr.response));
46 } 47 }
47 }); 48 });
48 }); 49 });
49 xhr.send(); 50 xhr.send();
50 }); 51 });
51 52
52 test('XHR.get Cross-domain', () { 53 test('XHR.get Cross-domain', () {
53 var url = "http://localhost:$port/" 54 var url = '$host/root_dart/tests/html/xhr_cross_origin_data.txt';
54 "root_dart/tests/html/xhr_cross_origin_data.txt";
55 HttpRequest.request(url).then(expectAsync1((xhr) { 55 HttpRequest.request(url).then(expectAsync1((xhr) {
56 var data = json.parse(xhr.response); 56 var data = json.parse(xhr.response);
57 expect(data, contains('feed')); 57 expect(data, contains('feed'));
58 expect(data['feed'], contains('entry')); 58 expect(data['feed'], contains('entry'));
59 expect(data, isMap); 59 expect(data, isMap);
60 })); 60 }));
61 }); 61 });
62 62
63 test('XHR.getWithCredentials Cross-domain', () { 63 test('XHR.getWithCredentials Cross-domain', () {
64 var url = "http://localhost:$port/" 64 var url = '$host/root_dart/tests/html/xhr_cross_origin_data.txt';
65 "root_dart/tests/html/xhr_cross_origin_data.txt";
66 HttpRequest.request(url, withCredentials: true).then(expectAsync1((xhr) { 65 HttpRequest.request(url, withCredentials: true).then(expectAsync1((xhr) {
67 var data = json.parse(xhr.response); 66 var data = json.parse(xhr.response);
68 expect(data, contains('feed')); 67 expect(data, contains('feed'));
69 expect(data['feed'], contains('entry')); 68 expect(data['feed'], contains('entry'));
70 expect(data, isMap); 69 expect(data, isMap);
71 })); 70 }));
72 }); 71 });
73 } 72 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698