2 * The contents of this file are subject to the Netscape Public
3 * License Version 1.1 (the "License"); you may not use this file
4 * except in compliance with the License. You may obtain a copy of
5 * the License at http://www.mozilla.org/NPL/
7 * Software distributed under the License is distributed on an "AS
8 * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
9 * implied. See the License for the specific language governing
10 * rights and limitations under the License.
12 * The Original Code is mozilla.org code.
14 * The Initial Developer of the Original Code is Netscape
15 * Communications Corporation. Portions created by Netscape are
16 * Copyright (C) 1998 Netscape Communications Corporation. All
23 * JavaScript test library shared functions file for running the tests
24 * in the browser. Overrides the shell's print function with document.write
25 * and make everything HTML pretty.
27 * To run the tests in the browser, use the mkhtml.pl script to generate
28 * html pages that include the shell.js, browser.js (this file), and the
29 * test js file in script tags.
31 * The source of the page that is generated should look something like this:
32 * <script src="./../shell.js"></script>
33 * <script src="./../browser.js"></script>
34 * <script src="./mytest.js"></script>
39 var GLOBAL = "[object Window]";
41 function startTest() {
42 writeHeaderToLog( SECTION + " "+ TITLE);
44 writeLineToLog ("BUGNUMBER: " + BUGNUMBER );
47 testcases = new Array();
51 function writeLineToLog( string ) {
52 document.write( string + "<br>\n");
54 function writeHeaderToLog( string ) {
55 document.write( "<h2>" + string + "</h2>" );
59 if ( gc != undefined ) {
62 document.write( "<hr>" );
64 function writeFormattedResult( expect, actual, string, passed ) {
65 var s = "<tt>"+ string ;
67 s += ( passed ) ? "<font color=#009900> " + PASSED
68 : "<font color=#aa0000> " + FAILED + expect + "</tt>";
69 writeLineToLog( s + "</font></b></tt>" );
72 function err( msg, page, line ) {
73 writeLineToLog( "Test failed on line " + line + " with the message: " + msg );
75 testcases[tc].actual = "error";
76 testcases[tc].reason = msg;
77 writeTestCaseResult( testcases[tc].expect,
79 testcases[tc].description +" = "+ testcases[tc].actual +
80 ": " + testcases[tc].reason );