| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 import 'dart:async'; | 5 import 'dart:async'; |
| 6 import 'dart:io'; | 6 import 'dart:io'; |
| 7 | 7 |
| 8 import "package:http_server/http_server.dart"; | 8 import "package:http_server/http_server.dart"; |
| 9 import 'package:path/path.dart' as pathos; | 9 import 'package:path/path.dart' as pathos; |
| 10 import "package:unittest/unittest.dart"; | 10 import "package:unittest/unittest.dart"; |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 virDir.allowDirectoryListing = true; | 135 virDir.allowDirectoryListing = true; |
| 136 | 136 |
| 137 return getAsString(virDir, '/alert(\'hacked!\');') | 137 return getAsString(virDir, '/alert(\'hacked!\');') |
| 138 .then((result) { | 138 .then((result) { |
| 139 expect(result, contains('/alert('hacked!');/')); | 139 expect(result, contains('/alert('hacked!');/')); |
| 140 }); | 140 }); |
| 141 }); | 141 }); |
| 142 | 142 |
| 143 testVirtualDir('non-ascii-dir', (dir) { | 143 testVirtualDir('non-ascii-dir', (dir) { |
| 144 var virDir = new VirtualDirectory(dir.path); | 144 var virDir = new VirtualDirectory(dir.path); |
| 145 new Directory('${dir.path}/æøå').createSync(); | 145 new Directory('${dir.path}/æø').createSync(); |
| 146 virDir.allowDirectoryListing = true; | 146 virDir.allowDirectoryListing = true; |
| 147 | 147 |
| 148 return getAsString(virDir, '/') | 148 return getAsString(virDir, '/') |
| 149 .then((result) { | 149 .then((result) { |
| 150 expect(result, contains('æøå')); | 150 expect(result, contains('æø')); |
| 151 }); | 151 }); |
| 152 }); | 152 }); |
| 153 | 153 |
| 154 testVirtualDir('content-type', (dir) { | 154 testVirtualDir('content-type', (dir) { |
| 155 var virDir = new VirtualDirectory(dir.path); | 155 var virDir = new VirtualDirectory(dir.path); |
| 156 virDir.allowDirectoryListing = true; | 156 virDir.allowDirectoryListing = true; |
| 157 | 157 |
| 158 return getHeaders(virDir, '/') | 158 return getHeaders(virDir, '/') |
| 159 .then((headers) { | 159 .then((headers) { |
| 160 var contentType = headers.contentType.toString(); | 160 var contentType = headers.contentType.toString(); |
| (...skipping 426 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 587 return virDir.serveFile(new File('${d.path}/file'), request); | 587 return virDir.serveFile(new File('${d.path}/file'), request); |
| 588 }; | 588 }; |
| 589 | 589 |
| 590 return getAsString(virDir, '/') | 590 return getAsString(virDir, '/') |
| 591 .then((result) { | 591 .then((result) { |
| 592 expect(result, 'file contents'); | 592 expect(result, 'file contents'); |
| 593 }); | 593 }); |
| 594 }); | 594 }); |
| 595 }); | 595 }); |
| 596 } | 596 } |
| OLD | NEW |