mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 887706 - Use a dynamic port in httpserver xpcshell tests so they can be run in parallel. r=Waldo
This commit is contained in:
parent
74efe04844
commit
67669b264e
@ -8,21 +8,28 @@
|
||||
* Basic functionality test, from the client programmer's POV.
|
||||
*/
|
||||
|
||||
var tests =
|
||||
[
|
||||
new Test("http://localhost:4444/objHandler",
|
||||
null, start_objHandler, null),
|
||||
new Test("http://localhost:4444/functionHandler",
|
||||
null, start_functionHandler, null),
|
||||
new Test("http://localhost:4444/nonexistent-path",
|
||||
null, start_non_existent_path, null),
|
||||
new Test("http://localhost:4444/lotsOfHeaders",
|
||||
null, start_lots_of_headers, null),
|
||||
XPCOMUtils.defineLazyGetter(this, "port", function() {
|
||||
return srv.identity.primaryPort;
|
||||
});
|
||||
|
||||
XPCOMUtils.defineLazyGetter(this, "tests", function() {
|
||||
return [
|
||||
new Test("http://localhost:" + port + "/objHandler",
|
||||
null, start_objHandler, null),
|
||||
new Test("http://localhost:" + port + "/functionHandler",
|
||||
null, start_functionHandler, null),
|
||||
new Test("http://localhost:" + port + "/nonexistent-path",
|
||||
null, start_non_existent_path, null),
|
||||
new Test("http://localhost:" + port + "/lotsOfHeaders",
|
||||
null, start_lots_of_headers, null),
|
||||
];
|
||||
});
|
||||
|
||||
var srv;
|
||||
|
||||
function run_test()
|
||||
{
|
||||
var srv = createServer();
|
||||
srv = createServer();
|
||||
|
||||
// base path
|
||||
// XXX should actually test this works with a file by comparing streams!
|
||||
@ -36,7 +43,7 @@ function run_test()
|
||||
srv.registerPathHandler("/functionHandler", functionHandler);
|
||||
srv.registerPathHandler("/lotsOfHeaders", lotsOfHeadersHandler);
|
||||
|
||||
srv.start(4444);
|
||||
srv.start(-1);
|
||||
|
||||
runHttpTests(tests, testComplete(srv));
|
||||
}
|
||||
@ -118,13 +125,13 @@ var objHandler =
|
||||
var body = "Request (slightly reformatted):\n\n";
|
||||
body += metadata.method + " " + metadata.path;
|
||||
|
||||
do_check_eq(metadata.port, 4444);
|
||||
do_check_eq(metadata.port, port);
|
||||
|
||||
if (metadata.queryString)
|
||||
body += "?" + metadata.queryString;
|
||||
|
||||
body += " HTTP/" + metadata.httpVersion + "\n";
|
||||
|
||||
|
||||
var headEnum = metadata.headers;
|
||||
while (headEnum.hasMoreElements())
|
||||
{
|
||||
@ -150,7 +157,7 @@ function functionHandler(metadata, response)
|
||||
response.setStatusLine("1.1", 404, "Page Not Found");
|
||||
response.setHeader("foopy", "quux-baz", false);
|
||||
|
||||
do_check_eq(metadata.port, 4444);
|
||||
do_check_eq(metadata.port, port);
|
||||
do_check_eq(metadata.host, "localhost");
|
||||
do_check_eq(metadata.path.charAt(0), "/");
|
||||
|
||||
|
@ -10,15 +10,13 @@
|
||||
* octal number.
|
||||
*/
|
||||
|
||||
const PORT = 4444;
|
||||
|
||||
var srv;
|
||||
|
||||
function run_test()
|
||||
{
|
||||
srv = createServer();
|
||||
srv.registerPathHandler("/content-length", contentLength);
|
||||
srv.start(PORT);
|
||||
srv.start(-1);
|
||||
|
||||
runHttpTests(tests, testComplete(srv));
|
||||
}
|
||||
@ -44,10 +42,12 @@ function contentLength(request, response)
|
||||
* BEGIN TESTS *
|
||||
***************/
|
||||
|
||||
var tests = [
|
||||
new Test("http://localhost:4444/content-length",
|
||||
init_content_length),
|
||||
];
|
||||
XPCOMUtils.defineLazyGetter(this, 'tests', function() {
|
||||
return [
|
||||
new Test("http://localhost:" + srv.identity.primaryPort + "/content-length",
|
||||
init_content_length),
|
||||
];
|
||||
});
|
||||
|
||||
function init_content_length(ch)
|
||||
{
|
||||
|
@ -7,10 +7,13 @@
|
||||
// checks if a byte range request and non-byte range request retrieve the
|
||||
// correct data.
|
||||
|
||||
const PREFIX = "http://localhost:4444";
|
||||
var srv;
|
||||
XPCOMUtils.defineLazyGetter(this, "PREFIX", function() {
|
||||
return "http://localhost:" + srv.identity.primaryPort;
|
||||
});
|
||||
|
||||
var tests =
|
||||
[
|
||||
XPCOMUtils.defineLazyGetter(this, "tests", function() {
|
||||
return [
|
||||
new Test(PREFIX + "/range.txt",
|
||||
init_byterange, start_byterange, stop_byterange),
|
||||
new Test(PREFIX + "/range.txt",
|
||||
@ -40,14 +43,15 @@ var tests =
|
||||
new Test(PREFIX + "/range.txt",
|
||||
null, start_normal, stop_normal)
|
||||
];
|
||||
});
|
||||
|
||||
function run_test()
|
||||
{
|
||||
var srv = createServer();
|
||||
srv = createServer();
|
||||
var dir = do_get_file("data/ranges/");
|
||||
srv.registerDirectory("/", dir);
|
||||
|
||||
srv.start(4444);
|
||||
srv.start(-1);
|
||||
|
||||
runHttpTests(tests, testComplete(srv));
|
||||
}
|
||||
|
@ -5,31 +5,35 @@
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
// exercises support for mod_cern_meta-style header/status line modification
|
||||
var srv;
|
||||
|
||||
const PREFIX = "http://localhost:4444";
|
||||
XPCOMUtils.defineLazyGetter(this, 'PREFIX', function() {
|
||||
return "http://localhost:" + srv.identity.primaryPort;
|
||||
});
|
||||
|
||||
var tests =
|
||||
[
|
||||
new Test(PREFIX + "/test_both.html",
|
||||
null, start_testBoth, null),
|
||||
new Test(PREFIX + "/test_ctype_override.txt",
|
||||
null, start_test_ctype_override_txt, null),
|
||||
new Test(PREFIX + "/test_status_override.html",
|
||||
null, start_test_status_override_html, null),
|
||||
new Test(PREFIX + "/test_status_override_nodesc.txt",
|
||||
null, start_test_status_override_nodesc_txt, null),
|
||||
new Test(PREFIX + "/caret_test.txt^",
|
||||
null, start_caret_test_txt_, null)
|
||||
XPCOMUtils.defineLazyGetter(this, 'tests', function() {
|
||||
return [
|
||||
new Test(PREFIX + "/test_both.html",
|
||||
null, start_testBoth, null),
|
||||
new Test(PREFIX + "/test_ctype_override.txt",
|
||||
null, start_test_ctype_override_txt, null),
|
||||
new Test(PREFIX + "/test_status_override.html",
|
||||
null, start_test_status_override_html, null),
|
||||
new Test(PREFIX + "/test_status_override_nodesc.txt",
|
||||
null, start_test_status_override_nodesc_txt, null),
|
||||
new Test(PREFIX + "/caret_test.txt^",
|
||||
null, start_caret_test_txt_, null)
|
||||
];
|
||||
});
|
||||
|
||||
function run_test()
|
||||
{
|
||||
var srv = createServer();
|
||||
srv = createServer();
|
||||
|
||||
var cernDir = do_get_file("data/cern_meta/");
|
||||
srv.registerDirectory("/", cernDir);
|
||||
|
||||
srv.start(4444);
|
||||
srv.start(-1);
|
||||
|
||||
runHttpTests(tests, testComplete(srv));
|
||||
}
|
||||
|
@ -10,6 +10,10 @@
|
||||
|
||||
var srv, dir, dirEntries;
|
||||
|
||||
XPCOMUtils.defineLazyGetter(this, 'BASE_URL', function() {
|
||||
return "http://localhost:" + srv.identity.primaryPort + "/";
|
||||
});
|
||||
|
||||
function run_test()
|
||||
{
|
||||
createTestDirectory();
|
||||
@ -20,7 +24,7 @@ function run_test()
|
||||
var nameDir = do_get_file("data/name-scheme/");
|
||||
srv.registerDirectory("/bar/", nameDir);
|
||||
|
||||
srv.start(4444);
|
||||
srv.start(-1);
|
||||
|
||||
function done()
|
||||
{
|
||||
@ -255,38 +259,32 @@ function makeFile(name, isDirectory, parentDir, lst)
|
||||
* TESTS *
|
||||
*********/
|
||||
|
||||
var tests = [];
|
||||
var test;
|
||||
XPCOMUtils.defineLazyGetter(this, "tests", function() {
|
||||
return [
|
||||
new Test(BASE_URL, null, start, stopRootDirectory),
|
||||
new Test(BASE_URL + "foo/", null, start, stopFooDirectory),
|
||||
new Test(BASE_URL + "bar/folder^/", null, start, stopTrailingCaretDirectory),
|
||||
];
|
||||
});
|
||||
|
||||
// check top-level directory listing
|
||||
test = new Test("http://localhost:4444/",
|
||||
null, start, stopRootDirectory),
|
||||
tests.push(test);
|
||||
function start(ch)
|
||||
{
|
||||
do_check_eq(ch.getResponseHeader("Content-Type"), "text/html;charset=utf-8");
|
||||
}
|
||||
function stopRootDirectory(ch, cx, status, data)
|
||||
{
|
||||
dataCheck(data, "http://localhost:4444/", "/", dirEntries[0]);
|
||||
dataCheck(data, BASE_URL, "/", dirEntries[0]);
|
||||
}
|
||||
|
||||
|
||||
// check non-top-level, too
|
||||
test = new Test("http://localhost:4444/foo/",
|
||||
null, start, stopFooDirectory),
|
||||
tests.push(test);
|
||||
function stopFooDirectory(ch, cx, status, data)
|
||||
{
|
||||
dataCheck(data, "http://localhost:4444/foo/", "/foo/", dirEntries[1]);
|
||||
dataCheck(data, BASE_URL + "foo/", "/foo/", dirEntries[1]);
|
||||
}
|
||||
|
||||
|
||||
// trailing-caret leaf with hidden files
|
||||
test = new Test("http://localhost:4444/bar/folder^/",
|
||||
null, start, stopTrailingCaretDirectory),
|
||||
tests.push(test);
|
||||
function stopTrailingCaretDirectory(ch, cx, status, data)
|
||||
{
|
||||
hiddenDataCheck(data, "http://localhost:4444/bar/folder^/", "/bar/folder^/");
|
||||
hiddenDataCheck(data, BASE_URL + "bar/folder^/", "/bar/folder^/");
|
||||
}
|
||||
|
@ -7,23 +7,26 @@
|
||||
// in its original incarnation, the server didn't like empty response-bodies;
|
||||
// see the comment in _end for details
|
||||
|
||||
var tests =
|
||||
[
|
||||
new Test("http://localhost:4444/empty-body-unwritten",
|
||||
null, ensureEmpty, null),
|
||||
new Test("http://localhost:4444/empty-body-written",
|
||||
null, ensureEmpty, null),
|
||||
var srv;
|
||||
|
||||
XPCOMUtils.defineLazyGetter(this, "tests", function() {
|
||||
return [
|
||||
new Test("http://localhost:" + srv.identity.primaryPort + "/empty-body-unwritten",
|
||||
null, ensureEmpty, null),
|
||||
new Test("http://localhost:" + srv.identity.primaryPort + "/empty-body-written",
|
||||
null, ensureEmpty, null),
|
||||
];
|
||||
});
|
||||
|
||||
function run_test()
|
||||
{
|
||||
var srv = createServer();
|
||||
srv = createServer();
|
||||
|
||||
// register a few test paths
|
||||
srv.registerPathHandler("/empty-body-unwritten", emptyBodyUnwritten);
|
||||
srv.registerPathHandler("/empty-body-written", emptyBodyWritten);
|
||||
|
||||
srv.start(4444);
|
||||
srv.start(-1);
|
||||
|
||||
runHttpTests(tests, testComplete(srv));
|
||||
}
|
||||
|
@ -7,15 +7,18 @@
|
||||
// Request handlers may throw exceptions, and those exception should be caught
|
||||
// by the server and converted into the proper error codes.
|
||||
|
||||
var tests =
|
||||
[
|
||||
new Test("http://localhost:4444/throws/exception",
|
||||
XPCOMUtils.defineLazyGetter(this, "tests", function() {
|
||||
return [
|
||||
new Test("http://localhost:" + srv.identity.primaryPort + "/throws/exception",
|
||||
null, start_throws_exception, succeeded),
|
||||
new Test("http://localhost:4444/this/file/does/not/exist/and/404s",
|
||||
new Test("http://localhost:" + srv.identity.primaryPort +
|
||||
"/this/file/does/not/exist/and/404s",
|
||||
null, start_nonexistent_404_fails_so_400, succeeded),
|
||||
new Test("http://localhost:4444/attempts/404/fails/so/400/fails/so/500s",
|
||||
new Test("http://localhost:" + srv.identity.primaryPort +
|
||||
"/attempts/404/fails/so/400/fails/so/500s",
|
||||
register400Handler, start_multiple_exceptions_500, succeeded),
|
||||
];
|
||||
});
|
||||
|
||||
var srv;
|
||||
|
||||
@ -26,7 +29,7 @@ function run_test()
|
||||
srv.registerErrorHandler(404, throwsException);
|
||||
srv.registerPathHandler("/throws/exception", throwsException);
|
||||
|
||||
srv.start(4444);
|
||||
srv.start(-1);
|
||||
|
||||
runHttpTests(tests, testComplete(srv));
|
||||
}
|
||||
|
@ -6,15 +6,15 @@
|
||||
|
||||
// test that special headers are sent as an array of headers with the same name
|
||||
|
||||
const PORT = 4444;
|
||||
var srv;
|
||||
|
||||
function run_test()
|
||||
{
|
||||
var srv;
|
||||
srv;
|
||||
|
||||
srv = createServer();
|
||||
srv.registerPathHandler("/path-handler", pathHandler);
|
||||
srv.start(PORT);
|
||||
srv.start(-1);
|
||||
|
||||
runHttpTests(tests, testComplete(srv));
|
||||
}
|
||||
@ -47,9 +47,12 @@ function pathHandler(request, response)
|
||||
* BEGIN TESTS *
|
||||
***************/
|
||||
|
||||
var tests = [
|
||||
new Test("http://localhost:4444/path-handler",
|
||||
null, check)];
|
||||
XPCOMUtils.defineLazyGetter(this, "tests", function() {
|
||||
return [
|
||||
new Test("http://localhost:" + srv.identity.primaryPort + "/path-handler",
|
||||
null, check)
|
||||
];
|
||||
});
|
||||
|
||||
function check(ch, cx)
|
||||
{
|
||||
|
@ -8,42 +8,47 @@
|
||||
// htaccess-like functionality without the need to explicitly disable display
|
||||
// of such files
|
||||
|
||||
const PREFIX = "http://localhost:4444";
|
||||
var srv;
|
||||
|
||||
var tests =
|
||||
[
|
||||
new Test(PREFIX + "/bar.html^",
|
||||
XPCOMUtils.defineLazyGetter(this, "PREFIX", function() {
|
||||
return "http://localhost:" + srv.identity.primaryPort;
|
||||
});
|
||||
|
||||
XPCOMUtils.defineLazyGetter(this, "tests", function() {
|
||||
return [
|
||||
new Test(PREFIX + "/bar.html^",
|
||||
null, start_bar_html_, null),
|
||||
new Test(PREFIX + "/foo.html^",
|
||||
new Test(PREFIX + "/foo.html^",
|
||||
null, start_foo_html_, null),
|
||||
new Test(PREFIX + "/normal-file.txt",
|
||||
new Test(PREFIX + "/normal-file.txt",
|
||||
null, start_normal_file_txt, null),
|
||||
new Test(PREFIX + "/folder^/file.txt",
|
||||
new Test(PREFIX + "/folder^/file.txt",
|
||||
null, start_folder__file_txt, null),
|
||||
|
||||
new Test(PREFIX + "/foo/bar.html^",
|
||||
new Test(PREFIX + "/foo/bar.html^",
|
||||
null, start_bar_html_, null),
|
||||
new Test(PREFIX + "/foo/foo.html^",
|
||||
new Test(PREFIX + "/foo/foo.html^",
|
||||
null, start_foo_html_, null),
|
||||
new Test(PREFIX + "/foo/normal-file.txt",
|
||||
new Test(PREFIX + "/foo/normal-file.txt",
|
||||
null, start_normal_file_txt, null),
|
||||
new Test(PREFIX + "/foo/folder^/file.txt",
|
||||
new Test(PREFIX + "/foo/folder^/file.txt",
|
||||
null, start_folder__file_txt, null),
|
||||
|
||||
new Test(PREFIX + "/end-caret^/bar.html^",
|
||||
new Test(PREFIX + "/end-caret^/bar.html^",
|
||||
null, start_bar_html_, null),
|
||||
new Test(PREFIX + "/end-caret^/foo.html^",
|
||||
new Test(PREFIX + "/end-caret^/foo.html^",
|
||||
null, start_foo_html_, null),
|
||||
new Test(PREFIX + "/end-caret^/normal-file.txt",
|
||||
new Test(PREFIX + "/end-caret^/normal-file.txt",
|
||||
null, start_normal_file_txt, null),
|
||||
new Test(PREFIX + "/end-caret^/folder^/file.txt",
|
||||
new Test(PREFIX + "/end-caret^/folder^/file.txt",
|
||||
null, start_folder__file_txt, null)
|
||||
];
|
||||
];
|
||||
});
|
||||
|
||||
|
||||
function run_test()
|
||||
{
|
||||
var srv = createServer();
|
||||
srv = createServer();
|
||||
|
||||
// make sure underscores work in directories "mounted" in directories with
|
||||
// folders starting with _
|
||||
@ -52,7 +57,7 @@ function run_test()
|
||||
srv.registerDirectory("/foo/", nameDir);
|
||||
srv.registerDirectory("/end-caret^/", nameDir);
|
||||
|
||||
srv.start(4444);
|
||||
srv.start(-1);
|
||||
|
||||
runHttpTests(tests, testComplete(srv));
|
||||
}
|
||||
|
@ -8,15 +8,18 @@
|
||||
* Tests for correct behavior of asynchronous responses.
|
||||
*/
|
||||
|
||||
const PORT = 4444;
|
||||
const PREPATH = "http://localhost:" + PORT;
|
||||
XPCOMUtils.defineLazyGetter(this, "PREPATH", function() {
|
||||
return "http://localhost:" + srv.identity.primaryPort;
|
||||
});
|
||||
|
||||
var srv;
|
||||
|
||||
function run_test()
|
||||
{
|
||||
var srv = createServer();
|
||||
srv = createServer();
|
||||
for (var path in handlers)
|
||||
srv.registerPathHandler(path, handlers[path]);
|
||||
srv.start(PORT);
|
||||
srv.start(-1);
|
||||
|
||||
runHttpTests(tests, testComplete(srv));
|
||||
}
|
||||
@ -26,8 +29,18 @@ function run_test()
|
||||
* BEGIN TESTS *
|
||||
***************/
|
||||
|
||||
var test;
|
||||
var tests = [];
|
||||
XPCOMUtils.defineLazyGetter(this, "tests", function() {
|
||||
return [
|
||||
new Test(PREPATH + "/handleSync", null, start_handleSync, null),
|
||||
new Test(PREPATH + "/handleAsync1", null, start_handleAsync1,
|
||||
stop_handleAsync1),
|
||||
new Test(PREPATH + "/handleAsync2", init_handleAsync2, start_handleAsync2,
|
||||
stop_handleAsync2),
|
||||
new Test(PREPATH + "/handleAsyncOrdering", null, null,
|
||||
stop_handleAsyncOrdering)
|
||||
];
|
||||
});
|
||||
|
||||
var handlers = {};
|
||||
|
||||
function handleSync(request, response)
|
||||
@ -54,11 +67,6 @@ function start_handleSync(ch, cx)
|
||||
do_check_eq(ch.responseStatusText, "handleSync pass");
|
||||
}
|
||||
|
||||
test = new Test(PREPATH + "/handleSync",
|
||||
null, start_handleSync, null),
|
||||
tests.push(test);
|
||||
|
||||
|
||||
function handleAsync1(request, response)
|
||||
{
|
||||
response.setStatusLine(request.httpVersion, 500, "Old status line!");
|
||||
@ -125,11 +133,6 @@ function stop_handleAsync1(ch, cx, status, data)
|
||||
do_check_eq(data.length, 0);
|
||||
}
|
||||
|
||||
test = new Test(PREPATH + "/handleAsync1",
|
||||
null, start_handleAsync1, stop_handleAsync1),
|
||||
tests.push(test);
|
||||
|
||||
|
||||
const startToHeaderDelay = 500;
|
||||
const startToFinishedDelay = 750;
|
||||
|
||||
@ -233,11 +236,6 @@ function stop_handleAsync2(ch, cx, status, data)
|
||||
do_check_eq(String.fromCharCode.apply(null, data), "BODY");
|
||||
}
|
||||
|
||||
test = new Test(PREPATH + "/handleAsync2",
|
||||
init_handleAsync2, start_handleAsync2, stop_handleAsync2);
|
||||
tests.push(test);
|
||||
|
||||
|
||||
/*
|
||||
* Tests that accessing output stream *before* calling processAsync() works
|
||||
* correctly, sending written data immediately as it is written, not buffering
|
||||
@ -304,7 +302,3 @@ function stop_handleAsyncOrdering(ch, cx, status, data)
|
||||
do_throw("value " + v + " at index " + index + " should be zero");
|
||||
});
|
||||
}
|
||||
|
||||
test = new Test(PREPATH + "/handleAsyncOrdering",
|
||||
null, null, stop_handleAsyncOrdering);
|
||||
tests.push(test);
|
||||
|
@ -10,17 +10,20 @@
|
||||
* created by XPConnect.
|
||||
*/
|
||||
|
||||
var tests =
|
||||
[
|
||||
new Test("http://localhost:4444/test",
|
||||
null, start_test, null),
|
||||
new Test("http://localhost:4444/sjs/qi.sjs",
|
||||
null, start_sjs_qi, null),
|
||||
XPCOMUtils.defineLazyGetter(this, "tests", function() {
|
||||
return [
|
||||
new Test("http://localhost:" + srv.identity.primaryPort + "/test",
|
||||
null, start_test, null),
|
||||
new Test("http://localhost:" + srv.identity.primaryPort + "/sjs/qi.sjs",
|
||||
null, start_sjs_qi, null),
|
||||
];
|
||||
});
|
||||
|
||||
var srv;
|
||||
|
||||
function run_test()
|
||||
{
|
||||
var srv = createServer();
|
||||
srv = createServer();
|
||||
|
||||
var qi;
|
||||
try
|
||||
@ -37,7 +40,7 @@ function run_test()
|
||||
srv.registerPathHandler("/test", testHandler);
|
||||
srv.registerDirectory("/", do_get_file("data/"));
|
||||
srv.registerContentType("sjs", "sjs");
|
||||
srv.start(4444);
|
||||
srv.start(-1);
|
||||
|
||||
runHttpTests(tests, testComplete(srv));
|
||||
}
|
||||
|
@ -6,10 +6,9 @@
|
||||
|
||||
// tests the registerDirectory API
|
||||
|
||||
const BASE = "http://localhost:4444";
|
||||
|
||||
var tests = [];
|
||||
var test;
|
||||
XPCOMUtils.defineLazyGetter(this, "BASE", function() {
|
||||
return "http://localhost:" + srv.identity.primaryPort;
|
||||
});
|
||||
|
||||
|
||||
function nocache(ch)
|
||||
@ -50,234 +49,190 @@ function checkFile(ch, cx, status, data)
|
||||
fileContents(actualFile));
|
||||
}
|
||||
|
||||
XPCOMUtils.defineLazyGetter(this, "tests", function() {
|
||||
return [
|
||||
|
||||
/***********************
|
||||
* without a base path *
|
||||
***********************/
|
||||
|
||||
test = new Test(BASE + "/test_registerdirectory.js",
|
||||
new Test(BASE + "/test_registerdirectory.js",
|
||||
nocache, notFound, null),
|
||||
tests.push(test);
|
||||
|
||||
|
||||
/********************
|
||||
* with a base path *
|
||||
********************/
|
||||
|
||||
test = new Test(BASE + "/test_registerdirectory.js",
|
||||
function(ch)
|
||||
{
|
||||
nocache(ch);
|
||||
serverBasePath = testsDirectory.clone();
|
||||
srv.registerDirectory("/", serverBasePath);
|
||||
},
|
||||
null,
|
||||
checkFile);
|
||||
tests.push(test);
|
||||
|
||||
new Test(BASE + "/test_registerdirectory.js",
|
||||
function(ch)
|
||||
{
|
||||
nocache(ch);
|
||||
serverBasePath = testsDirectory.clone();
|
||||
srv.registerDirectory("/", serverBasePath);
|
||||
},
|
||||
null,
|
||||
checkFile),
|
||||
|
||||
/*****************************
|
||||
* without a base path again *
|
||||
*****************************/
|
||||
|
||||
test = new Test(BASE + "/test_registerdirectory.js",
|
||||
function(ch)
|
||||
{
|
||||
nocache(ch);
|
||||
serverBasePath = null;
|
||||
srv.registerDirectory("/", serverBasePath);
|
||||
},
|
||||
notFound,
|
||||
null);
|
||||
tests.push(test);
|
||||
|
||||
new Test(BASE + "/test_registerdirectory.js",
|
||||
function(ch)
|
||||
{
|
||||
nocache(ch);
|
||||
serverBasePath = null;
|
||||
srv.registerDirectory("/", serverBasePath);
|
||||
},
|
||||
notFound,
|
||||
null),
|
||||
|
||||
/***************************
|
||||
* registered path handler *
|
||||
***************************/
|
||||
|
||||
test = new Test(BASE + "/test_registerdirectory.js",
|
||||
function(ch)
|
||||
{
|
||||
nocache(ch);
|
||||
srv.registerPathHandler("/test_registerdirectory.js",
|
||||
override_test_registerdirectory);
|
||||
},
|
||||
checkOverride,
|
||||
null);
|
||||
tests.push(test);
|
||||
|
||||
new Test(BASE + "/test_registerdirectory.js",
|
||||
function(ch)
|
||||
{
|
||||
nocache(ch);
|
||||
srv.registerPathHandler("/test_registerdirectory.js",
|
||||
override_test_registerdirectory);
|
||||
},
|
||||
checkOverride,
|
||||
null),
|
||||
|
||||
/************************
|
||||
* removed path handler *
|
||||
************************/
|
||||
|
||||
test = new Test(BASE + "/test_registerdirectory.js",
|
||||
function init_registerDirectory6(ch)
|
||||
{
|
||||
nocache(ch);
|
||||
srv.registerPathHandler("/test_registerdirectory.js", null);
|
||||
},
|
||||
notFound,
|
||||
null);
|
||||
tests.push(test);
|
||||
|
||||
new Test(BASE + "/test_registerdirectory.js",
|
||||
function init_registerDirectory6(ch)
|
||||
{
|
||||
nocache(ch);
|
||||
srv.registerPathHandler("/test_registerdirectory.js", null);
|
||||
},
|
||||
notFound,
|
||||
null),
|
||||
|
||||
/********************
|
||||
* with a base path *
|
||||
********************/
|
||||
new Test(BASE + "/test_registerdirectory.js",
|
||||
function(ch)
|
||||
{
|
||||
nocache(ch);
|
||||
|
||||
test = new Test(BASE + "/test_registerdirectory.js",
|
||||
function(ch)
|
||||
{
|
||||
nocache(ch);
|
||||
|
||||
// set the base path again
|
||||
serverBasePath = testsDirectory.clone();
|
||||
srv.registerDirectory("/", serverBasePath);
|
||||
},
|
||||
null,
|
||||
checkFile);
|
||||
tests.push(test);
|
||||
|
||||
// set the base path again
|
||||
serverBasePath = testsDirectory.clone();
|
||||
srv.registerDirectory("/", serverBasePath);
|
||||
},
|
||||
null,
|
||||
checkFile),
|
||||
|
||||
/*************************
|
||||
* ...and a path handler *
|
||||
*************************/
|
||||
|
||||
test = new Test(BASE + "/test_registerdirectory.js",
|
||||
function(ch)
|
||||
{
|
||||
nocache(ch);
|
||||
srv.registerPathHandler("/test_registerdirectory.js",
|
||||
override_test_registerdirectory);
|
||||
},
|
||||
checkOverride,
|
||||
null);
|
||||
tests.push(test);
|
||||
|
||||
new Test(BASE + "/test_registerdirectory.js",
|
||||
function(ch)
|
||||
{
|
||||
nocache(ch);
|
||||
srv.registerPathHandler("/test_registerdirectory.js",
|
||||
override_test_registerdirectory);
|
||||
},
|
||||
checkOverride,
|
||||
null),
|
||||
|
||||
/************************
|
||||
* removed base handler *
|
||||
************************/
|
||||
|
||||
test = new Test(BASE + "/test_registerdirectory.js",
|
||||
function(ch)
|
||||
{
|
||||
nocache(ch);
|
||||
serverBasePath = null;
|
||||
srv.registerDirectory("/", serverBasePath);
|
||||
},
|
||||
checkOverride,
|
||||
null);
|
||||
tests.push(test);
|
||||
|
||||
new Test(BASE + "/test_registerdirectory.js",
|
||||
function(ch)
|
||||
{
|
||||
nocache(ch);
|
||||
serverBasePath = null;
|
||||
srv.registerDirectory("/", serverBasePath);
|
||||
},
|
||||
checkOverride,
|
||||
null),
|
||||
|
||||
/************************
|
||||
* removed path handler *
|
||||
************************/
|
||||
|
||||
test = new Test(BASE + "/test_registerdirectory.js",
|
||||
function(ch)
|
||||
{
|
||||
nocache(ch);
|
||||
srv.registerPathHandler("/test_registerdirectory.js", null);
|
||||
},
|
||||
notFound,
|
||||
null);
|
||||
tests.push(test);
|
||||
|
||||
new Test(BASE + "/test_registerdirectory.js",
|
||||
function(ch)
|
||||
{
|
||||
nocache(ch);
|
||||
srv.registerPathHandler("/test_registerdirectory.js", null);
|
||||
},
|
||||
notFound,
|
||||
null),
|
||||
|
||||
/*************************
|
||||
* mapping set up, works *
|
||||
*************************/
|
||||
|
||||
test = new Test(BASE + "/foo/test_registerdirectory.js",
|
||||
function(ch)
|
||||
{
|
||||
nocache(ch);
|
||||
serverBasePath = testsDirectory.clone();
|
||||
srv.registerDirectory("/foo/", serverBasePath);
|
||||
},
|
||||
check200,
|
||||
null);
|
||||
tests.push(test);
|
||||
|
||||
new Test(BASE + "/foo/test_registerdirectory.js",
|
||||
function(ch)
|
||||
{
|
||||
nocache(ch);
|
||||
serverBasePath = testsDirectory.clone();
|
||||
srv.registerDirectory("/foo/", serverBasePath);
|
||||
},
|
||||
check200,
|
||||
null),
|
||||
|
||||
/*********************
|
||||
* no mapping, fails *
|
||||
*********************/
|
||||
|
||||
test = new Test(BASE + "/foo/test_registerdirectory.js/test_registerdirectory.js",
|
||||
nocache,
|
||||
notFound,
|
||||
null);
|
||||
tests.push(test);
|
||||
|
||||
new Test(BASE + "/foo/test_registerdirectory.js/test_registerdirectory.js",
|
||||
nocache,
|
||||
notFound,
|
||||
null),
|
||||
|
||||
/******************
|
||||
* mapping, works *
|
||||
******************/
|
||||
|
||||
test = new Test(BASE + "/foo/test_registerdirectory.js/test_registerdirectory.js",
|
||||
function(ch)
|
||||
{
|
||||
nocache(ch);
|
||||
srv.registerDirectory("/foo/test_registerdirectory.js/",
|
||||
serverBasePath);
|
||||
},
|
||||
null,
|
||||
checkFile);
|
||||
tests.push(test);
|
||||
|
||||
new Test(BASE + "/foo/test_registerdirectory.js/test_registerdirectory.js",
|
||||
function(ch)
|
||||
{
|
||||
nocache(ch);
|
||||
srv.registerDirectory("/foo/test_registerdirectory.js/",
|
||||
serverBasePath);
|
||||
},
|
||||
null,
|
||||
checkFile),
|
||||
|
||||
/************************************
|
||||
* two mappings set up, still works *
|
||||
************************************/
|
||||
|
||||
test = new Test(BASE + "/foo/test_registerdirectory.js",
|
||||
nocache, null, checkFile);
|
||||
tests.push(test);
|
||||
|
||||
new Test(BASE + "/foo/test_registerdirectory.js",
|
||||
nocache, null, checkFile),
|
||||
|
||||
/**************************
|
||||
* remove topmost mapping *
|
||||
**************************/
|
||||
|
||||
test = new Test(BASE + "/foo/test_registerdirectory.js",
|
||||
function(ch)
|
||||
{
|
||||
nocache(ch);
|
||||
srv.registerDirectory("/foo/", null);
|
||||
},
|
||||
notFound,
|
||||
null);
|
||||
tests.push(test);
|
||||
|
||||
new Test(BASE + "/foo/test_registerdirectory.js",
|
||||
function(ch)
|
||||
{
|
||||
nocache(ch);
|
||||
srv.registerDirectory("/foo/", null);
|
||||
},
|
||||
notFound,
|
||||
null),
|
||||
|
||||
/**************************************
|
||||
* lower mapping still present, works *
|
||||
**************************************/
|
||||
|
||||
test = new Test(BASE + "/foo/test_registerdirectory.js/test_registerdirectory.js",
|
||||
nocache, null, checkFile);
|
||||
tests.push(test);
|
||||
|
||||
new Test(BASE + "/foo/test_registerdirectory.js/test_registerdirectory.js",
|
||||
nocache, null, checkFile),
|
||||
|
||||
/*******************
|
||||
* mapping removed *
|
||||
*******************/
|
||||
|
||||
test = new Test(BASE + "/foo/test_registerdirectory.js/test_registerdirectory.js",
|
||||
function(ch)
|
||||
{
|
||||
nocache(ch);
|
||||
srv.registerDirectory("/foo/test_registerdirectory.js/", null);
|
||||
},
|
||||
notFound,
|
||||
null);
|
||||
tests.push(test);
|
||||
|
||||
new Test(BASE + "/foo/test_registerdirectory.js/test_registerdirectory.js",
|
||||
function(ch)
|
||||
{
|
||||
nocache(ch);
|
||||
srv.registerDirectory("/foo/test_registerdirectory.js/", null);
|
||||
},
|
||||
notFound,
|
||||
null)
|
||||
];
|
||||
});
|
||||
|
||||
|
||||
var srv;
|
||||
@ -289,7 +244,7 @@ function run_test()
|
||||
testsDirectory = do_get_cwd();
|
||||
|
||||
srv = createServer();
|
||||
srv.start(4444);
|
||||
srv.start(-1);
|
||||
|
||||
runHttpTests(tests, testComplete(srv));
|
||||
}
|
||||
|
@ -6,7 +6,9 @@
|
||||
|
||||
// tests the registerFile API
|
||||
|
||||
const BASE = "http://localhost:4444";
|
||||
XPCOMUtils.defineLazyGetter(this, "BASE", function() {
|
||||
return "http://localhost:" + srv.identity.primaryPort;
|
||||
});
|
||||
|
||||
var file = do_get_file("test_registerfile.js");
|
||||
|
||||
@ -21,15 +23,19 @@ function onStop(ch, cx, status, data)
|
||||
do_check_eq(data.length, file.fileSize);
|
||||
}
|
||||
|
||||
var test = new Test(BASE + "/foo", null, onStart, onStop);
|
||||
XPCOMUtils.defineLazyGetter(this, "test", function() {
|
||||
return new Test(BASE + "/foo", null, onStart, onStop);
|
||||
});
|
||||
|
||||
var srv;
|
||||
|
||||
function run_test()
|
||||
{
|
||||
var srv = createServer();
|
||||
srv = createServer();
|
||||
|
||||
try
|
||||
{
|
||||
srv.registerFile("/foo", do_get_cwd());
|
||||
srv.registerFile("/foo", do_get_profile());
|
||||
throw "registerFile succeeded!";
|
||||
}
|
||||
catch (e)
|
||||
@ -38,7 +44,7 @@ function run_test()
|
||||
}
|
||||
|
||||
srv.registerFile("/foo", file);
|
||||
srv.start(4444);
|
||||
srv.start(-1);
|
||||
|
||||
runHttpTests([test], testComplete(srv));
|
||||
}
|
||||
|
@ -6,10 +6,9 @@
|
||||
|
||||
// tests the registerPrefixHandler API
|
||||
|
||||
const BASE = "http://localhost:4444";
|
||||
|
||||
var tests = [];
|
||||
var test;
|
||||
XPCOMUtils.defineLazyGetter(this, "BASE", function() {
|
||||
return "http://localhost:" + srv.identity.primaryPort;
|
||||
});
|
||||
|
||||
function nocache(ch)
|
||||
{
|
||||
@ -33,6 +32,20 @@ function makeCheckOverride(magic)
|
||||
});
|
||||
}
|
||||
|
||||
XPCOMUtils.defineLazyGetter(this, "tests", function() {
|
||||
return [
|
||||
new Test(BASE + "/prefix/dummy", prefixHandler, null,
|
||||
makeCheckOverride("prefix")),
|
||||
new Test(BASE + "/prefix/dummy", pathHandler, null,
|
||||
makeCheckOverride("path")),
|
||||
new Test(BASE + "/prefix/subpath/dummy", longerPrefixHandler, null,
|
||||
makeCheckOverride("subpath")),
|
||||
new Test(BASE + "/prefix/dummy", removeHandlers, null, notFound),
|
||||
new Test(BASE + "/prefix/subpath/dummy", newPrefixHandler, null,
|
||||
makeCheckOverride("subpath"))
|
||||
];
|
||||
});
|
||||
|
||||
/***************************
|
||||
* registered prefix handler *
|
||||
***************************/
|
||||
@ -43,10 +56,6 @@ function prefixHandler(channel)
|
||||
srv.registerPrefixHandler("/prefix/", makeOverride("prefix"));
|
||||
}
|
||||
|
||||
test = new Test(BASE + "/prefix/dummy", prefixHandler, null,
|
||||
makeCheckOverride("prefix"));
|
||||
tests.push(test);
|
||||
|
||||
/********************************
|
||||
* registered path handler on top *
|
||||
********************************/
|
||||
@ -56,9 +65,6 @@ function pathHandler(channel)
|
||||
nocache(channel);
|
||||
srv.registerPathHandler("/prefix/dummy", makeOverride("path"));
|
||||
}
|
||||
test = new Test(BASE + "/prefix/dummy", pathHandler, null,
|
||||
makeCheckOverride("path"));
|
||||
tests.push(test);
|
||||
|
||||
/**********************************
|
||||
* registered longer prefix handler *
|
||||
@ -69,9 +75,6 @@ function longerPrefixHandler(channel)
|
||||
nocache(channel);
|
||||
srv.registerPrefixHandler("/prefix/subpath/", makeOverride("subpath"));
|
||||
}
|
||||
test = new Test(BASE + "/prefix/subpath/dummy", longerPrefixHandler, null,
|
||||
makeCheckOverride("subpath"));
|
||||
tests.push(test);
|
||||
|
||||
/************************
|
||||
* removed prefix handler *
|
||||
@ -83,8 +86,6 @@ function removeHandlers(channel)
|
||||
srv.registerPrefixHandler("/prefix/", null);
|
||||
srv.registerPathHandler("/prefix/dummy", null);
|
||||
}
|
||||
test = new Test(BASE + "/prefix/dummy", removeHandlers, null, notFound);
|
||||
tests.push(test);
|
||||
|
||||
/*****************************
|
||||
* re-register shorter handler *
|
||||
@ -95,9 +96,6 @@ function newPrefixHandler(channel)
|
||||
nocache(channel);
|
||||
srv.registerPrefixHandler("/prefix/", makeOverride("prefix"));
|
||||
}
|
||||
test = new Test(BASE + "/prefix/subpath/dummy", newPrefixHandler, null,
|
||||
makeCheckOverride("subpath"));
|
||||
tests.push(test);
|
||||
|
||||
var srv;
|
||||
var serverBasePath;
|
||||
@ -105,10 +103,10 @@ var testsDirectory;
|
||||
|
||||
function run_test()
|
||||
{
|
||||
testsDirectory = do_get_cwd();
|
||||
testsDirectory = do_get_profile();
|
||||
|
||||
srv = createServer();
|
||||
srv.start(4444);
|
||||
srv.start(-1);
|
||||
|
||||
runHttpTests(tests, testComplete(srv));
|
||||
}
|
||||
|
@ -10,18 +10,16 @@
|
||||
* properly.
|
||||
*/
|
||||
|
||||
const PORT = 4444;
|
||||
|
||||
var srv;
|
||||
var srv = createServer();
|
||||
srv.start(-1);
|
||||
const PORT = srv.identity.primaryPort;
|
||||
|
||||
function run_test()
|
||||
{
|
||||
srv = createServer();
|
||||
srv.registerPathHandler("/lots-of-leading-blank-lines",
|
||||
lotsOfLeadingBlankLines);
|
||||
srv.registerPathHandler("/very-long-request-line",
|
||||
veryLongRequestLine);
|
||||
srv.start(PORT);
|
||||
|
||||
runRawTests(tests, testComplete(srv));
|
||||
}
|
||||
@ -53,7 +51,7 @@ reallyLong = reallyLong + reallyLong + reallyLong + reallyLong; // 524288
|
||||
if (reallyLong.length !== 524288)
|
||||
throw new TypeError("generated length not as long as expected");
|
||||
str = "GET /very-long-request-line?" + reallyLong + " HTTP/1.1\r\n" +
|
||||
"Host: localhost:4444\r\n" +
|
||||
"Host: localhost:" + PORT + "\r\n" +
|
||||
"\r\n";
|
||||
data = [];
|
||||
for (var i = 0; i < str.length; i += 16384)
|
||||
@ -80,7 +78,7 @@ function checkVeryLongRequestLine(data)
|
||||
"Version: 1.1",
|
||||
"Scheme: http",
|
||||
"Host: localhost",
|
||||
"Port: 4444",
|
||||
"Port: " + PORT,
|
||||
];
|
||||
|
||||
expectLines(iter, body);
|
||||
@ -100,7 +98,7 @@ for (var i = 0; i < 14; i++)
|
||||
blankLines += blankLines;
|
||||
str = blankLines +
|
||||
"GET /lots-of-leading-blank-lines HTTP/1.1\r\n" +
|
||||
"Host: localhost:4444\r\n" +
|
||||
"Host: localhost:" + PORT + "\r\n" +
|
||||
"\r\n";
|
||||
data = [];
|
||||
for (var i = 0; i < str.length; i += 100)
|
||||
@ -127,7 +125,7 @@ function checkLotsOfLeadingBlankLines(data)
|
||||
"Version: 1.1",
|
||||
"Scheme: http",
|
||||
"Host: localhost",
|
||||
"Port: 4444",
|
||||
"Port: " + PORT,
|
||||
];
|
||||
|
||||
expectLines(iter, body);
|
||||
|
@ -6,21 +6,24 @@
|
||||
|
||||
// make sure response.write works for strings, and coerces other args to strings
|
||||
|
||||
var tests =
|
||||
[
|
||||
new Test("http://localhost:4444/writeString",
|
||||
XPCOMUtils.defineLazyGetter(this, "tests", function() {
|
||||
return [
|
||||
new Test("http://localhost:" + srv.identity.primaryPort + "/writeString",
|
||||
null, check_1234, succeeded),
|
||||
new Test("http://localhost:4444/writeInt",
|
||||
new Test("http://localhost:" + srv.identity.primaryPort + "/writeInt",
|
||||
null, check_1234, succeeded),
|
||||
];
|
||||
});
|
||||
|
||||
var srv;
|
||||
|
||||
function run_test()
|
||||
{
|
||||
var srv = createServer();
|
||||
srv = createServer();
|
||||
|
||||
srv.registerPathHandler("/writeString", writeString);
|
||||
srv.registerPathHandler("/writeInt", writeInt);
|
||||
srv.start(4444);
|
||||
srv.start(-1);
|
||||
|
||||
runHttpTests(tests, testComplete(srv));
|
||||
}
|
||||
|
@ -8,7 +8,9 @@
|
||||
* Tests that the seizePower API works correctly.
|
||||
*/
|
||||
|
||||
const PORT = 4444;
|
||||
XPCOMUtils.defineLazyGetter(this, "PORT", function() {
|
||||
return srv.identity.primaryPort;
|
||||
});
|
||||
|
||||
var srv;
|
||||
|
||||
@ -22,7 +24,7 @@ function run_test()
|
||||
srv.registerPathHandler("/async-seizure", handleAsyncSeizure);
|
||||
srv.registerPathHandler("/seize-after-async", handleSeizeAfterAsync);
|
||||
|
||||
srv.start(PORT);
|
||||
srv.start(-1);
|
||||
|
||||
runRawTests(tests, testComplete(srv));
|
||||
}
|
||||
@ -134,50 +136,47 @@ function handleSeizeAfterAsync(request, response)
|
||||
* BEGIN TESTS *
|
||||
***************/
|
||||
|
||||
var test, data;
|
||||
var tests = [];
|
||||
XPCOMUtils.defineLazyGetter(this, "tests", function() {
|
||||
return [
|
||||
new RawTest("localhost", PORT, data0, checkRawData),
|
||||
new RawTest("localhost", PORT, data1, checkTooLate),
|
||||
new RawTest("localhost", PORT, data2, checkExceptions),
|
||||
new RawTest("localhost", PORT, data3, checkAsyncSeizure),
|
||||
new RawTest("localhost", PORT, data4, checkSeizeAfterAsync),
|
||||
];
|
||||
});
|
||||
|
||||
data = "GET /raw-data HTTP/1.0\r\n" +
|
||||
var data0 = "GET /raw-data HTTP/1.0\r\n" +
|
||||
"\r\n";
|
||||
function checkRawData(data)
|
||||
{
|
||||
do_check_eq(data, "Raw data!");
|
||||
}
|
||||
test = new RawTest("localhost", PORT, data, checkRawData),
|
||||
tests.push(test);
|
||||
|
||||
data = "GET /called-too-late HTTP/1.0\r\n" +
|
||||
var data1 = "GET /called-too-late HTTP/1.0\r\n" +
|
||||
"\r\n";
|
||||
function checkTooLate(data)
|
||||
{
|
||||
do_check_eq(LineIterator(data).next(), "too-late passed");
|
||||
}
|
||||
test = new RawTest("localhost", PORT, data, checkTooLate),
|
||||
tests.push(test);
|
||||
|
||||
data = "GET /exceptions HTTP/1.0\r\n" +
|
||||
var data2 = "GET /exceptions HTTP/1.0\r\n" +
|
||||
"\r\n";
|
||||
function checkExceptions(data)
|
||||
{
|
||||
do_check_eq("exceptions test passed", data);
|
||||
}
|
||||
test = new RawTest("localhost", PORT, data, checkExceptions),
|
||||
tests.push(test);
|
||||
|
||||
data = "GET /async-seizure HTTP/1.0\r\n" +
|
||||
var data3 = "GET /async-seizure HTTP/1.0\r\n" +
|
||||
"\r\n";
|
||||
function checkAsyncSeizure(data)
|
||||
{
|
||||
do_check_eq(data, "async seizure passed");
|
||||
}
|
||||
test = new RawTest("localhost", PORT, data, checkAsyncSeizure),
|
||||
tests.push(test);
|
||||
|
||||
data = "GET /seize-after-async HTTP/1.0\r\n" +
|
||||
var data4 = "GET /seize-after-async HTTP/1.0\r\n" +
|
||||
"\r\n";
|
||||
function checkSeizeAfterAsync(data)
|
||||
{
|
||||
do_check_eq(LineIterator(data).next(), "HTTP/1.0 200 async seizure pass");
|
||||
}
|
||||
test = new RawTest("localhost", PORT, data, checkSeizeAfterAsync),
|
||||
tests.push(test);
|
||||
|
@ -11,21 +11,25 @@ var srv, serverBasePath;
|
||||
function run_test()
|
||||
{
|
||||
srv = createServer();
|
||||
serverBasePath = do_get_cwd();
|
||||
serverBasePath = do_get_profile();
|
||||
srv.registerDirectory("/", serverBasePath);
|
||||
srv.setIndexHandler(myIndexHandler);
|
||||
srv.start(4444);
|
||||
srv.start(-1);
|
||||
|
||||
runHttpTests(tests, testComplete(srv));
|
||||
}
|
||||
|
||||
XPCOMUtils.defineLazyGetter(this, "URL", function() {
|
||||
return "http://localhost:" + srv.identity.primaryPort + "/";
|
||||
});
|
||||
|
||||
var tests = [];
|
||||
var test;
|
||||
XPCOMUtils.defineLazyGetter(this, "tests", function() {
|
||||
return [
|
||||
new Test(URL, init, startCustomIndexHandler, stopCustomIndexHandler),
|
||||
new Test(URL, init, startDefaultIndexHandler, stopDefaultIndexHandler)
|
||||
];
|
||||
});
|
||||
|
||||
test = new Test("http://localhost:4444/",
|
||||
init, startCustomIndexHandler, stopCustomIndexHandler);
|
||||
tests.push(test);
|
||||
function init(ch)
|
||||
{
|
||||
ch.loadFlags |= Ci.nsIRequest.LOAD_BYPASS_CACHE; // important!
|
||||
@ -41,9 +45,6 @@ function stopCustomIndexHandler(ch, cx, status, data)
|
||||
do_check_eq(String.fromCharCode.apply(null, data), "directory!");
|
||||
}
|
||||
|
||||
test = new Test("http://localhost:4444/",
|
||||
init, startDefaultIndexHandler, stopDefaultIndexHandler);
|
||||
tests.push(test);
|
||||
function startDefaultIndexHandler(ch, cx)
|
||||
{
|
||||
do_check_eq(ch.responseStatus, 200);
|
||||
|
@ -7,6 +7,10 @@
|
||||
// exercise nsIHttpResponse.setStatusLine, ensure its atomicity, and ensure the
|
||||
// specified behavior occurs if it's not called
|
||||
|
||||
XPCOMUtils.defineLazyGetter(this, "URL", function() {
|
||||
return "http://localhost:" + srv.identity.primaryPort;
|
||||
});
|
||||
|
||||
var srv;
|
||||
|
||||
function run_test()
|
||||
@ -22,7 +26,7 @@ function run_test()
|
||||
srv.registerPathHandler("/crazyCode", crazyCode);
|
||||
srv.registerPathHandler("/nullVersion", nullVersion);
|
||||
|
||||
srv.start(4444);
|
||||
srv.start(-1);
|
||||
|
||||
runHttpTests(tests, testComplete(srv));
|
||||
}
|
||||
@ -48,16 +52,24 @@ function checkStatusLine(channel, httpMaxVer, httpMinVer, httpCode, statusText)
|
||||
* TESTS *
|
||||
*********/
|
||||
|
||||
var tests = [];
|
||||
var test;
|
||||
XPCOMUtils.defineLazyGetter(this, "tests", function() {
|
||||
return [
|
||||
new Test(URL + "/no/setstatusline", null, startNoSetStatusLine, stop),
|
||||
new Test(URL + "/http1_0", null, startHttp1_0, stop),
|
||||
new Test(URL + "/http1_1", null, startHttp1_1, stop),
|
||||
new Test(URL + "/invalidVersion", null, startPassedTrue, stop),
|
||||
new Test(URL + "/invalidStatus", null, startPassedTrue, stop),
|
||||
new Test(URL + "/invalidDescription", null, startPassedTrue, stop),
|
||||
new Test(URL + "/crazyCode", null, startCrazy, stop),
|
||||
new Test(URL + "/nullVersion", null, startNullVersion, stop)
|
||||
];
|
||||
});
|
||||
|
||||
|
||||
// /no/setstatusline
|
||||
function noSetstatusline(metadata, response)
|
||||
{
|
||||
}
|
||||
test = new Test("http://localhost:4444/no/setstatusline",
|
||||
null, startNoSetStatusLine, stop);
|
||||
tests.push(test);
|
||||
function startNoSetStatusLine(ch, cx)
|
||||
{
|
||||
checkStatusLine(ch, 1, 1, 200, "OK");
|
||||
@ -73,9 +85,6 @@ function http1_0(metadata, response)
|
||||
{
|
||||
response.setStatusLine("1.0", 200, "OK");
|
||||
}
|
||||
test = new Test("http://localhost:4444/http1_0",
|
||||
null, startHttp1_0, stop);
|
||||
tests.push(test);
|
||||
function startHttp1_0(ch, cx)
|
||||
{
|
||||
checkStatusLine(ch, 1, 0, 200, "OK");
|
||||
@ -87,9 +96,6 @@ function http1_1(metadata, response)
|
||||
{
|
||||
response.setStatusLine("1.1", 200, "OK");
|
||||
}
|
||||
test = new Test("http://localhost:4444/http1_1",
|
||||
null, startHttp1_1, stop);
|
||||
tests.push(test);
|
||||
function startHttp1_1(ch, cx)
|
||||
{
|
||||
checkStatusLine(ch, 1, 1, 200, "OK");
|
||||
@ -108,9 +114,6 @@ function invalidVersion(metadata, response)
|
||||
response.setHeader("Passed", "true", false);
|
||||
}
|
||||
}
|
||||
test = new Test("http://localhost:4444/invalidVersion",
|
||||
null, startPassedTrue, stop);
|
||||
tests.push(test);
|
||||
function startPassedTrue(ch, cx)
|
||||
{
|
||||
checkStatusLine(ch, 1, 1, 200, "OK");
|
||||
@ -130,9 +133,6 @@ function invalidStatus(metadata, response)
|
||||
response.setHeader("Passed", "true", false);
|
||||
}
|
||||
}
|
||||
test = new Test("http://localhost:4444/invalidStatus",
|
||||
null, startPassedTrue, stop);
|
||||
tests.push(test);
|
||||
|
||||
|
||||
// /invalidDescription
|
||||
@ -147,9 +147,6 @@ function invalidDescription(metadata, response)
|
||||
response.setHeader("Passed", "true", false);
|
||||
}
|
||||
}
|
||||
test = new Test("http://localhost:4444/invalidDescription",
|
||||
null, startPassedTrue, stop);
|
||||
tests.push(test);
|
||||
|
||||
|
||||
// /crazyCode
|
||||
@ -157,9 +154,6 @@ function crazyCode(metadata, response)
|
||||
{
|
||||
response.setStatusLine("1.1", 617, "Crazy");
|
||||
}
|
||||
test = new Test("http://localhost:4444/crazyCode",
|
||||
null, startCrazy, stop);
|
||||
tests.push(test);
|
||||
function startCrazy(ch, cx)
|
||||
{
|
||||
checkStatusLine(ch, 1, 1, 617, "Crazy");
|
||||
@ -171,9 +165,6 @@ function nullVersion(metadata, response)
|
||||
{
|
||||
response.setStatusLine(null, 255, "NULL");
|
||||
}
|
||||
test = new Test("http://localhost:4444/nullVersion",
|
||||
null, startNullVersion, stop);
|
||||
tests.push(test);
|
||||
function startNullVersion(ch, cx)
|
||||
{
|
||||
// currently, this server implementation defaults to 1.1
|
||||
|
@ -6,10 +6,17 @@
|
||||
|
||||
// tests support for server JS-generated pages
|
||||
|
||||
const BASE = "http://localhost:4444";
|
||||
var srv = createServer();
|
||||
|
||||
var sjs = do_get_file("data/sjs/cgi.sjs");
|
||||
var srv;
|
||||
// NB: The server has no state at this point -- all state is set up and torn
|
||||
// down in the tests, because we run the same tests twice with only a
|
||||
// different query string on the requests, followed by the oddball
|
||||
// test that doesn't care about throwing or not.
|
||||
srv.start(-1);
|
||||
const PORT = srv.identity.primaryPort;
|
||||
|
||||
const BASE = "http://localhost:" + PORT;
|
||||
var test;
|
||||
var tests = [];
|
||||
|
||||
@ -230,8 +237,6 @@ tests.push(test);
|
||||
|
||||
function run_test()
|
||||
{
|
||||
srv = createServer();
|
||||
|
||||
// Test for a content-type which isn't a field-value
|
||||
try
|
||||
{
|
||||
@ -242,13 +247,5 @@ function run_test()
|
||||
{
|
||||
isException(e, Cr.NS_ERROR_INVALID_ARG);
|
||||
}
|
||||
|
||||
|
||||
// NB: The server has no state at this point -- all state is set up and torn
|
||||
// down in the tests, because we run the same tests twice with only a
|
||||
// different query string on the requests, followed by the oddball
|
||||
// test that doesn't care about throwing or not.
|
||||
|
||||
srv.start(4444);
|
||||
runHttpTests(tests, testComplete(srv));
|
||||
}
|
||||
|
@ -8,9 +8,10 @@
|
||||
* Tests that the object-state-preservation mechanism works correctly.
|
||||
*/
|
||||
|
||||
const PORT = 4444;
|
||||
|
||||
const PATH = "http://localhost:" + PORT + "/object-state.sjs";
|
||||
XPCOMUtils.defineLazyGetter(this, "PATH", function() {
|
||||
return "http://localhost:" + srv.identity.primaryPort + "/object-state.sjs";
|
||||
});
|
||||
|
||||
var srv;
|
||||
|
||||
@ -20,7 +21,7 @@ function run_test()
|
||||
var sjsDir = do_get_file("data/sjs/");
|
||||
srv.registerDirectory("/", sjsDir);
|
||||
srv.registerContentType("sjs", "sjs");
|
||||
srv.start(PORT);
|
||||
srv.start(-1);
|
||||
|
||||
do_test_pending();
|
||||
|
||||
|
@ -6,7 +6,9 @@
|
||||
|
||||
// exercises the server's state-preservation API
|
||||
|
||||
const PORT = 4444;
|
||||
XPCOMUtils.defineLazyGetter(this, "URL", function() {
|
||||
return "http://localhost:" + srv.identity.primaryPort;
|
||||
});
|
||||
|
||||
var srv;
|
||||
|
||||
@ -17,7 +19,7 @@ function run_test()
|
||||
srv.registerDirectory("/", sjsDir);
|
||||
srv.registerContentType("sjs", "sjs");
|
||||
srv.registerPathHandler("/path-handler", pathHandler);
|
||||
srv.start(PORT);
|
||||
srv.start(-1);
|
||||
|
||||
function done()
|
||||
{
|
||||
@ -76,8 +78,35 @@ function pathHandler(request, response)
|
||||
* BEGIN TESTS *
|
||||
***************/
|
||||
|
||||
var test;
|
||||
var tests = [];
|
||||
XPCOMUtils.defineLazyGetter(this, "tests", function() {
|
||||
return [
|
||||
new Test(URL + "/state1.sjs?" +
|
||||
"newShared=newShared&newPrivate=newPrivate",
|
||||
null, start_initial, null),
|
||||
new Test(URL + "/state1.sjs?" +
|
||||
"newShared=newShared2&newPrivate=newPrivate2",
|
||||
null, start_overwrite, null),
|
||||
new Test(URL + "/state1.sjs?" +
|
||||
"newShared=&newPrivate=newPrivate3",
|
||||
null, start_remove, null),
|
||||
new Test(URL + "/path-handler",
|
||||
null, start_handler, null),
|
||||
new Test(URL + "/path-handler",
|
||||
null, start_handler_again, null),
|
||||
new Test(URL + "/state2.sjs?" +
|
||||
"newShared=newShared4&newPrivate=newPrivate4",
|
||||
null, start_other_initial, null),
|
||||
new Test(URL + "/state2.sjs?" +
|
||||
"newShared=",
|
||||
null, start_other_remove_ignore, null),
|
||||
new Test(URL + "/state2.sjs?" +
|
||||
"newShared=newShared5&newPrivate=newPrivate5",
|
||||
null, start_other_set_new, null),
|
||||
new Test(URL + "/state1.sjs?" +
|
||||
"newShared=done!&newPrivate=",
|
||||
null, start_set_remove_original, null)
|
||||
];
|
||||
});
|
||||
|
||||
/* Hack around bug 474845 for now. */
|
||||
function getHeaderFunction(ch)
|
||||
@ -109,100 +138,48 @@ function expectValues(ch, oldShared, newShared, oldPrivate, newPrivate)
|
||||
do_check_eq(getHeader("X-New-Private-Value"), newPrivate);
|
||||
}
|
||||
|
||||
|
||||
test = new Test("http://localhost:4444/state1.sjs?" +
|
||||
"newShared=newShared&newPrivate=newPrivate",
|
||||
null, start_initial, null);
|
||||
tests.push(test);
|
||||
|
||||
function start_initial(ch, cx)
|
||||
{
|
||||
dumpn("XXX start_initial");
|
||||
expectValues(ch, "", "newShared", "", "newPrivate");
|
||||
}
|
||||
|
||||
|
||||
test = new Test("http://localhost:4444/state1.sjs?" +
|
||||
"newShared=newShared2&newPrivate=newPrivate2",
|
||||
null, start_overwrite, null);
|
||||
tests.push(test);
|
||||
|
||||
function start_overwrite(ch, cx)
|
||||
{
|
||||
expectValues(ch, "newShared", "newShared2", "newPrivate", "newPrivate2");
|
||||
}
|
||||
|
||||
|
||||
test = new Test("http://localhost:4444/state1.sjs?" +
|
||||
"newShared=&newPrivate=newPrivate3",
|
||||
null, start_remove, null);
|
||||
tests.push(test);
|
||||
|
||||
function start_remove(ch, cx)
|
||||
{
|
||||
expectValues(ch, "newShared2", "", "newPrivate2", "newPrivate3");
|
||||
}
|
||||
|
||||
|
||||
test = new Test("http://localhost:4444/path-handler",
|
||||
null, start_handler, null);
|
||||
tests.push(test);
|
||||
|
||||
function start_handler(ch, cx)
|
||||
{
|
||||
expectValues(ch, "", "pathHandlerShared", "", "pathHandlerPrivate");
|
||||
}
|
||||
|
||||
|
||||
test = new Test("http://localhost:4444/path-handler",
|
||||
null, start_handler_again, null);
|
||||
tests.push(test);
|
||||
|
||||
function start_handler_again(ch, cx)
|
||||
{
|
||||
expectValues(ch, "pathHandlerShared", "",
|
||||
"pathHandlerPrivate", "pathHandlerPrivate2");
|
||||
}
|
||||
|
||||
|
||||
test = new Test("http://localhost:4444/state2.sjs?" +
|
||||
"newShared=newShared4&newPrivate=newPrivate4",
|
||||
null, start_other_initial, null);
|
||||
tests.push(test);
|
||||
|
||||
function start_other_initial(ch, cx)
|
||||
{
|
||||
expectValues(ch, "", "newShared4", "", "newPrivate4");
|
||||
}
|
||||
|
||||
|
||||
test = new Test("http://localhost:4444/state2.sjs?" +
|
||||
"newShared=",
|
||||
null, start_other_remove_ignore, null);
|
||||
tests.push(test);
|
||||
|
||||
function start_other_remove_ignore(ch, cx)
|
||||
{
|
||||
expectValues(ch, "newShared4", "", "newPrivate4", "");
|
||||
}
|
||||
|
||||
|
||||
test = new Test("http://localhost:4444/state2.sjs?" +
|
||||
"newShared=newShared5&newPrivate=newPrivate5",
|
||||
null, start_other_set_new, null);
|
||||
tests.push(test);
|
||||
|
||||
function start_other_set_new(ch, cx)
|
||||
{
|
||||
expectValues(ch, "", "newShared5", "newPrivate4", "newPrivate5");
|
||||
}
|
||||
|
||||
|
||||
test = new Test("http://localhost:4444/state1.sjs?" +
|
||||
"newShared=done!&newPrivate=",
|
||||
null, start_set_remove_original, null);
|
||||
tests.push(test);
|
||||
|
||||
function start_set_remove_original(ch, cx)
|
||||
{
|
||||
expectValues(ch, "newShared5", "done!", "newPrivate3", "");
|
||||
|
@ -10,15 +10,19 @@
|
||||
* then preventing any file from being opened).
|
||||
*/
|
||||
|
||||
const PORT = 4444;
|
||||
XPCOMUtils.defineLazyGetter(this, "URL", function() {
|
||||
return "http://localhost:" + srv.identity.primaryPort;
|
||||
});
|
||||
|
||||
var srv;
|
||||
|
||||
function run_test()
|
||||
{
|
||||
var srv = createServer();
|
||||
srv = createServer();
|
||||
var sjsDir = do_get_file("data/sjs/");
|
||||
srv.registerDirectory("/", sjsDir);
|
||||
srv.registerContentType("sjs", "sjs");
|
||||
srv.start(PORT);
|
||||
srv.start(-1);
|
||||
|
||||
function done()
|
||||
{
|
||||
@ -41,16 +45,15 @@ var lastPassed = false;
|
||||
// This hits the open-file limit for me on OS X; your mileage may vary.
|
||||
const TEST_RUNS = 250;
|
||||
|
||||
var test = new Test("http://localhost:4444/thrower.sjs?throw",
|
||||
null, start_thrower);
|
||||
|
||||
var tests = new Array(TEST_RUNS + 1);
|
||||
for (var i = 0; i < TEST_RUNS; i++)
|
||||
tests[i] = test;
|
||||
|
||||
// ...and don't forget to stop!
|
||||
tests[TEST_RUNS] = new Test("http://localhost:4444/thrower.sjs",
|
||||
null, start_last);
|
||||
XPCOMUtils.defineLazyGetter(this, "tests", function() {
|
||||
var _tests = new Array(TEST_RUNS + 1);
|
||||
var _test = new Test(URL + "/thrower.sjs?throw", null, start_thrower);
|
||||
for (var i = 0; i < TEST_RUNS; i++)
|
||||
_tests[i] = _test;
|
||||
// ...and don't forget to stop!
|
||||
_tests[TEST_RUNS] = new Test(URL + "/thrower.sjs", null, start_last);
|
||||
return _tests;
|
||||
});
|
||||
|
||||
function start_thrower(ch, cx)
|
||||
{
|
||||
|
@ -8,8 +8,13 @@
|
||||
* Tests for correct behavior of the server start() and stop() methods.
|
||||
*/
|
||||
|
||||
const PORT = 4444;
|
||||
const PREPATH = "http://localhost:" + PORT;
|
||||
XPCOMUtils.defineLazyGetter(this, "PORT", function() {
|
||||
return srv.identity.primaryPort;
|
||||
});
|
||||
|
||||
XPCOMUtils.defineLazyGetter(this, "PREPATH", function() {
|
||||
return "http://localhost:" + PORT;
|
||||
});
|
||||
|
||||
var srv, srv2;
|
||||
|
||||
@ -25,7 +30,7 @@ function run_test()
|
||||
dumpn("*** run_test");
|
||||
|
||||
srv = createServer();
|
||||
srv.start(PORT);
|
||||
srv.start(-1);
|
||||
|
||||
try
|
||||
{
|
||||
|
@ -13,6 +13,7 @@ tail =
|
||||
[test_header_array.js]
|
||||
[test_headers.js]
|
||||
[test_host.js]
|
||||
run-sequentially = Reusing same server on different specific ports.
|
||||
[test_linedata.js]
|
||||
[test_load_module.js]
|
||||
[test_name_scheme.js]
|
||||
|
Loading…
Reference in New Issue
Block a user