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

Side by Side Diff: pkg/http_server/test/virtual_directory_test.dart

Issue 370753002: Fix links of VirtualDirectory. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 5 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
« no previous file with comments | « pkg/http_server/pubspec.yaml ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 new File('${dir.path}/$i').createSync(); 109 new File('${dir.path}/$i').createSync();
110 } 110 }
111 virDir.allowDirectoryListing = true; 111 virDir.allowDirectoryListing = true;
112 112
113 return getAsString(virDir, '/') 113 return getAsString(virDir, '/')
114 .then((result) { 114 .then((result) {
115 expect(result, contains('Index of &#x2F')); 115 expect(result, contains('Index of &#x2F'));
116 }); 116 });
117 }); 117 });
118 118
119 testVirtualDir('dir-href', (dir) {
120 var virDir = new VirtualDirectory(dir.path);
121 new Directory('${dir.path}/dir').createSync();
122 virDir.allowDirectoryListing = true;
123
124 return getAsString(virDir, '/')
125 .then((result) {
126 expect(result, contains('<a href="dir/">'));
127 });
128 });
129
119 testVirtualDir('dirs', (dir) { 130 testVirtualDir('dirs', (dir) {
120 var virDir = new VirtualDirectory(dir.path); 131 var virDir = new VirtualDirectory(dir.path);
121 for (int i = 0; i < 10; i++) { 132 for (int i = 0; i < 10; i++) {
122 new Directory('${dir.path}/$i').createSync(); 133 new Directory('${dir.path}/$i').createSync();
123 } 134 }
124 virDir.allowDirectoryListing = true; 135 virDir.allowDirectoryListing = true;
125 136
126 return getAsString(virDir, '/') 137 return getAsString(virDir, '/')
127 .then((result) { 138 .then((result) {
128 expect(result, contains('Index of &#x2F')); 139 expect(result, contains('Index of &#x2F'));
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 }); 198 });
188 199
189 testVirtualDir('encoded-path', (dir) { 200 testVirtualDir('encoded-path', (dir) {
190 var virDir = new VirtualDirectory(dir.path); 201 var virDir = new VirtualDirectory(dir.path);
191 new Directory('${dir.path}/javascript:alert(document);"') 202 new Directory('${dir.path}/javascript:alert(document);"')
192 .createSync(); 203 .createSync();
193 virDir.allowDirectoryListing = true; 204 virDir.allowDirectoryListing = true;
194 205
195 return getAsString(virDir, '/') 206 return getAsString(virDir, '/')
196 .then((result) { 207 .then((result) {
197 expect(result, contains('%2Fjavascript%3Aalert(document)%3B%22')); 208 expect(result, contains('javascript%3Aalert(document)%3B%22/'));
198 }); 209 });
199 }); 210 });
200 211
201 testVirtualDir('encoded-special', (dir) { 212 testVirtualDir('encoded-special', (dir) {
202 var virDir = new VirtualDirectory(dir.path); 213 var virDir = new VirtualDirectory(dir.path);
203 new Directory('${dir.path}/<>&"').createSync(); 214 new Directory('${dir.path}/<>&"').createSync();
204 virDir.allowDirectoryListing = true; 215 virDir.allowDirectoryListing = true;
205 216
206 return getAsString(virDir, '/') 217 return getAsString(virDir, '/')
207 .then((result) { 218 .then((result) {
208 expect(result, contains('&lt;&gt;&amp;&quot;&#x2F;')); 219 expect(result, contains('&lt;&gt;&amp;&quot;&#x2F;'));
209 expect(result, contains('href="%2F%3C%3E%26%22"')); 220 expect(result, contains('href="%3C%3E%26%22/"'));
210 }); 221 });
211 }); 222 });
212 } 223 }
213 }); 224 });
214 225
215 group('custom', () { 226 group('custom', () {
216 testVirtualDir('simple', (dir) { 227 testVirtualDir('simple', (dir) {
217 var virDir = new VirtualDirectory(dir.path); 228 var virDir = new VirtualDirectory(dir.path);
218 virDir.allowDirectoryListing = true; 229 virDir.allowDirectoryListing = true;
219 virDir.directoryHandler = (dir2, request) { 230 virDir.directoryHandler = (dir2, request) {
(...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after
587 return virDir.serveFile(new File('${d.path}/file'), request); 598 return virDir.serveFile(new File('${d.path}/file'), request);
588 }; 599 };
589 600
590 return getAsString(virDir, '/') 601 return getAsString(virDir, '/')
591 .then((result) { 602 .then((result) {
592 expect(result, 'file contents'); 603 expect(result, 'file contents');
593 }); 604 });
594 }); 605 });
595 }); 606 });
596 } 607 }
OLDNEW
« no previous file with comments | « pkg/http_server/pubspec.yaml ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698