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 '../../pkg/unittest/lib/unittest.dart'; | 7 import '../../pkg/unittest/lib/unittest.dart'; |
8 import '../../pkg/unittest/lib/html_config.dart'; | 8 import '../../pkg/unittest/lib/html_config.dart'; |
9 import 'dart:html'; | 9 import 'dart:html'; |
10 | 10 |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 | 52 |
53 test('send', () { | 53 test('send', () { |
54 var form = new FormData(); | 54 var form = new FormData(); |
55 var blobString = 'Indescribable... Indestructible! Nothing can stop it!'; | 55 var blobString = 'Indescribable... Indestructible! Nothing can stop it!'; |
56 var blob = new Blob( | 56 var blob = new Blob( |
57 [blobString], | 57 [blobString], |
58 'text/plain'); | 58 'text/plain'); |
59 form.append('theBlob', blob, 'theBlob.txt'); | 59 form.append('theBlob', blob, 'theBlob.txt'); |
60 | 60 |
61 var xhr = new HttpRequest(); | 61 var xhr = new HttpRequest(); |
62 xhr.open("POST", "http://localhost:9876/echo"); | 62 xhr.open("POST", "http://localhost:${window.location.port}/echo"); |
63 | 63 |
64 xhr.on.load.add(expectAsync1((e) { | 64 xhr.on.load.add(expectAsync1((e) { |
65 expect(xhr.responseText.contains(blobString), true); | 65 expect(xhr.responseText.contains(blobString), true); |
66 })); | 66 })); |
67 xhr.on.error.add((e) { | 67 xhr.on.error.add((e) { |
68 fail('$e'); | 68 fail('$e'); |
69 }); | 69 }); |
70 xhr.send(form); | 70 xhr.send(form); |
71 }); | 71 }); |
72 } | 72 } |
OLD | NEW |