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

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

Issue 360453004: Use utf-8 encoding for listing and error page, in http_server VirtualDirectory. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Update right pubspec... 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 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 var virDir = new VirtualDirectory(dir.path); 133 var virDir = new VirtualDirectory(dir.path);
134 new Directory('${dir.path}/alert(\'hacked!\');').createSync(); 134 new Directory('${dir.path}/alert(\'hacked!\');').createSync();
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) {
144 var virDir = new VirtualDirectory(dir.path);
145 new Directory('${dir.path}/æøå').createSync();
146 virDir.allowDirectoryListing = true;
147
148 return getAsString(virDir, '/')
149 .then((result) {
150 expect(result, contains('æøå'));
151 });
152 });
153
154 testVirtualDir('content-type', (dir) {
155 var virDir = new VirtualDirectory(dir.path);
156 virDir.allowDirectoryListing = true;
157
158 return getHeaders(virDir, '/')
159 .then((headers) {
160 var contentType = headers.contentType.toString();
161 expect(contentType, 'text/html; charset=utf-8');
162 });
163 });
164
143 if (!Platform.isWindows) { 165 if (!Platform.isWindows) {
144 testVirtualDir('recursive-link', (dir) { 166 testVirtualDir('recursive-link', (dir) {
145 var link = new Link('${dir.path}/recursive')..createSync('.'); 167 var link = new Link('${dir.path}/recursive')..createSync('.');
146 var virDir = new VirtualDirectory(dir.path); 168 var virDir = new VirtualDirectory(dir.path);
147 virDir.allowDirectoryListing = true; 169 virDir.allowDirectoryListing = true;
148 170
149 return Future.wait([ 171 return Future.wait([
150 getAsString(virDir, '/').then( 172 getAsString(virDir, '/').then(
151 (s) => s.contains('recursive/')), 173 (s) => s.contains('recursive/')),
152 getAsString(virDir, '/').then( 174 getAsString(virDir, '/').then(
(...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after
565 return virDir.serveFile(new File('${d.path}/file'), request); 587 return virDir.serveFile(new File('${d.path}/file'), request);
566 }; 588 };
567 589
568 return getAsString(virDir, '/') 590 return getAsString(virDir, '/')
569 .then((result) { 591 .then((result) {
570 expect(result, 'file contents'); 592 expect(result, 'file contents');
571 }); 593 });
572 }); 594 });
573 }); 595 });
574 } 596 }
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