B2G/gecko/testing/mochitest/server.js
/**
 * Produce a test harness page containing all the test cases
 * below it, recursively.
 */
Produce a test harness page containing all the test cases
below it, recursively.
Produce a test harness page containing all the test cases below it recursively .
function testListing(metadata, response)
{
  var [links, count] = list(metadata.path,
                            metadata.getProperty("directory"),
                            true);
  var table_class = metadata.queryString.indexOf("hideResultsTable=1") > -1 ? "invisible": "";
  dumpn("count: " + count);
  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: "/tests/SimpleTest/LogController.js"}),
        SCRIPT({type: "text/javascript",
                 src: "/tests/SimpleTest/TestRunner.js"}),
        SCRIPT({type: "text/javascript",
                 src: "/tests/SimpleTest/MozillaLogger.js"}),
        SCRIPT({type: "text/javascript",
                 src: "/tests/SimpleTest/setup.js"}),
        SCRIPT({type: "text/javascript"},
               "window.onload =  hookup; gTestList=" + tests + ";"
        )
      ),
      BODY(
        DIV({class: "container"},
          H2("--> ", A({href: "#", id: "runtests"}, "Run Tests"), " <--"),
            P({style: "float: right;"},
            SMALL(
              "Based on the ",
              A({href:"http://www.mochikit.com/"}, "MochiKit"),
              " unit tests."
            )
          ),
          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"},
            IFRAME({scrolling: "no", id: "testframe", width: "500", height: "300"})
          ),
          DIV({class: "clear"}),
          DIV({class: "toggle"},
            A({href: "#", id: "toggleNonTests"}, "Show Non-Tests"),
            BR()
          ),
          (
           displayResults ?
            TABLE({cellpadding: 0, cellspacing: 0, class: table_class, id: "test-table"},
              TR(TD("Passed"), TD("Failed"), TD("Todo"), TD("Test Files")),
              linksToTableRows(links, 0)
            ) : ""
          ),
          BR(),
          TABLE({cellpadding: 0, cellspacing: 0, border: 1, bordercolor: "red", id: "fail-table"}
          ),
          DIV({class: "clear"})
        )
      )
    )
  );
}
function testListing ( metadata , response ) { var [ links , count ] = list ( metadata . path , metadata . getProperty ( "directory" ) , true ) ; var table_class = metadata . queryString . indexOf ( "hideResultsTable=1" ) > - 1 ? "invisible" : "" ; dumpn ( "count: " + count ) ; 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 : "/tests/SimpleTest/LogController.js" } ) , SCRIPT ( { type : "text/javascript" , src : "/tests/SimpleTest/TestRunner.js" } ) , SCRIPT ( { type : "text/javascript" , src : "/tests/SimpleTest/MozillaLogger.js" } ) , SCRIPT ( { type : "text/javascript" , src : "/tests/SimpleTest/setup.js" } ) , SCRIPT ( { type : "text/javascript" } , "window.onload =  hookup; gTestList=" + tests + ";" ) ) , BODY ( DIV ( { class : "container" } , H2 ( "--> " , A ( { href : "#" , id : "runtests" } , "Run Tests" ) , " <--" ) , P ( { style : "float: right;" } , SMALL ( "Based on the " , A ( { href : "http://www.mochikit.com/" } , "MochiKit" ) , " unit tests." ) ) , 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" } , IFRAME ( { scrolling : "no" , id : "testframe" , width : "500" , height : "300" } ) ) , DIV ( { class : "clear" } ) , DIV ( { class : "toggle" } , A ( { href : "#" , id : "toggleNonTests" } , "Show Non-Tests" ) , BR ( ) ) , ( displayResults ? TABLE ( { cellpadding : 0 , cellspacing : 0 , class : table_class , id : "test-table" } , TR ( TD ( "Passed" ) , TD ( "Failed" ) , TD ( "Todo" ) , TD ( "Test Files" ) ) , linksToTableRows ( links , 0 ) ) : "" ) , BR ( ) , TABLE ( { cellpadding : 0 , cellspacing : 0 , border : 1 , bordercolor : "red" , id : "fail-table" } ) , DIV ( { class : "clear" } ) ) ) ) ) ; }
Produce a test harness page containing all the test cases
 below it, recursively.
Produce a test harness page containing all the test cases below it recursively .