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

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

Issue 22227003: Adding HttpRequest method to make it easier to post form data. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 4 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 XHRTest; 5 library XHRTest;
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:async'; 8 import 'dart:async';
9 import 'dart:html'; 9 import 'dart:html';
10 import 'dart:json' as json; 10 import 'dart:json' as json;
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 for (var i = 0; i < data.length; ++i) { 201 for (var i = 0; i < data.length; ++i) {
202 data[i] = i & 0xFF; 202 data[i] = i & 0xFF;
203 } 203 }
204 xhr.send(data); 204 xhr.send(data);
205 205
206 return xhr.onLoad.first.then((_) { 206 return xhr.onLoad.first.then((_) {
207 expect(progressCalled, isTrue); 207 expect(progressCalled, isTrue);
208 }); 208 });
209 }); 209 });
210 } 210 }
211
212 test('xhr postFormData', () {
213 var data = { 'name': 'John', 'time': '2 pm' };
214
215 var parts = [];
216 for (var key in data.keys) {
217 parts.add('${Uri.encodeQueryComponent(key)}='
218 '${Uri.encodeQueryComponent(data[key])}');
219 }
220 var encodedData = parts.join('&');
221
222 return HttpRequest.postFormData(
223 '${window.location.protocol}//${window.location.host}/echo', data)
224 .then((xhr) {
225 expect(xhr.responseText, encodedData);
226 });
227 });
228
211 }); 229 });
212 230
213 group('xhr_requestBlob', () { 231 group('xhr_requestBlob', () {
214 test('XHR.request responseType blob', () { 232 test('XHR.request responseType blob', () {
215 if (Platform.supportsTypedData) { 233 if (Platform.supportsTypedData) {
216 return HttpRequest.request(url, responseType: 'blob').then( 234 return HttpRequest.request(url, responseType: 'blob').then(
217 (xhr) { 235 (xhr) {
218 expect(xhr.status, equals(200)); 236 expect(xhr.status, equals(200));
219 var blob = xhr.response; 237 var blob = xhr.response;
220 expect(blob is Blob, isTrue); 238 expect(blob is Blob, isTrue);
221 expect(blob, isNotNull); 239 expect(blob, isNotNull);
222 }); 240 });
223 } 241 }
224 }); 242 });
225 }); 243 });
226 } 244 }
OLDNEW
« no previous file with comments | « sdk/lib/html/dartium/html_dartium.dart ('k') | tools/dom/templates/html/impl/impl_XMLHttpRequest.darttemplate » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698