netwerk/test/httpserver/test/test_name_scheme.js

Wed, 31 Dec 2014 07:53:36 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 07:53:36 +0100
branch
TOR_BUG_3246
changeset 5
4ab42b5ab56c
permissions
-rw-r--r--

Correct small whitespace inconsistency, lost while renaming variables.

     1 /* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     2 /* vim:set ts=2 sw=2 sts=2 et: */
     3 /* This Source Code Form is subject to the terms of the Mozilla Public
     4  * License, v. 2.0. If a copy of the MPL was not distributed with this
     5  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     7 // requests for files ending with a caret (^) are handled specially to enable
     8 // htaccess-like functionality without the need to explicitly disable display
     9 // of such files
    11 var srv;
    13 XPCOMUtils.defineLazyGetter(this, "PREFIX", function() {
    14   return "http://localhost:" + srv.identity.primaryPort;
    15 });
    17 XPCOMUtils.defineLazyGetter(this, "tests", function() {
    18   return [
    19     new Test(PREFIX + "/bar.html^",
    20             null, start_bar_html_, null),
    21     new Test(PREFIX + "/foo.html^",
    22             null, start_foo_html_, null),
    23     new Test(PREFIX + "/normal-file.txt",
    24             null, start_normal_file_txt, null),
    25     new Test(PREFIX + "/folder^/file.txt",
    26             null, start_folder__file_txt, null),
    28     new Test(PREFIX + "/foo/bar.html^",
    29             null, start_bar_html_, null),
    30     new Test(PREFIX + "/foo/foo.html^",
    31             null, start_foo_html_, null),
    32     new Test(PREFIX + "/foo/normal-file.txt",
    33             null, start_normal_file_txt, null),
    34     new Test(PREFIX + "/foo/folder^/file.txt",
    35             null, start_folder__file_txt, null),
    37     new Test(PREFIX + "/end-caret^/bar.html^",
    38             null, start_bar_html_, null),
    39     new Test(PREFIX + "/end-caret^/foo.html^",
    40             null, start_foo_html_, null),
    41     new Test(PREFIX + "/end-caret^/normal-file.txt",
    42             null, start_normal_file_txt, null),
    43     new Test(PREFIX + "/end-caret^/folder^/file.txt",
    44             null, start_folder__file_txt, null)
    45     ];
    46 });
    49 function run_test()
    50 {
    51   srv = createServer();
    53   // make sure underscores work in directories "mounted" in directories with
    54   // folders starting with _
    55   var nameDir = do_get_file("data/name-scheme/");
    56   srv.registerDirectory("/", nameDir);
    57   srv.registerDirectory("/foo/", nameDir);
    58   srv.registerDirectory("/end-caret^/", nameDir);
    60   srv.start(-1);
    62   runHttpTests(tests, testComplete(srv));
    63 }
    66 // TEST DATA
    68 function start_bar_html_(ch, cx)
    69 {
    70   do_check_eq(ch.responseStatus, 200);
    72   do_check_eq(ch.getResponseHeader("Content-Type"), "text/html");
    73 }
    75 function start_foo_html_(ch, cx)
    76 {
    77   do_check_eq(ch.responseStatus, 404);
    78 }
    80 function start_normal_file_txt(ch, cx)
    81 {
    82   do_check_eq(ch.responseStatus, 200);
    83   do_check_eq(ch.getResponseHeader("Content-Type"), "text/plain");
    84 }
    86 function start_folder__file_txt(ch, cx)
    87 {
    88   do_check_eq(ch.responseStatus, 200);
    89   do_check_eq(ch.getResponseHeader("Content-Type"), "text/plain");
    90 }

mercurial