| 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 FormDataTest; | 5 library FormDataTest; |
| 6 | 6 |
| 7 import 'package:unittest/unittest.dart'; | 7 import 'package:unittest/unittest.dart'; |
| 8 import 'package:unittest/html_individual_config.dart'; | 8 import 'package:unittest/html_individual_config.dart'; |
| 9 import 'dart:html'; | 9 import 'dart:html'; |
| 10 | 10 |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 var blob = new Blob( | 56 var blob = new Blob( |
| 57 ['Indescribable... Indestructible! Nothing can stop it!'], | 57 ['Indescribable... Indestructible! Nothing can stop it!'], |
| 58 'text/plain'); | 58 'text/plain'); |
| 59 form.appendBlob('theBlob', blob, 'theBlob.txt'); | 59 form.appendBlob('theBlob', blob, 'theBlob.txt'); |
| 60 }); | 60 }); |
| 61 | 61 |
| 62 test('send', () { | 62 test('send', () { |
| 63 var form = new FormData(); | 63 var form = new FormData(); |
| 64 var blobString = | 64 var blobString = |
| 65 'Indescribable... Indestructible! Nothing can stop it!'; | 65 'Indescribable... Indestructible! Nothing can stop it!'; |
| 66 var blob = new Blob( | 66 var blob = new Blob([blobString], 'text/plain'); |
| 67 [blobString], | |
| 68 'text/plain'); | |
| 69 form.appendBlob('theBlob', blob, 'theBlob.txt'); | 67 form.appendBlob('theBlob', blob, 'theBlob.txt'); |
| 70 | 68 |
| 71 var xhr = new HttpRequest(); | 69 var xhr = new HttpRequest(); |
| 72 xhr.open('POST', | 70 xhr.open('POST', |
| 73 '${window.location.protocol}//${window.location.host}/echo'); | 71 '${window.location.protocol}//${window.location.host}/echo'); |
| 74 | 72 |
| 75 xhr.onLoad.listen(expectAsync((e) { | 73 xhr.onLoad.listen(expectAsync((e) { |
| 76 expect(xhr.responseText, contains(blobString)); | 74 expect(xhr.responseText, contains(blobString)); |
| 77 })); | 75 })); |
| 78 xhr.onError.listen((e) { | 76 xhr.onError.listen((e) { |
| 79 fail('$e'); | 77 fail('$e'); |
| 80 }); | 78 }); |
| 81 xhr.send(form); | 79 xhr.send(form); |
| 82 }); | 80 }); |
| 83 } | 81 } |
| 84 }); | 82 }); |
| 85 } | 83 } |
| OLD | NEW |