2007-01-26 21:44:58 +03:00
|
|
|
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim:set ts=2 sw=2 sts=2 et: */
|
|
|
|
/* ***** BEGIN LICENSE BLOCK *****
|
|
|
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
|
|
|
*
|
|
|
|
* The contents of this file are subject to the Mozilla Public License Version
|
|
|
|
* 1.1 (the "License"); you may not use this file except in compliance with
|
|
|
|
* the License. You may obtain a copy of the License at
|
|
|
|
* http://www.mozilla.org/MPL/
|
|
|
|
*
|
|
|
|
* Software distributed under the License is distributed on an "AS IS" basis,
|
|
|
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
|
|
|
* for the specific language governing rights and limitations under the
|
|
|
|
* License.
|
|
|
|
*
|
|
|
|
* The Original Code is MozJSHTTP code.
|
|
|
|
*
|
|
|
|
* The Initial Developer of the Original Code is
|
|
|
|
* Jeff Walden <jwalden+code@mit.edu>.
|
|
|
|
* Portions created by the Initial Developer are Copyright (C) 2006
|
|
|
|
* the Initial Developer. All Rights Reserved.
|
|
|
|
*
|
|
|
|
* Contributor(s):
|
|
|
|
* Robert Sayre <sayrer@gmail.com>
|
|
|
|
*
|
|
|
|
* Alternatively, the contents of this file may be used under the terms of
|
|
|
|
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
|
|
|
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
|
|
|
* in which case the provisions of the GPL or the LGPL are applicable instead
|
|
|
|
* of those above. If you wish to allow use of your version of this file only
|
|
|
|
* under the terms of either the GPL or the LGPL, and not to allow others to
|
|
|
|
* use your version of this file under the terms of the MPL, indicate your
|
|
|
|
* decision by deleting the provisions above and replace them with the notice
|
|
|
|
* and other provisions required by the GPL or the LGPL. If you do not delete
|
|
|
|
* the provisions above, a recipient may use your version of this file under
|
|
|
|
* the terms of any one of the MPL, the GPL or the LGPL.
|
|
|
|
*
|
|
|
|
* ***** END LICENSE BLOCK ***** */
|
|
|
|
|
|
|
|
// Note that the server script itself already defines Cc, Ci, and Cr for us,
|
|
|
|
// and because they're constants it's not safe to redefine them. Scope leakage
|
|
|
|
// sucks.
|
|
|
|
|
|
|
|
const SERVER_PORT = 8888;
|
|
|
|
var server; // for use in the shutdown handler, if necessary
|
|
|
|
|
|
|
|
//
|
|
|
|
// HTML GENERATION
|
|
|
|
//
|
|
|
|
var tags = ['A', 'ABBR', 'ACRONYM', 'ADDRESS', 'APPLET', 'AREA', 'B', 'BASE',
|
|
|
|
'BASEFONT', 'BDO', 'BIG', 'BLOCKQUOTE', 'BODY', 'BR', 'BUTTON',
|
|
|
|
'CAPTION', 'CENTER', 'CITE', 'CODE', 'COL', 'COLGROUP', 'DD',
|
|
|
|
'DEL', 'DFN', 'DIR', 'DIV', 'DL', 'DT', 'EM', 'FIELDSET', 'FONT',
|
|
|
|
'FORM', 'FRAME', 'FRAMESET', 'H1', 'H2', 'H3', 'H4', 'H5', 'H6',
|
|
|
|
'HEAD', 'HR', 'HTML', 'I', 'IFRAME', 'IMG', 'INPUT', 'INS',
|
|
|
|
'ISINDEX', 'KBD', 'LABEL', 'LEGEND', 'LI', 'LINK', 'MAP', 'MENU',
|
|
|
|
'META', 'NOFRAMES', 'NOSCRIPT', 'OBJECT', 'OL', 'OPTGROUP',
|
|
|
|
'OPTION', 'P', 'PARAM', 'PRE', 'Q', 'S', 'SAMP', 'SCRIPT',
|
|
|
|
'SELECT', 'SMALL', 'SPAN', 'STRIKE', 'STRONG', 'STYLE', 'SUB',
|
|
|
|
'SUP', 'TABLE', 'TBODY', 'TD', 'TEXTAREA', 'TFOOT', 'TH', 'THEAD',
|
|
|
|
'TITLE', 'TR', 'TT', 'U', 'UL', 'VAR'];
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Below, we'll use makeTagFunc to create a function for each of the
|
|
|
|
* strings in 'tags'. This will allow us to use s-expression like syntax
|
|
|
|
* to create HTML.
|
|
|
|
*/
|
|
|
|
function makeTagFunc(tagName)
|
|
|
|
{
|
|
|
|
return function (attrs /* rest... */)
|
|
|
|
{
|
|
|
|
var startChildren = 0;
|
|
|
|
var response = "";
|
|
|
|
|
|
|
|
// write the start tag and attributes
|
|
|
|
response += "<" + tagName;
|
|
|
|
// if attr is an object, write attributes
|
|
|
|
if (attrs && typeof attrs == 'object') {
|
|
|
|
startChildren = 1;
|
|
|
|
for (var [key,value] in attrs) {
|
|
|
|
var val = "" + value;
|
|
|
|
response += " " + key + '="' + val.replace('"','"') + '"';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
response += ">";
|
|
|
|
|
|
|
|
// iterate through the rest of the args
|
|
|
|
for (var i = startChildren; i < arguments.length; i++) {
|
|
|
|
if (typeof arguments[i] == 'function') {
|
|
|
|
response += arguments[i]();
|
|
|
|
} else {
|
|
|
|
response += arguments[i];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// write the close tag
|
|
|
|
response += "</" + tagName + ">\n";
|
|
|
|
return response;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-02-20 04:56:30 +03:00
|
|
|
function makeTags() {
|
|
|
|
// map our global HTML generation functions
|
2008-01-29 06:48:34 +03:00
|
|
|
for each (var tag in tags) {
|
|
|
|
this[tag] = makeTagFunc(tag.toLowerCase());
|
2007-02-20 04:56:30 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// only run the "main" section if httpd.js was loaded ahead of us
|
|
|
|
if (this["nsHttpServer"]) {
|
|
|
|
//
|
|
|
|
// SCRIPT CODE
|
|
|
|
//
|
|
|
|
runServer();
|
|
|
|
|
2008-01-29 06:48:34 +03:00
|
|
|
// We can only have gotten here if the /server/shutdown path was requested,
|
|
|
|
// and we can shut down the xpcshell now that all testing requests have been
|
|
|
|
// served.
|
2007-02-20 04:56:30 +03:00
|
|
|
quit(0);
|
|
|
|
}
|
2007-01-26 21:44:58 +03:00
|
|
|
|
2007-02-20 04:56:30 +03:00
|
|
|
var serverBasePath;
|
2007-01-26 21:44:58 +03:00
|
|
|
|
|
|
|
//
|
|
|
|
// SERVER SETUP
|
|
|
|
//
|
|
|
|
function runServer()
|
|
|
|
{
|
2007-02-20 04:56:30 +03:00
|
|
|
serverBasePath = Cc["@mozilla.org/file/local;1"]
|
2007-01-26 21:44:58 +03:00
|
|
|
.createInstance(Ci.nsILocalFile);
|
|
|
|
var procDir = Cc["@mozilla.org/file/directory_service;1"]
|
|
|
|
.getService(Ci.nsIProperties).get("CurProcD", Ci.nsIFile);
|
|
|
|
serverBasePath.initWithPath(procDir.parent.parent.path);
|
|
|
|
serverBasePath.append("_tests");
|
|
|
|
serverBasePath.append("testing");
|
|
|
|
serverBasePath.append("mochitest");
|
|
|
|
server = new nsHttpServer();
|
|
|
|
server.registerDirectory("/", serverBasePath);
|
|
|
|
|
2008-01-29 06:48:34 +03:00
|
|
|
server.registerPathHandler("/server/shutdown", serverShutdown);
|
2007-01-26 21:44:58 +03:00
|
|
|
|
2008-02-12 22:40:59 +03:00
|
|
|
server.registerContentType("sjs", "sjs"); // .sjs == CGI-like functionality
|
|
|
|
|
2007-01-26 21:44:58 +03:00
|
|
|
server.setIndexHandler(defaultDirHandler);
|
|
|
|
server.start(SERVER_PORT);
|
2007-07-13 04:58:25 +04:00
|
|
|
|
2007-01-26 21:44:58 +03:00
|
|
|
// touch a file in the profile directory to indicate we're alive
|
|
|
|
var foStream = Cc["@mozilla.org/network/file-output-stream;1"]
|
|
|
|
.createInstance(Ci.nsIFileOutputStream);
|
|
|
|
var serverAlive = Cc["@mozilla.org/file/local;1"]
|
|
|
|
.createInstance(Ci.nsILocalFile);
|
|
|
|
serverAlive.initWithFile(serverBasePath);
|
2007-01-31 08:14:23 +03:00
|
|
|
serverAlive.append("mochitesttestingprofile");
|
2007-01-26 21:44:58 +03:00
|
|
|
|
|
|
|
// If we're running outside of the test harness, there might
|
|
|
|
// not be a test profile directory present
|
|
|
|
if (serverAlive.exists()) {
|
|
|
|
serverAlive.append("server_alive.txt");
|
|
|
|
foStream.init(serverAlive,
|
|
|
|
0x02 | 0x08 | 0x20, 0664, 0); // write, create, truncate
|
|
|
|
data = "It's alive!";
|
|
|
|
foStream.write(data, data.length);
|
|
|
|
foStream.close();
|
|
|
|
}
|
|
|
|
|
2007-02-20 04:56:30 +03:00
|
|
|
makeTags();
|
2007-01-26 21:44:58 +03:00
|
|
|
|
|
|
|
//
|
|
|
|
// The following is threading magic to spin an event loop -- this has to
|
|
|
|
// happen manually in xpcshell for the server to actually work.
|
|
|
|
//
|
|
|
|
var thread = Cc["@mozilla.org/thread-manager;1"]
|
|
|
|
.getService()
|
|
|
|
.currentThread;
|
|
|
|
while (!server.isStopped())
|
|
|
|
thread.processNextEvent(true);
|
|
|
|
|
|
|
|
// Server stopped by /server/shutdown handler -- go through pending events
|
|
|
|
// and return.
|
|
|
|
|
|
|
|
// get rid of any pending requests
|
|
|
|
while (thread.hasPendingEvents())
|
|
|
|
thread.processNextEvent(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
// PATH HANDLERS
|
|
|
|
|
|
|
|
// /server/shutdown
|
|
|
|
function serverShutdown(metadata, response)
|
|
|
|
{
|
|
|
|
response.setStatusLine("1.1", 200, "OK");
|
2008-03-18 20:42:39 +03:00
|
|
|
response.setHeader("Content-type", "text/plain", false);
|
2007-01-26 21:44:58 +03:00
|
|
|
|
|
|
|
var body = "Server shut down.";
|
|
|
|
response.bodyOutputStream.write(body, body.length);
|
|
|
|
|
|
|
|
// Note: this doesn't disrupt the current request.
|
|
|
|
server.stop();
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// DIRECTORY LISTINGS
|
|
|
|
//
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Creates a generator that iterates over the contents of
|
|
|
|
* an nsIFile directory.
|
|
|
|
*/
|
|
|
|
function dirIter(dir)
|
|
|
|
{
|
|
|
|
var enum = dir.directoryEntries;
|
|
|
|
while (enum.hasMoreElements()) {
|
|
|
|
var file = enum.getNext();
|
|
|
|
yield file.QueryInterface(Ci.nsILocalFile);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Builds an optionally nested object containing links to the
|
|
|
|
* files and directories within dir.
|
|
|
|
*/
|
|
|
|
function list(requestPath, directory, recurse)
|
|
|
|
{
|
2007-01-31 21:25:15 +03:00
|
|
|
var count = 0;
|
2007-01-26 21:44:58 +03:00
|
|
|
var path = requestPath;
|
|
|
|
if (path.charAt(path.length - 1) != "/") {
|
|
|
|
path += "/";
|
|
|
|
}
|
|
|
|
|
|
|
|
var dir = directory.QueryInterface(Ci.nsIFile);
|
|
|
|
var links = {};
|
|
|
|
|
|
|
|
// The SimpleTest directory is hidden
|
|
|
|
var files = [file for (file in dirIter(dir))
|
2008-03-15 04:12:05 +03:00
|
|
|
if (file.exists() && file.path.indexOf("SimpleTest") == -1)];
|
2007-01-31 21:25:15 +03:00
|
|
|
|
2007-06-22 00:21:30 +04:00
|
|
|
// Sort files by name, so that tests can be run in a pre-defined order inside
|
|
|
|
// a given directory (see bug 384823)
|
|
|
|
function leafNameComparator(first, second) {
|
|
|
|
if (first.leafName < second.leafName)
|
|
|
|
return -1;
|
|
|
|
if (first.leafName > second.leafName)
|
|
|
|
return 1;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
files.sort(leafNameComparator);
|
|
|
|
|
2007-01-31 21:25:15 +03:00
|
|
|
count = files.length;
|
2007-01-26 21:44:58 +03:00
|
|
|
for each (var file in files) {
|
2007-06-15 09:42:06 +04:00
|
|
|
var key = path + file.leafName;
|
2007-01-31 21:25:15 +03:00
|
|
|
var childCount = 0;
|
2007-01-26 21:44:58 +03:00
|
|
|
if (file.isDirectory()) {
|
|
|
|
key += "/";
|
|
|
|
}
|
|
|
|
if (recurse && file.isDirectory()) {
|
2007-01-31 21:25:15 +03:00
|
|
|
[links[key], childCount] = list(key, file, recurse);
|
|
|
|
count += childCount;
|
2007-01-26 21:44:58 +03:00
|
|
|
} else {
|
2007-04-27 20:48:53 +04:00
|
|
|
if (file.leafName.charAt(0) != '.') {
|
|
|
|
links[key] = true;
|
|
|
|
}
|
2007-01-26 21:44:58 +03:00
|
|
|
}
|
|
|
|
}
|
2007-01-31 21:25:15 +03:00
|
|
|
|
|
|
|
return [links, count];
|
2007-01-26 21:44:58 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Heuristic function that determines whether a given path
|
|
|
|
* is a test case to be executed in the harness, or just
|
|
|
|
* a supporting file.
|
|
|
|
*/
|
2007-07-09 20:24:15 +04:00
|
|
|
function isTest(filename, pattern)
|
2007-01-26 21:44:58 +03:00
|
|
|
{
|
2007-07-09 20:24:15 +04:00
|
|
|
if (pattern)
|
|
|
|
return pattern.test(filename);
|
|
|
|
|
|
|
|
return filename.indexOf("test_") > -1 &&
|
|
|
|
filename.indexOf(".js") == -1 &&
|
2007-11-11 20:44:50 +03:00
|
|
|
filename.indexOf(".css") == -1 &&
|
2007-11-12 19:55:48 +03:00
|
|
|
!/\^headers\^$/.test(filename);
|
2007-01-26 21:44:58 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Transform nested hashtables of paths to nested HTML lists.
|
|
|
|
*/
|
|
|
|
function linksToListItems(links)
|
|
|
|
{
|
|
|
|
var response = "";
|
2007-01-29 08:45:52 +03:00
|
|
|
var children = "";
|
2007-01-26 21:44:58 +03:00
|
|
|
for (var [link, value] in links) {
|
|
|
|
var classVal = (!isTest(link) && !(value instanceof Object))
|
|
|
|
? "non-test invisible"
|
2007-01-29 08:45:52 +03:00
|
|
|
: "test";
|
2007-01-26 21:44:58 +03:00
|
|
|
if (value instanceof Object) {
|
2007-01-29 08:45:52 +03:00
|
|
|
children = UL({class: "testdir"}, linksToListItems(value));
|
|
|
|
} else {
|
|
|
|
children = "";
|
2007-01-26 21:44:58 +03:00
|
|
|
}
|
2007-06-17 15:51:35 +04:00
|
|
|
|
|
|
|
var bug_title = link.match(/test_bug\S+/);
|
|
|
|
var bug_num = null;
|
|
|
|
if (bug_title != null) {
|
|
|
|
bug_num = bug_title[0].match(/\d+/);
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((bug_title == null) || (bug_num == null)) {
|
|
|
|
response += LI({class: classVal}, A({href: link}, link), children);
|
|
|
|
} else {
|
2007-07-13 03:33:51 +04:00
|
|
|
var bug_url = "https://bugzilla.mozilla.org/show_bug.cgi?id="+bug_num;
|
2007-06-17 15:51:35 +04:00
|
|
|
response += LI({class: classVal}, A({href: link}, link), " - ", A({href: bug_url}, "Bug "+bug_num), children);
|
|
|
|
}
|
2007-01-29 08:45:52 +03:00
|
|
|
|
2007-01-26 21:44:58 +03:00
|
|
|
}
|
|
|
|
return response;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Transform nested hashtables of paths to a flat table rows.
|
|
|
|
*/
|
|
|
|
function linksToTableRows(links)
|
|
|
|
{
|
|
|
|
var response = "";
|
|
|
|
for (var [link, value] in links) {
|
|
|
|
var classVal = (!isTest(link) && !(value instanceof Object))
|
|
|
|
? "non-test invisible"
|
|
|
|
: "";
|
|
|
|
if (value instanceof Object) {
|
|
|
|
response += TR({class: "dir", id: "tr-" + link },
|
2007-02-22 01:51:46 +03:00
|
|
|
TD({colspan: "3"}," "));
|
2007-01-26 21:44:58 +03:00
|
|
|
response += linksToTableRows(value);
|
|
|
|
} else {
|
|
|
|
response += TR({class: classVal, id: "tr-" + link},
|
|
|
|
TD("0"), TD("0"), TD("0"));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return response;
|
|
|
|
}
|
|
|
|
|
2007-07-09 20:24:15 +04:00
|
|
|
function arrayOfTestFiles(linkArray, fileArray, testPattern) {
|
|
|
|
for (var [link, value] in linkArray) {
|
|
|
|
if (value instanceof Object) {
|
|
|
|
arrayOfTestFiles(value, fileArray, testPattern);
|
|
|
|
} else if (isTest(link, testPattern)) {
|
|
|
|
fileArray.push(link)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2007-01-26 21:44:58 +03:00
|
|
|
/**
|
|
|
|
* Produce a flat array of test file paths to be executed in the harness.
|
|
|
|
*/
|
|
|
|
function jsonArrayOfTestFiles(links)
|
|
|
|
{
|
|
|
|
var testFiles = [];
|
2007-07-09 20:24:15 +04:00
|
|
|
arrayOfTestFiles(links, testFiles);
|
|
|
|
testFiles = ['"' + file + '"' for each(file in testFiles)];
|
2007-01-26 21:44:58 +03:00
|
|
|
return "[" + testFiles.join(",\n") + "]";
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Produce a normal directory listing.
|
|
|
|
*/
|
|
|
|
function regularListing(metadata, response)
|
|
|
|
{
|
2007-01-31 21:25:15 +03:00
|
|
|
var [links, count] = list(metadata.path,
|
|
|
|
metadata.getProperty("directory"),
|
|
|
|
false);
|
2007-01-26 21:44:58 +03:00
|
|
|
response.write(
|
|
|
|
HTML(
|
|
|
|
HEAD(
|
|
|
|
TITLE("mochitest index ", metadata.path)
|
|
|
|
),
|
|
|
|
BODY(
|
|
|
|
BR(),
|
|
|
|
A({href: ".."}, "Up a level"),
|
|
|
|
UL(linksToListItems(links))
|
|
|
|
)
|
|
|
|
)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Produce a test harness page containing all the test cases
|
|
|
|
* below it, recursively.
|
|
|
|
*/
|
|
|
|
function testListing(metadata, response)
|
|
|
|
{
|
2007-01-31 21:25:15 +03:00
|
|
|
var [links, count] = list(metadata.path,
|
|
|
|
metadata.getProperty("directory"),
|
|
|
|
true);
|
|
|
|
dumpn("count: " + count);
|
2007-01-26 21:44:58 +03:00
|
|
|
var tests = jsonArrayOfTestFiles(links);
|
|
|
|
response.write(
|
|
|
|
HTML(
|
|
|
|
HEAD(
|
|
|
|
TITLE("MochiTest | ", metadata.path),
|
|
|
|
LINK({rel: "stylesheet",
|
|
|
|
type: "text/css", href: "/static/harness.css"}
|
|
|
|
),
|
|
|
|
SCRIPT({type: "text/javascript", src: "/MochiKit/packed.js"}),
|
|
|
|
SCRIPT({type: "text/javascript",
|
|
|
|
src: "/tests/SimpleTest/TestRunner.js"}),
|
|
|
|
SCRIPT({type: "text/javascript",
|
|
|
|
src: "/tests/SimpleTest/MozillaFileLogger.js"}),
|
|
|
|
SCRIPT({type: "text/javascript",
|
|
|
|
src: "/tests/SimpleTest/quit.js"}),
|
|
|
|
SCRIPT({type: "text/javascript",
|
|
|
|
src: "/tests/SimpleTest/setup.js"}),
|
|
|
|
SCRIPT({type: "text/javascript"},
|
2007-02-20 04:56:30 +03:00
|
|
|
"connect(window, 'onload', hookup); gTestList=" + tests + ";"
|
2007-01-26 21:44:58 +03:00
|
|
|
)
|
|
|
|
),
|
|
|
|
BODY(
|
|
|
|
DIV({class: "container"},
|
|
|
|
H2("--> ", A({href: "#", id: "runtests"}, "Run Tests"), " <--"),
|
2007-01-29 08:45:52 +03:00
|
|
|
P({style: "float: right;"},
|
|
|
|
SMALL(
|
|
|
|
"Based on the ",
|
|
|
|
A({href:"http://www.mochikit.com/"}, "MochiKit"),
|
|
|
|
" unit tests."
|
|
|
|
)
|
|
|
|
),
|
2007-01-26 21:44:58 +03:00
|
|
|
DIV({class: "status"},
|
|
|
|
H1({id: "indicator"}, "Status"),
|
|
|
|
H2({id: "pass"}, "Passed: ", SPAN({id: "pass-count"},"0")),
|
|
|
|
H2({id: "fail"}, "Failed: ", SPAN({id: "fail-count"},"0")),
|
|
|
|
H2({id: "fail"}, "Todo: ", SPAN({id: "todo-count"},"0"))
|
|
|
|
),
|
|
|
|
DIV({class: "clear"}),
|
|
|
|
DIV({id: "current-test"},
|
|
|
|
B("Currently Executing: ",
|
|
|
|
SPAN({id: "current-test-path"}, "_")
|
|
|
|
)
|
|
|
|
),
|
|
|
|
DIV({class: "clear"}),
|
|
|
|
DIV({class: "frameholder"},
|
2008-04-02 01:21:54 +04:00
|
|
|
IFRAME({scrolling: "no", id: "testframe", width: "500", height: "300"})
|
2007-01-26 21:44:58 +03:00
|
|
|
),
|
|
|
|
DIV({class: "clear"}),
|
|
|
|
DIV({class: "toggle"},
|
|
|
|
A({href: "#", id: "toggleNonTests"}, "Show Non-Tests"),
|
|
|
|
BR()
|
|
|
|
),
|
2007-01-31 21:25:15 +03:00
|
|
|
|
2007-01-26 21:44:58 +03:00
|
|
|
TABLE({cellpadding: 0, cellspacing: 0, id: "test-table"},
|
2007-01-31 21:25:15 +03:00
|
|
|
TR(TD("Passed"), TD("Failed"), TD("Todo"),
|
|
|
|
TD({rowspan: count+1},
|
|
|
|
UL({class: "top"},
|
|
|
|
LI(B("Test Files")),
|
|
|
|
linksToListItems(links)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
),
|
2007-01-26 21:44:58 +03:00
|
|
|
linksToTableRows(links)
|
|
|
|
),
|
2007-01-29 08:45:52 +03:00
|
|
|
DIV({class: "clear"})
|
2007-01-26 21:44:58 +03:00
|
|
|
)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Respond to requests that match a file system directory.
|
|
|
|
* Under the tests/ directory, return a test harness page.
|
|
|
|
*/
|
|
|
|
function defaultDirHandler(metadata, response)
|
|
|
|
{
|
|
|
|
response.setStatusLine("1.1", 200, "OK");
|
2008-03-18 20:42:39 +03:00
|
|
|
response.setHeader("Content-type", "text/html", false);
|
2007-01-26 21:44:58 +03:00
|
|
|
try {
|
|
|
|
if (metadata.path.indexOf("/tests") != 0) {
|
|
|
|
regularListing(metadata, response);
|
|
|
|
} else {
|
|
|
|
testListing(metadata, response);
|
|
|
|
}
|
|
|
|
} catch (ex) {
|
|
|
|
response.write(ex);
|
|
|
|
}
|
|
|
|
}
|