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

Unified Diff: tests/compiler/dart2js/http_test.dart

Issue 557383002: dart2js: Support https. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tests/compiler/dart2js/http_launch_data/pkcert/key4.db ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/compiler/dart2js/http_test.dart
diff --git a/tests/compiler/dart2js/http_test.dart b/tests/compiler/dart2js/http_test.dart
index 29c22007829ca0653e60eb756711e0c189f2577a..2478980c4e28e4a15406d10ec7b118e4546c79f5 100644
--- a/tests/compiler/dart2js/http_test.dart
+++ b/tests/compiler/dart2js/http_test.dart
@@ -16,9 +16,11 @@ import 'package:expect/expect.dart';
import 'package:path/path.dart' as path;
Uri pathOfData = Platform.script.resolve('http_launch_data/');
+Uri pathOfPkcert = pathOfData.resolve('pkcert');
int port;
Directory tempDir;
String outFilePath;
+String scheme;
_sendNotFound(HttpResponse response) {
response.statusCode = HttpStatus.NOT_FOUND;
@@ -77,8 +79,8 @@ Future testNonHttp() {
.then((_) { cleanup(); });
}
-Future testHttp() {
- String inFilePath = 'http://127.0.0.1:$port/http_launch_main.dart';
+Future testHttpMain() {
+ String inFilePath = '$scheme://127.0.0.1:$port/http_launch_main.dart';
Bill Hesse 2014/09/11 08:08:40 The only uses of scheme and port are in the expres
floitsch 2014/09/11 13:37:40 Done.
List<String> args = [inFilePath, "--out=" + outFilePath];
return launchDart2Js(args)
.then(check)
@@ -88,7 +90,7 @@ Future testHttp() {
Future testHttpLib() {
File file = new File(path.join(tempDir.path, "in.dart"));
file.writeAsStringSync("""
- import 'http://127.0.0.1:$port/lib1.dart';
+ import '$scheme://127.0.0.1:$port/lib1.dart';
main() { print(foo()); }
""");
String inFilePath = file.path;
@@ -102,7 +104,7 @@ Future testHttpLib() {
Future testHttpPackage() {
String inFilePath =
pathOfData.resolve('http_launch_main_package.dart').toFilePath();
- String packageRoot = 'http://127.0.0.1:$port/packages/';
+ String packageRoot = '$scheme://127.0.0.1:$port/packages/';
List<String> args = [inFilePath,
"--out=" + outFilePath,
"--package-root=" + packageRoot];
@@ -114,7 +116,7 @@ Future testHttpPackage() {
Future testBadHttp() {
File file = new File(path.join(tempDir.path, "in_bad.dart"));
file.writeAsStringSync("""
- import 'http://127.0.0.1:$port/not_existing.dart';
+ import '$scheme://127.0.0.1:$port/not_existing.dart';
main() { print(foo()); }
""");
String inFilePath = file.path;
@@ -126,7 +128,7 @@ Future testBadHttp() {
}
Future testBadHttp2() {
- String inFilePath = 'http://127.0.0.1:$port/not_found.dart';
+ String inFilePath = '$scheme://127.0.0.1:$port/not_found.dart';
List<String> args = [inFilePath, "--out=" + outFilePath];
return launchDart2Js(args)
.then((processResult) => checkNotFound(processResult, "not_found.dart"))
@@ -140,10 +142,10 @@ serverRunning(HttpServer server) {
asyncStart();
server.listen(handleRequest);
- new Future.value()
+ return new Future.value()
Bill Hesse 2014/09/11 08:08:40 You could make the tests return their input, and s
floitsch 2014/09/11 13:37:40 I don't like to return things that don't make sens
.then((_) => cleanup()) // Make sure we start fresh.
.then((_) => testNonHttp())
- .then((_) => testHttp())
+ .then((_) => testHttpMain())
.then((_) => testHttpLib())
.then((_) => testHttpPackage())
.then((_) => testBadHttp())
@@ -153,6 +155,29 @@ serverRunning(HttpServer server) {
.then((_) => asyncEnd());
}
+Future testHttp() {
+ scheme = "http";
+ return HttpServer.bind(InternetAddress.LOOPBACK_IP_V4, 0).then(serverRunning);
+}
+
+void initializeSSL() {
+ String testPkcertDatabase = pathOfPkcert.toFilePath();
+ SecureSocket.initialize(database: testPkcertDatabase,
+ password: 'dartdart');
+}
+
+Future testHttps() {
+ initializeSSL();
+ scheme = "https";
+ return HttpServer.bindSecure(InternetAddress.LOOPBACK_IP_V4,
+ 0,
+ certificateName: 'localhost_cert')
+ .then(serverRunning);
+}
+
main() {
- HttpServer.bind(InternetAddress.LOOPBACK_IP_V4, 0).then(serverRunning);
+ asyncStart();
+ testHttp()
+ .then((_) => testHttps)
+ .whenComplete(asyncEnd);
}
« no previous file with comments | « tests/compiler/dart2js/http_launch_data/pkcert/key4.db ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698