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