/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** 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 mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Bob Clary
'); writer.writeln('# Created ' + new Date()); for (suiteName in suites) { writer.writeln('# ' + suiteName + ': ' + elements['SUMMARY_' + suiteName].value); } writer.writeln('# TOTAL: ' + elements['TOTAL'].value); for (suiteName in suites) { var testDirs = suites[suiteName].testDirs; for (var testDirName in testDirs) { var tests = testDirs[testDirName].tests; for (var testName in tests) { var radioName = tests[testName].id; var radio = elements[radioName]; if (radio.checked) writer.writeln(suiteName + '/' + testDirName + '/' + radio.value); } } } writer.writeln('<\/pre>'); writer.close(); } var gTests; var gTestNumber; var gWindow; function executeList() { var elements = document.forms['testCases'].elements; gTests = []; gTestNumber = -1; for (var suiteName in suites) { var testDirs = suites[suiteName].testDirs; for (var testDirName in testDirs) { var tests = testDirs[testDirName].tests; for (var testName in tests) { var test = tests[testName]; var radioName = test.id; var radio = elements[radioName]; delete test.testCases; if (radio.checked) { gTests[gTests.length] = test; test.path = suiteName + '/' + testDirName + '/' + radio.value; } } } } runNextTest(); } function runNextTest() { var iTestCase; if (gTestNumber != -1) { // tests have already run in gWindow, collect the results // for later reporting. var e; try { var test = gTests[gTestNumber]; test.testCases = []; //test.testCases = test.testCases.concat(gWindow.gTestcases); // note MSIE6 has a bug where instead of concating the new arrays // it concats them to the first element. work around... var origtestcases = gWindow.gTestcases; for (iTestCase = 0; iTestCase < origtestcases.length; iTestCase++) { // test.testCases[test.testCases.length] = origtestcases[iTestCase]; var origtestcase = origtestcases[iTestCase]; var testCase = test.testCases[test.testCases.length] = {}; testCase.name = new String(origtestcase.name); testCase.description = new String(origtestcase.description); testCase.expect = new String(origtestcase.expect); testCase.actual = new String(origtestcase.actual); testCase.passed = origtestcase.passed ? true : false; testCase.reason = new String(origtestcase.reason); testCase.bugnumber = new String(origtestcase.bugnumber?origtestcase.bugnumber:''); } origtestcases = origtestcase = null; } catch(e) { ; } } ++gTestNumber; if (gTestNumber < gTests.length) { // run test test = gTests[gTestNumber]; gWindow = window.open('js-test-driver-' + document.forms.testCases.doctype.value + '.html?test=' + test.path + ';language=' + document.forms.testCases.language.value, 'output'); if (!gWindow) { alert('This test suite requires popup windows.\n' + 'Please enable them for this site.'); } } else if (document.forms.testCases.outputformat.value == 'html') { // all tests completed, display report reportHTML(); } else if (document.forms.testCases.outputformat.value == 'javascript') { // all tests completed, display report reportJavaScript(); } } function reportHTML() { var errorsOnly = document.forms.testCases.failures.checked; var totalTestCases = 0; var totalTestCasesPassed = 0; var totalTestCasesFailed = 0; gWindow.document.close(); var writer = new CachedWriter(gWindow.document); writer.writeln(''); writer.writeln(''); writer.writeln(''); writer.writeln('JavaScript Tests Browser: ' + navigator.userAgent + ' Language: ' + document.forms.testCases.language.value + '<\/title>'); writer.writeln('