Permalink
Browse files

fixed test directory

git-svn-id: file:///Users/jyurek/Backups/repositories/jocha/trunk@6 5317845c-832e-0410-b2c0-db6c5bc7c761
  • Loading branch information...
1 parent 677f5c2 commit fd7598d908e02e261914dfc80500036fb42f5f58 tfwright committed Apr 20, 2007
View
120 test/jsunit/app/css/jsUnitStyle.css
@@ -0,0 +1,120 @@
+/* jsUnit */
+
+/* ***** 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 Edward Hieatt code.
+
+ *
+
+ * The Initial Developer of the Original Code is
+
+ * Edward Hieatt, edward@jsunit.net.
+
+ * Portions created by the Initial Developer are Copyright (C) 2001
+
+ * the Initial Developer. All Rights Reserved.
+
+ *
+
+ * Contributor(s):
+
+ * Edward Hieatt, edward@jsunit.net (original author)
+
+ * Bob Clary, bc@bclary.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 ***** */
+
+
+
+body
+
+{
+
+ margin-top: 0;
+
+ margin-bottom: 0;
+
+ font-family: Verdana, Arial, Helvetica, sans-serif;
+
+ color: #000;
+
+ font-size: 0.8em;
+
+ background-color: #fff;
+
+}
+
+
+
+td
+
+{
+
+ padding: 0;
+
+ margin: 0;
+
+}
+
+
+
+td img
+
+{
+
+ padding: 0;
+
+ margin: 0;
+
+ vertical-align: baseline;
+
View
10 test/jsunit/app/css/readme
@@ -0,0 +1,10 @@
+this file is required due to differences in behavior between Mozilla/Opera
+and Internet Explorer.
+
+main-data.html calls kickOffTests() which calls top.testManager.start()
+in the top most frame. top.testManager.start() initializes the output
+frames using document.write and HTML containing a relative <link> to the
+jsUnitStyle.css file. In MSIE, the base href used to find the CSS file is
+that of the top level frame however in Mozilla/Opera the base href is
+that of main-data.html. This leads to not-found for the jsUnitStyle.css
+in Mozilla/Opera. Creating app/css/jsUnitStyle.css works around this problem.
View
13 test/jsunit/app/emptyPage.html
@@ -0,0 +1,13 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
+ "http://www.w3.org/TR/html4/loose.dtd">
+<html>
+<!-- @author Edward Hieatt, edward@jsunit.net -->
+ <head>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+ <title>emptyPage</title>
+ </head>
+
+ <body>
+ </body>
+</html>
+
View
383 test/jsunit/app/jsUnitCore.js
@@ -0,0 +1,383 @@
+/* @author Edward Hieatt, edward@jsunit.net */
+
+var JSUNIT_UNDEFINED_VALUE;
+var JSUNIT_VERSION="2.1";
+var isTestPageLoaded = false;
+
+//hack for NS62 bug
+function jsUnitFixTop() {
+ var tempTop = top;
+ if (!tempTop) {
+ tempTop = window;
+ while (tempTop.parent) {
+ tempTop = tempTop.parent;
+ if (tempTop.top && tempTop.top.jsUnitTestSuite) {
+ tempTop = tempTop.top;
+ break;
+ }
+ }
+ }
+ try {
+ window.top = tempTop;
+ } catch (e) {}
+}
+
+jsUnitFixTop();
+
+function _displayStringForValue(aVar) {
+ if (aVar === null)
+ return 'null';
+
+ if (aVar === top.JSUNIT_UNDEFINED_VALUE)
+ return 'undefined';
+
+ return aVar;
+}
+
+function fail(failureMessage) {
+ throw new JsUnitException(null, failureMessage);
+}
+
+function error(errorMessage) {
+ var errorObject = new Object();
+ errorObject.description = errorMessage;
+ errorObject.stackTrace = getStackTrace();
+ throw errorObject;
+}
+
+function argumentsIncludeComments(expectedNumberOfNonCommentArgs, args) {
+ return args.length == expectedNumberOfNonCommentArgs + 1;
+}
+
+function commentArg(expectedNumberOfNonCommentArgs, args) {
+ if (argumentsIncludeComments(expectedNumberOfNonCommentArgs, args))
+ return args[0];
+
+ return null;
+}
+
+function nonCommentArg(desiredNonCommentArgIndex, expectedNumberOfNonCommentArgs, args) {
+ return argumentsIncludeComments(expectedNumberOfNonCommentArgs, args) ?
+ args[desiredNonCommentArgIndex] :
+ args[desiredNonCommentArgIndex - 1];
+}
+
+function _validateArguments(expectedNumberOfNonCommentArgs, args) {
+ if (!( args.length == expectedNumberOfNonCommentArgs ||
+ (args.length == expectedNumberOfNonCommentArgs + 1 && typeof(args[0]) == 'string') ))
+ error('Incorrect arguments passed to assert function');
+}
+
+function _assert(comment, booleanValue, failureMessage) {
+ if (!booleanValue)
+ throw new JsUnitException(comment, failureMessage);
+}
+
+function assert() {
+ _validateArguments(1, arguments);
+ var booleanValue=nonCommentArg(1, 1, arguments);
+
+ if (typeof(booleanValue) != 'boolean')
+ error('Bad argument to assert(boolean)');
+
+ _assert(commentArg(1, arguments), booleanValue === true, 'Call to assert(boolean) with false');
+}
+
+function assertTrue() {
+ _validateArguments(1, arguments);
+ var booleanValue=nonCommentArg(1, 1, arguments);
+
+ if (typeof(booleanValue) != 'boolean')
+ error('Bad argument to assertTrue(boolean)');
+
+ _assert(commentArg(1, arguments), booleanValue === true, 'Call to assertTrue(boolean) with false');
+}
+
+function assertFalse() {
+ _validateArguments(1, arguments);
+ var booleanValue=nonCommentArg(1, 1, arguments);
+
+ if (typeof(booleanValue) != 'boolean')
+ error('Bad argument to assertFalse(boolean)');
+
+ _assert(commentArg(1, arguments), booleanValue === false, 'Call to assertFalse(boolean) with true');
+}
+
+function assertEquals() {
+ _validateArguments(2, arguments);
+ var var1=nonCommentArg(1, 2, arguments);
+ var var2=nonCommentArg(2, 2, arguments);
+ _assert(commentArg(2, arguments), var1 === var2, 'Expected ' + var1 + ' (' + typeof(var1) + ') but was ' + _displayStringForValue(var2) + ' (' + typeof(var2) + ')');
+}
+
+function assertNotEquals() {
+ _validateArguments(2, arguments);
+ var var1=nonCommentArg(1, 2, arguments);
+ var var2=nonCommentArg(2, 2, arguments);
+ _assert(commentArg(2, arguments), var1 !== var2, 'Expected not to be ' + _displayStringForValue(var2));
+}
+
+function assertNull() {
+ _validateArguments(1, arguments);
+ var aVar=nonCommentArg(1, 1, arguments);
+ _assert(commentArg(1, arguments), aVar === null, 'Expected null but was ' + _displayStringForValue(aVar));
+}
+
+function assertNotNull() {
+ _validateArguments(1, arguments);
+ var aVar=nonCommentArg(1, 1, arguments);
+ _assert(commentArg(1, arguments), aVar !== null, 'Expected not to be null');
+}
+
+function assertUndefined() {
+ _validateArguments(1, arguments);
+ var aVar=nonCommentArg(1, 1, arguments);
+ _assert(commentArg(1, arguments), aVar === top.JSUNIT_UNDEFINED_VALUE, 'Expected undefined but was ' + _displayStringForValue(aVar));
+}
+
+function assertNotUndefined() {
+ _validateArguments(1, arguments);
+ var aVar=nonCommentArg(1, 1, arguments);
+ _assert(commentArg(1, arguments), aVar !== top.JSUNIT_UNDEFINED_VALUE, 'Expected not to be undefined');
+}
+
+function assertNaN() {
+ _validateArguments(1, arguments);
+ var aVar=nonCommentArg(1, 1, arguments);
+ _assert(commentArg(1, arguments), isNaN(aVar), 'Expected NaN');
+}
+
+function assertNotNaN() {
+ _validateArguments(1, arguments);
+ var aVar=nonCommentArg(1, 1, arguments);
+ _assert(commentArg(1, arguments), !isNaN(aVar), 'Expected not NaN');
+}
+
+function isLoaded() {
+ return isTestPageLoaded;
+}
+
+function setUp() {
+}
+
+function tearDown() {
+}
+
+function getFunctionName(aFunction) {
+ var name = aFunction.toString().match(/function (\w*)/)[1];
+
+ if ((name == null) || (name.length == 0))
+ name = 'anonymous';
+
+ return name;
+}
+
+function getStackTrace() {
+ var result = '';
+
+ if (typeof(arguments.caller) != 'undefined') { // IE, not ECMA
+ for (var a = arguments.caller; a != null; a = a.caller) {
+ result += '> ' + getFunctionName(a.callee) + '\n';
+ if (a.caller == a) {
+ result += '*';
+ break;
+ }
+ }
+ }
+ else { // Mozilla, not ECMA
+ // fake an exception so we can get Mozilla's error stack
+ var testExcp;
+ try
+ {
+ foo.bar;
+ }
+ catch(testExcp)
+ {
+ var stack = parseErrorStack(testExcp);
+ for (var i = 1; i < stack.length; i++)
+ {
+ result += '> ' + stack[i] + '\n';
+ }
+ }
+ }
+
+ return result;
+}
+
+function parseErrorStack(excp)
+{
+ var stack = [];
+ var name;
+
+ if (!excp || !excp.stack)
+ {
+ return stack;
+ }
+
+ var stacklist = excp.stack.split('\n');
+
+ for (var i = 0; i < stacklist.length - 1; i++)
+ {
+ var framedata = stacklist[i];
+
+ name = framedata.match(/^(\w*)/)[1];
+ if (!name) {
+ name = 'anonymous';
+ }
+
+ stack[stack.length] = name;
+ }
+ // remove top level anonymous functions to match IE
+
+ while (stack.length && stack[stack.length - 1] == 'anonymous')
+ {
+ stack.length = stack.length - 1;
+ }
+ return stack;
+}
+
+function JsUnitException(comment, message) {
+ this.isJsUnitException = true;
+ this.comment = comment;
+ this.jsUnitMessage = message;
+ this.stackTrace = getStackTrace();
+}
+
+function warn() {
+ if (top.tracer != null)
+ top.tracer.warn(arguments[0], arguments[1]);
+}
+
+function inform() {
+ if (top.tracer != null)
+ top.tracer.inform(arguments[0], arguments[1]);
+}
+
+function info() {
+ inform(arguments[0], arguments[1]);
+}
+
+function debug() {
+ if (top.tracer != null)
+ top.tracer.debug(arguments[0], arguments[1]);
+}
+
+function setjsUnitTracer(ajsUnitTracer) {
+ top.tracer=ajsUnitTracer;
+}
+
+function trim(str) {
+ if (str == null)
+ return null;
+
+ var startingIndex = 0;
+ var endingIndex = str.length-1;
+
+ while (str.substring(startingIndex, startingIndex+1) == ' ')
+ startingIndex++;
+
+ while (str.substring(endingIndex, endingIndex+1) == ' ')
+ endingIndex--;
+
+ if (endingIndex < startingIndex)
+ return '';
+
+ return str.substring(startingIndex, endingIndex+1);
+}
+
+function isBlank(str) {
+ return trim(str) == '';
+}
+
+// the functions push(anArray, anObject) and pop(anArray)
+// exist because the JavaScript Array.push(anObject) and Array.pop()
+// functions are not available in IE 5.0
+
+function push(anArray, anObject) {
+ anArray[anArray.length]=anObject;
+}
+function pop(anArray) {
+ if (anArray.length>=1) {
+ delete anArray[anArray.length - 1];
+ anArray.length--;
+ }
+}
+
+// safe, strict access to jsUnitParmHash
+function jsUnitGetParm(name)
+{
+ if (typeof(top.jsUnitParmHash[name]) != 'undefined')
+ {
+ return top.jsUnitParmHash[name];
+ }
+ return null;
+}
+
+if (top && typeof(top.xbDEBUG) != 'undefined' && top.xbDEBUG.on && top.testManager)
+{
+ top.xbDebugTraceObject('top.testManager.containerTestFrame', 'JSUnitException');
+ // asserts
+ top.xbDebugTraceFunction('top.testManager.containerTestFrame', '_displayStringForValue');
+ top.xbDebugTraceFunction('top.testManager.containerTestFrame', 'error');
+ top.xbDebugTraceFunction('top.testManager.containerTestFrame', 'argumentsIncludeComments');
+ top.xbDebugTraceFunction('top.testManager.containerTestFrame', 'commentArg');
+ top.xbDebugTraceFunction('top.testManager.containerTestFrame', 'nonCommentArg');
+ top.xbDebugTraceFunction('top.testManager.containerTestFrame', '_validateArguments');
+ top.xbDebugTraceFunction('top.testManager.containerTestFrame', '_assert');
+ top.xbDebugTraceFunction('top.testManager.containerTestFrame', 'assert');
+ top.xbDebugTraceFunction('top.testManager.containerTestFrame', 'assertTrue');
+ top.xbDebugTraceFunction('top.testManager.containerTestFrame', 'assertEquals');
+ top.xbDebugTraceFunction('top.testManager.containerTestFrame', 'assertNotEquals');
+ top.xbDebugTraceFunction('top.testManager.containerTestFrame', 'assertNull');
+ top.xbDebugTraceFunction('top.testManager.containerTestFrame', 'assertNotNull');
+ top.xbDebugTraceFunction('top.testManager.containerTestFrame', 'assertUndefined');
+ top.xbDebugTraceFunction('top.testManager.containerTestFrame', 'assertNotUndefined');
+ top.xbDebugTraceFunction('top.testManager.containerTestFrame', 'assertNaN');
+ top.xbDebugTraceFunction('top.testManager.containerTestFrame', 'assertNotNaN');
+ top.xbDebugTraceFunction('top.testManager.containerTestFrame', 'isLoaded');
+ top.xbDebugTraceFunction('top.testManager.containerTestFrame', 'setUp');
+ top.xbDebugTraceFunction('top.testManager.containerTestFrame', 'tearDown');
+ top.xbDebugTraceFunction('top.testManager.containerTestFrame', 'getFunctionName');
+ top.xbDebugTraceFunction('top.testManager.containerTestFrame', 'getStackTrace');
+ top.xbDebugTraceFunction('top.testManager.containerTestFrame', 'warn');
+ top.xbDebugTraceFunction('top.testManager.containerTestFrame', 'inform');
+ top.xbDebugTraceFunction('top.testManager.containerTestFrame', 'debug');
+ top.xbDebugTraceFunction('top.testManager.containerTestFrame', 'setjsUnitTracer');
+ top.xbDebugTraceFunction('top.testManager.containerTestFrame', 'trim');
+ top.xbDebugTraceFunction('top.testManager.containerTestFrame', 'isBlank');
+ top.xbDebugTraceFunction('top.testManager.containerTestFrame', 'newOnLoadEvent');
+ top.xbDebugTraceFunction('top.testManager.containerTestFrame', 'push');
+ top.xbDebugTraceFunction('top.testManager.containerTestFrame', 'pop');
+}
+
+function newOnLoadEvent() {
+ isTestPageLoaded = true;
+}
+
+function jsUnitSetOnLoad(windowRef, onloadHandler)
+{
+ var isKonqueror = navigator.userAgent.indexOf('Konqueror/') != -1 ||
+ navigator.userAgent.indexOf('Safari/') != -1;
+
+ if (typeof(windowRef.attachEvent) != 'undefined') {
+ // Internet Explorer, Opera
+ windowRef.attachEvent("onload", onloadHandler);
+ } else if (typeof(windowRef.addEventListener) != 'undefined' && !isKonqueror){
+ // Mozilla, Konqueror
+ // exclude Konqueror due to load issues
+ windowRef.addEventListener("load", onloadHandler, false);
+ } else if (typeof(windowRef.document.addEventListener) != 'undefined' && !isKonqueror) {
+ // DOM 2 Events
+ // exclude Mozilla, Konqueror due to load issues
+ windowRef.document.addEventListener("load", onloadHandler, false);
+ } else if (typeof(windowRef.onload) != 'undefined' && windowRef.onload) {
+ windowRef.jsunit_original_onload = windowRef.onload;
+ windowRef.onload = function() { windowRef.jsunit_original_onload(); onloadHandler(); };
+ } else {
+ // browsers that do not support windowRef.attachEvent or
+ // windowRef.addEventListener will override a page's own onload event
+ windowRef.onload=onloadHandler;
+ }
+}
+
+jsUnitSetOnLoad(window, newOnLoadEvent);
View
676 test/jsunit/app/jsUnitTestManager.js
@@ -0,0 +1,676 @@
+/* @author Edward Hieatt, edward@jsunit.net */
+
+function jsUnitTestManager()
+{
+ this._windowForAllProblemMessages = null;
+
+
+ this.container = top.frames.testContainer
+ this.documentLoader = top.frames.documentLoader;
+ this.mainFrame = top.frames.mainFrame;
+
+ this.containerController = this.container.frames.testContainerController;
+ this.containerTestFrame = this.container.frames.testFrame;
+
+ var mainData = this.mainFrame.frames.mainData;
+
+ // form elements on mainData frame
+ this.testFileName = mainData.document.testRunnerForm.testFileName;
+ this.runButton = mainData.document.testRunnerForm.runButton;
+ this.traceLevel = mainData.document.testRunnerForm.traceLevel;
+ this.closeTraceWindowOnNewRun = mainData.document.testRunnerForm.closeTraceWindowOnNewRun;
+ this.timeout = mainData.document.testRunnerForm.timeout;
+ this.setUpPageTimeout = mainData.document.testRunnerForm.setUpPageTimeout;
+
+ // image output
+ this.progressBar = this.mainFrame.frames.mainProgress.document.progress;
+
+ this.problemsListField = this.mainFrame.frames.mainErrors.document.testRunnerForm.problemsList;
+ this.testCaseResultsField = this.mainFrame.frames.mainResults.document.resultsForm.testCases;
+ this.resultsTimeField = this.mainFrame.frames.mainResults.document.resultsForm.time;
+
+ // 'layer' output frames
+ this.uiFrames = new Object();
+ this.uiFrames.mainStatus = this.mainFrame.frames.mainStatus;
+
+ var mainCounts = this.mainFrame.frames.mainCounts;
+
+ this.uiFrames.mainCountsErrors = mainCounts.frames.mainCountsErrors;
+ this.uiFrames.mainCountsFailures = mainCounts.frames.mainCountsFailures;
+ this.uiFrames.mainCountsRuns = mainCounts.frames.mainCountsRuns;
+ this._baseURL = "";
+
+ this.setup();
+}
+
+// seconds to wait for each test page to load
+jsUnitTestManager.TESTPAGE_WAIT_SEC = 20;
+jsUnitTestManager.TIMEOUT_LENGTH = 20;
+
+// seconds to wait for setUpPage to complete
+jsUnitTestManager.SETUPPAGE_TIMEOUT = 60;
+
+// milliseconds to wait between polls on setUpPages
+jsUnitTestManager.SETUPPAGE_INTERVAL = 100;
+
+jsUnitTestManager.prototype.setup = function ()
+{
+ this.totalCount = 0;
+ this.errorCount = 0;
+ this.failureCount = 0;
+ this._suiteStack = Array();
+
+
+ var initialSuite = new top.jsUnitTestSuite();
+ push(this._suiteStack, initialSuite);
+}
+
+jsUnitTestManager.prototype.start = function ()
+{
+ this._baseURL = this.resolveUserEnteredTestFileName();
+ var firstQuery = this._baseURL.indexOf("?");
+ if (firstQuery >= 0) {
+ this._baseURL = this._baseURL.substring(0, firstQuery);
+ }
+ var lastSlash = this._baseURL.lastIndexOf("/");
+ var lastRevSlash = this._baseURL.lastIndexOf("\\");
+ if (lastRevSlash > lastSlash) {
+ lastSlash = lastRevSlash;
+ }
+ if (lastSlash > 0) {
+ this._baseURL = this._baseURL.substring(0, lastSlash + 1);
+ }
+
+ this._timeRunStarted = new Date();
+ this.initialize();
+ setTimeout('top.testManager._nextPage();', jsUnitTestManager.TIMEOUT_LENGTH);
+}
+
+jsUnitTestManager.prototype.getBaseURL = function () {
+ return this._baseURL;
+}
+
+jsUnitTestManager.prototype.doneLoadingPage = function (pageName)
+{
+ //this.containerTestFrame.setTracer(top.tracer);
+ this._testFileName = pageName;
+ if (this.isTestPageSuite())
+ this._handleNewSuite();
+ else
+ {
+ this._testIndex = 0;
+ this._testsInPage = this.getTestFunctionNames();
+ this._numberOfTestsInPage = this._testsInPage.length;
+ this._runTest();
+ }
+}
+
+jsUnitTestManager.prototype._handleNewSuite = function ()
+{
+ var allegedSuite = this.containerTestFrame.suite();
+ if (allegedSuite.isjsUnitTestSuite) {
+ var newSuite = allegedSuite.clone();
+ if (newSuite.containsTestPages())
+ push(this._suiteStack, newSuite);
+ this._nextPage();
+ }
+ else {
+ alert('Invalid test suite in file ' + this._testFileName);
+ this.abort();
+ }
+}
+
+jsUnitTestManager.prototype._runTest = function ()
+{
+ if (this._testIndex + 1 > this._numberOfTestsInPage)
+ {
+ this._nextPage();
+ return;
+ }
+
+ if (this._testIndex == 0 && typeof(this.containerTestFrame.setUpPage) == 'function')
+ {
+ // first test for this page and a setUpPage is defined
+ if (typeof(this.containerTestFrame.setUpPageStatus) == 'undefined')
+ {
+ // setUpPage() not called yet, so call it
+ this.containerTestFrame.setUpPageStatus = false;
+ this.containerTestFrame.startTime = new Date();
+ this.containerTestFrame.setUpPage();
+ // try test again later
+ setTimeout('top.testManager._runTest()', jsUnitTestManager.SETUPPAGE_INTERVAL);
+ return;
+ }
+
+ if (this.containerTestFrame.setUpPageStatus != 'complete')
+ {
+ // setUpPage called, but not complete yet
+ top.status = 'setUpPage not completed... ' + this.containerTestFrame.setUpPageStatus + ' ' + (new Date());
+ if ((new Date() - this.containerTestFrame.startTime) /1000 > this.getsetUpPageTimeout()) {
+ alert('setUpPage timed out without completing.');
+ if (prompt('Retry or Cancel ?', 'Retry') != 'Retry')
+ {
+ this.abort();
+ return;
+ }
+ this.containerTestFrame.startTime = (new Date());
+ }
+ // try test again later
+ setTimeout('top.testManager._runTest()', jsUnitTestManager.SETUPPAGE_INTERVAL);
+ return;
+ }
+ }
+
+ top.status = '';
+ // either not first test, or no setUpPage defined, or setUpPage completed
+ this.executeTestFunction(this._testsInPage[this._testIndex]);
+ this.totalCount++;
+ this.updateProgressIndicators();
+ this._testIndex++;
+ setTimeout('top.testManager._runTest()', jsUnitTestManager.TIMEOUT_LENGTH);
+}
+
+jsUnitTestManager.prototype._done = function ()
+{
+ var secondsSinceRunBegan=(new Date() - this._timeRunStarted)/1000;
+ this.setStatus('Done (' + secondsSinceRunBegan + ' seconds)');
+ this._cleanUp();
+ if (top.shouldSubmitResults()) {
+ this.resultsTimeField.value = secondsSinceRunBegan;
+ top.submitResults();
+ }
+}
+
+jsUnitTestManager.prototype._nextPage = function ()
+{
+ if (this._currentSuite().hasMorePages()) {
+ this.loadPage(this._currentSuite().nextPage());
+ }
+ else {
+ pop(this._suiteStack);
+ if (this._currentSuite() == null)
+ this._done();
+ else
+ this._nextPage();
+ }
+}
+
+jsUnitTestManager.prototype._currentSuite = function ()
+{
+ var suite = null;
+
+ if (this._suiteStack && this._suiteStack.length > 0)
+ suite = this._suiteStack[this._suiteStack.length-1];
+
+ return suite;
+}
+
+jsUnitTestManager.prototype.calculateProgressBarProportion = function ()
+{
+ if (this.totalCount == 0)
+ return 0;
+ var currentDivisor = 1;
+ var result = 0;
+
+ for (var i = 0; i < this._suiteStack.length; i++) {
+ var aSuite = this._suiteStack[i];
+ currentDivisor *= aSuite.testPages.length;
+ result += (aSuite.pageIndex - 1)/currentDivisor;
+ }
+ result += (this._testIndex + 1)/(this._numberOfTestsInPage * currentDivisor);
+ return result;
+}
+
+jsUnitTestManager.prototype._cleanUp = function ()
+{
+ this.containerController.setTestPage('./app/emptyPage.html');
+ this.finalize();
+ top.tracer.finalize();
+}
+
+jsUnitTestManager.prototype.abort = function ()
+{
+ this.setStatus('Aborted');
+ this._cleanUp();
+}
+
+jsUnitTestManager.prototype.getTimeout = function ()
+{
+ var result = jsUnitTestManager.TESTPAGE_WAIT_SEC;
+ try {
+ result = eval(this.timeout.value);
+ }
+ catch (e) {
+ }
+ return result;
+}
+
+jsUnitTestManager.prototype.getsetUpPageTimeout = function ()
+{
+ var result = jsUnitTestManager.SETUPPAGE_TIMEOUT;
+ try {
+ result = eval(this.setUpPageTimeout.value);
+ }
+ catch (e) {
+ }
+ return result;
+}
+
+jsUnitTestManager.prototype.isTestPageSuite = function ()
+{
+ var result = false;
+ if (typeof(this.containerTestFrame.suite) == 'function')
+ {
+ result = true;
+ }
+ return result;
+}
+
+jsUnitTestManager.prototype.getTestFunctionNames = function ()
+{
+ var testFrame = this.containerTestFrame;
+ var testFunctionNames = new Array();
+ var i;
+
+ if (testFrame && typeof(testFrame.exposeTestFunctionNames) == 'function')
+ return testFrame.exposeTestFunctionNames();
+
+ if (testFrame &&
+ testFrame.document &&
+ typeof(testFrame.document.scripts) != 'undefined') { // IE5 and up
+ var scriptsInTestFrame = testFrame.document.scripts;
+
+ for (i = 0; i < scriptsInTestFrame.length; i++) {
+ var someNames = this._extractTestFunctionNamesFromScript(scriptsInTestFrame[i]);
+ if (someNames)
+ testFunctionNames=testFunctionNames.concat(someNames);
+ }
+ }
+ else {
+ for (i in testFrame) {
+ if (i.substring(0, 4) == 'test' && typeof(testFrame[i]) == 'function')
+ push(testFunctionNames, i);
+ }
+ }
+ return testFunctionNames;
+}
+
+jsUnitTestManager.prototype._extractTestFunctionNamesFromScript = function (aScript)
+{
+ var result;
+ var remainingScriptToInspect = aScript.text;
+ var currentIndex = remainingScriptToInspect.indexOf('function test');
+ while (currentIndex != -1) {
+ if (!result)
+ result=new Array();
+
+ var fragment = remainingScriptToInspect.substring(currentIndex, remainingScriptToInspect.length);
+ result = result.concat(fragment.substring('function '.length, fragment.indexOf('(')));
+ remainingScriptToInspect=remainingScriptToInspect.substring(currentIndex+12, remainingScriptToInspect.length);
+ currentIndex=remainingScriptToInspect.indexOf('function test');
+ }
+ return result;
+}
+
+jsUnitTestManager.prototype.loadPage = function (testFileName)
+{
+ this._testFileName = testFileName;
+ this._loadAttemptStartTime = new Date();
+ this.setStatus('Opening Test Page "' + this._testFileName + '"');
+ this.containerController.setTestPage(this._testFileName);
+ this._callBackWhenPageIsLoaded();
+}
+
+jsUnitTestManager.prototype._callBackWhenPageIsLoaded = function ()
+{
+ if ((new Date() - this._loadAttemptStartTime) / 1000 > this.getTimeout()) {
+ alert('Reading Test Page ' + this._testFileName + ' timed out.\nMake sure that the file exists and is a Test Page.');
+ if (prompt('Retry or Cancel ?', 'Retry') != 'Retry')
+ {
+ this.abort();
+ return;
+ }
+ }
+ if (!this._isTestFrameLoaded()) {
+ setTimeout('top.testManager._callBackWhenPageIsLoaded();', jsUnitTestManager.TIMEOUT_LENGTH);
+ return;
+ }
+ this.doneLoadingPage(this._testFileName);
+}
+
+jsUnitTestManager.prototype._isTestFrameLoaded = function ()
+{
+ try {
+ return this.containerController.isPageLoaded();
+ }
+ catch (e) {
+ }
+ return false;
+}
+
+jsUnitTestManager.prototype.executeTestFunction = function (functionName)
+{
+ this._testFunctionName=functionName;
+ this.setStatus('Running test "' + this._testFunctionName + '"');
+ var excep=null;
+ var timeBefore = new Date();
+ try {
+ this.containerTestFrame.setUp();
+ eval('this.containerTestFrame.' + this._testFunctionName + '();');
+ }
+ catch (e1) {
+ excep = e1;
+ }
+ finally {
+ try {
+ this.containerTestFrame.tearDown();
+ }
+ catch (e2) {
+ excep = e2;
+ }
+ }
+ var timeTaken = (new Date() - timeBefore) / 1000;
+ if (excep != null)
+ this._handleTestException(excep);
+ var serializedTestCaseString = this._fullyQualifiedCurrentTestFunctionName()+"|"+timeTaken+"|";
+ if (excep==null)
+ serializedTestCaseString+="S||";
+ else {
+ if (typeof(excep.isJsUnitException) != 'undefined' && excep.isJsUnitException)
+ serializedTestCaseString+="F|";
+ else {
+ serializedTestCaseString+="E|";
+ }
+ serializedTestCaseString+=this._problemDetailMessageFor(excep);
+ }
+ var newOption = new Option(serializedTestCaseString);
+ this.testCaseResultsField[this.testCaseResultsField.length]=newOption;
+}
+
+jsUnitTestManager.prototype._fullyQualifiedCurrentTestFunctionName = function() {
+ var testURL = this.containerTestFrame.location.href;
+ var testQuery = testURL.indexOf("?");
+ if (testQuery >= 0) {
+ testURL = testURL.substring(0, testQuery);
+ }
+ if (testURL.substring(0, this._baseURL.length) == this._baseURL) {
+ testURL = testURL.substring(this._baseURL.length);
+ }
+ return testURL + ':' + this._testFunctionName;
+}
+
+
+jsUnitTestManager.prototype._handleTestException = function (excep)
+{
+ var problemMessage = this._fullyQualifiedCurrentTestFunctionName() + ' ';
+ var errOption;
+ if (typeof(excep.isJsUnitException) == 'undefined' || !excep.isJsUnitException) {
+ problemMessage += 'had an error';
+ this.errorCount++;
+ }
+ else {
+ problemMessage += 'failed';
+ this.failureCount++;
+ }
+ var listField = this.problemsListField;
+ var problemDocument = this.mainFrame.frames.mainErrors.document;
+ if (typeof(problemDocument.createElement) != 'undefined') {
+ // DOM Level 2 HTML method.
+ // this is required for Opera 7 since appending to the end of the
+ // options array does not work, and adding an Option created by new Option()
+ // and appended by listField.options.add() fails due to WRONG_DOCUMENT_ERR
+ errOption = problemDocument.createElement('option');
+ errOption.setAttribute('value', this._problemDetailMessageFor(excep));
+ errOption.appendChild(problemDocument.createTextNode(problemMessage));
+ listField.appendChild(errOption);
+ }
+ else {
+ // new Option() is DOM 0
+ errOption = new Option(problemMessage, this._problemDetailMessageFor(excep));
+ if (typeof(listField.add) != 'undefined') {
+ // DOM 2 HTML
+ listField.add( errOption , null);
+ }
+ else if (typeof(listField.options.add) != 'undefined') {
+ // DOM 0
+ listField.options.add( errOption, null);
+ }
+ else {
+ // DOM 0
+ listField.options[listField.length]= errOption;
+ }
+ }
+}
+
+jsUnitTestManager.prototype._problemDetailMessageFor = function (excep)
+{
+ var result=null;
+ if (typeof(excep.isJsUnitException) != 'undefined' && excep.isJsUnitException) {
+ result = '';
+ if (excep.comment != null)
+ result+=('"'+excep.comment+'"\n');
+
+ result += excep.jsUnitMessage;
+
+ if (excep.stackTrace)
+ result+='\n\nStack trace follows:\n'+excep.stackTrace;
+ }
+ else {
+ result = 'Error message is:\n"';
+ result +=
+ (typeof(excep.description) == 'undefined') ?
+ excep :
+ excep.description;
+ result += '"';
+ if (typeof(excep.stack) != 'undefined') // Mozilla only
+ result+='\n\nStack trace follows:\n'+excep.stack;
+ }
+ return result;
+}
+
+jsUnitTestManager.prototype._setTextOnLayer = function (layerName, str)
+{
+ var html = '';
+ html += '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">';
+ html += '<html><head><link rel="stylesheet" type="text/css" href="css/jsUnitStyle.css"><\/head>';
+ html += '<body><div>';
+ html += str;
+ html += '<\/div><\/body>';
+ html += '<\/html>';
+ this.uiFrames[layerName].document.write(html);
+ this.uiFrames[layerName].document.close();
+}
+
+jsUnitTestManager.prototype.setStatus = function (str)
+{
+ this._setTextOnLayer('mainStatus', '<b>Status:<\/b> '+str);
+}
+
+jsUnitTestManager.prototype._setErrors = function (n)
+{
+ this._setTextOnLayer('mainCountsErrors', '<b>Errors: <\/b>' + n);
+}
+
+jsUnitTestManager.prototype._setFailures = function (n)
+{
+ this._setTextOnLayer('mainCountsFailures', '<b>Failures:<\/b> ' + n);
+}
+
+jsUnitTestManager.prototype._setTotal = function (n)
+{
+ this._setTextOnLayer('mainCountsRuns', '<b>Runs:<\/b> ' + n);
+}
+
+jsUnitTestManager.prototype._setProgressBarImage = function (imgName)
+{
+ this.progressBar.src=imgName;
+}
+
+jsUnitTestManager.prototype._setProgressBarWidth = function (w)
+{
+ this.progressBar.width=w;
+}
+
+jsUnitTestManager.prototype.updateProgressIndicators = function ()
+{
+ this._setTotal(this.totalCount);
+ this._setErrors(this.errorCount);
+ this._setFailures(this.failureCount);
+ this._setProgressBarWidth(300 * this.calculateProgressBarProportion());
+
+ if (this.errorCount > 0 || this.failureCount > 0)
+ this._setProgressBarImage('../images/red.gif');
+ else
+ this._setProgressBarImage('../images/green.gif');
+}
+
+jsUnitTestManager.prototype.showMessageForSelectedProblemTest = function ()
+{
+ var problemTestIndex = this.problemsListField.selectedIndex;
+ if (problemTestIndex != -1)
+ alert(this.problemsListField[problemTestIndex].value);
+}
+
+jsUnitTestManager.prototype.showMessagesForAllProblemTests = function ()
+{
+ if (this.problemsListField.length == 0)
+ return;
+
+ try
+ {
+ if (this._windowForAllProblemMessages && !this._windowForAllProblemMessages.closed)
+ this._windowForAllProblemMessages.close();
+ }
+ catch(e)
+ {
+ }
+
+ this._windowForAllProblemMessages = window.open('','','width=600, height=350,status=no,resizable=yes,scrollbars=yes');
+ var resDoc = this._windowForAllProblemMessages.document;
+ resDoc.write('<html><head><link rel="stylesheet" href="../css/jsUnitStyle.css"><title>Tests with problems - JsUnit<\/title><head><body>');
+ resDoc.write('<p class="jsUnitSubHeading">Tests with problems (' + this.problemsListField.length + ' total) - JsUnit<\/p>');
+ resDoc.write('<p class="jsUnitSubSubHeading"><i>Running on '+navigator.userAgent+'</i></p>');
+ for (var i = 0; i < this.problemsListField.length; i++)
+ {
+ resDoc.write('<p class="jsUnitDefault">');
+ resDoc.write('<b>' + (i + 1) + '. ');
+ resDoc.write(this.problemsListField[i].text);
+ resDoc.write('<\/b><\/p><p><pre>');
+ resDoc.write(this.problemsListField[i].value);
+ resDoc.write('<\/pre><\/p>');
+ }
+
+ resDoc.write('<\/body><\/html>');
+ resDoc.close();
+}
+
+jsUnitTestManager.prototype._clearProblemsList = function ()
+{
+ var listField = this.problemsListField;
+ var initialLength=listField.options.length;
+
+ for (var i = 0; i < initialLength; i++)
+ listField.remove(0);
+}
+
+jsUnitTestManager.prototype.initialize = function ()
+{
+ this.setStatus('Initializing...');
+ this._setRunButtonEnabled(false);
+ this._clearProblemsList();
+ this.updateProgressIndicators();
+ this.setStatus('Done initializing');
+}
+
+jsUnitTestManager.prototype.finalize = function ()
+{
+ this._setRunButtonEnabled(true);
+}
+
+jsUnitTestManager.prototype._setRunButtonEnabled = function (b)
+{
+ this.runButton.disabled = !b;
+}
+
+jsUnitTestManager.prototype.getTestFileName = function ()
+{
+ var rawEnteredFileName = this.testFileName.value;
+ var result = rawEnteredFileName;
+
+ while (result.indexOf('\\') != -1)
+ result = result.replace('\\', '/');
+
+ return result;
+}
+
+jsUnitTestManager.prototype.resolveUserEnteredTestFileName = function (rawText)
+{
+ var userEnteredTestFileName = top.testManager.getTestFileName();
+
+ // only test for file:// since Opera uses a different format
+ if (userEnteredTestFileName.indexOf('http://') == 0 || userEnteredTestFileName.indexOf('https://') == 0 || userEnteredTestFileName.indexOf('file://') == 0)
+ return userEnteredTestFileName;
+
+ return getTestFileProtocol() + this.getTestFileName();
+}
+
+function getTestFileProtocol()
+{
+ return getDocumentProtocol();
+}
+
+function getDocumentProtocol()
+{
+ var protocol = top.document.location.protocol;
+
+ if (protocol == "file:")
+ return "file:///";
+
+ if (protocol == "http:")
+ return "http://";
+
+ if (protocol == 'https:')
+ return 'https://';
+
+ if (protocol == "chrome:")
+ return "chrome://";
+
+ return null;
+}
+
+function isBeingRunOverHTTP() {
+ return getDocumentProtocol()=="http://";
+}
+
+function getWebserver() {
+ if (isBeingRunOverHTTP()) {
+ var myUrl = location.href;
+ var myUrlWithProtocolStripped = myUrl.substring(myUrl.indexOf("/") + 2);
+ return myUrlWithProtocolStripped.substring(0, myUrlWithProtocolStripped.indexOf("/"));
+ }
+ return null;
+}
+
+// the functions push(anArray, anObject) and pop(anArray)
+// exist because the JavaScript Array.push(anObject) and Array.pop()
+// functions are not available in IE 5.0
+
+function push(anArray, anObject)
+{
+ anArray[anArray.length]=anObject;
+}
+
+function pop(anArray)
+{
+ if (anArray.length>=1) {
+ delete anArray[anArray.length - 1];
+ anArray.length--;
+ }
+}
+
+if (xbDEBUG.on)
+{
+ xbDebugTraceObject('window', 'jsUnitTestManager');
+ xbDebugTraceFunction('window', 'getTestFileProtocol');
+ xbDebugTraceFunction('window', 'getDocumentProtocol');
+}
View
46 test/jsunit/app/jsUnitTestSuite.js
@@ -0,0 +1,46 @@
+/* @author Edward Hieatt, edward@jsunit.net */
+
+function jsUnitTestSuite() {
+ this.isjsUnitTestSuite = true;
+ this.testPages = Array();
+ this.pageIndex = 0;
+}
+
+jsUnitTestSuite.prototype.addTestPage = function (pageName)
+{
+ this.testPages[this.testPages.length] = pageName;
+}
+
+jsUnitTestSuite.prototype.addTestSuite = function (suite)
+{
+ for (var i = 0; i < suite.testPages.length; i++)
+ this.addTestPage(suite.testPages[i]);
+}
+
+jsUnitTestSuite.prototype.containsTestPages = function ()
+{
+ return this.testPages.length > 0;
+}
+
+jsUnitTestSuite.prototype.nextPage = function ()
+{
+ return this.testPages[this.pageIndex++];
+}
+
+jsUnitTestSuite.prototype.hasMorePages = function ()
+{
+ return this.pageIndex < this.testPages.length;
+}
+
+jsUnitTestSuite.prototype.clone = function ()
+{
+ var clone = new jsUnitTestSuite();
+ clone.testPages = this.testPages;
+ return clone;
+}
+
+if (xbDEBUG.on)
+{
+ xbDebugTraceObject('window', 'jsUnitTestSuite');
+}
+
View
83 test/jsunit/app/jsUnitTracer.js
@@ -0,0 +1,83 @@
+/* @author Edward Hieatt, edward@jsunit.net */
+
+function jsUnitTracer() {
+ this._traceWindow = null;
+ this.TRACE_LEVEL_WARNING = 1;
+ this.TRACE_LEVEL_INFO = 2;
+ this.TRACE_LEVEL_DEBUG = 3;
+ this.popupWindowsBlocked = false;
+}
+
+jsUnitTracer.prototype.initialize = function ()
+{
+ if (this._traceWindow != null && top.testManager.closeTraceWindowOnNewRun.checked)
+ this._traceWindow.close();
+
+ this._traceWindow = null;
+}
+
+jsUnitTracer.prototype.finalize = function ()
+{
+ if (this._traceWindow!=null) {
+ this._traceWindow.document.write('<\/body>\n<\/html>');
+ this._traceWindow.document.close();
+ }
+}
+
+jsUnitTracer.prototype.warn = function ()
+{
+ this._trace(arguments[0], arguments[1], this.TRACE_LEVEL_WARNING);
+}
+
+jsUnitTracer.prototype.inform = function ()
+{
+ this._trace(arguments[0], arguments[1], this.TRACE_LEVEL_INFO);
+}
+
+jsUnitTracer.prototype.debug = function ()
+{
+ this._trace(arguments[0], arguments[1], this.TRACE_LEVEL_DEBUG);
+}
+
+jsUnitTracer.prototype._trace = function (message, value, traceLevel)
+{
+ if (this._getChosenTraceLevel() >= traceLevel) {
+ var traceString = message;
+ if (value)
+ traceString += ': ' + value;
+ this._writeToTraceWindow(traceString, traceLevel);
+ }
+}
+
+jsUnitTracer.prototype._getChosenTraceLevel = function ()
+{
+ return eval(top.testManager.traceLevel.value);
+}
+
+jsUnitTracer.prototype._writeToTraceWindow = function (traceString, traceLevel)
+{
+ var htmlToAppend = '<p class="jsUnitDefault">' + traceString + '<\/p>\n';
+ this._getTraceWindow().document.write(htmlToAppend);
+}
+
+jsUnitTracer.prototype._getTraceWindow = function ()
+{
+ if (this._traceWindow == null && !this.popupWindowsBlocked) {
+ this._traceWindow = window.open('','','width=600, height=350,status=no,resizable=yes,scrollbars=yes');
+ if (!this._traceWindow) {
+ this.popupWindowsBlocked = true;
+ }
+ else {
+ var resDoc = this._traceWindow.document;
+ resDoc.write('<html>\n<head>\n<link rel="stylesheet" href="css/jsUnitStyle.css">\n<title>Tracing - JsUnit<\/title>\n<head>\n<body>');
+ resDoc.write('<h2>Tracing - JsUnit<\/h2>\n');
+ }
+ }
+ return this._traceWindow;
+}
+
+if (xbDEBUG.on)
+{
+ xbDebugTraceObject('window', 'jsUnitTracer');
+}
+
View
14 test/jsunit/app/main-counts-errors.html
@@ -0,0 +1,14 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
+ "http://www.w3.org/TR/html4/loose.dtd">
+<html>
+<!-- @author Edward Hieatt, edward@jsunit.net -->
+ <head>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+ <title></title>
+ <link rel="stylesheet" type="text/css" href="../css/jsUnitStyle.css">
+ </head>
+
+ <body>
+ <div><b>Errors:</b> 0</div>
+ </body>
+</html>
View
15 test/jsunit/app/main-counts-failures.html
@@ -0,0 +1,15 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
+ "http://www.w3.org/TR/html4/loose.dtd">
+<html>
+<!-- @author Edward Hieatt, edward@jsunit.net -->
+ <head>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+ <title></title>
+ <link rel="stylesheet" type="text/css" href="../css/jsUnitStyle.css">
+ </head>
+
+ <body>
+ <div><b>Failures:</b> 0</div>
+ </body>
+</html>
+
View
15 test/jsunit/app/main-counts-runs.html
@@ -0,0 +1,15 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
+ "http://www.w3.org/TR/html4/loose.dtd">
+<html>
+<!-- @author Edward Hieatt, edward@jsunit.net -->
+ <head>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+ <title></title>
+ <link rel="stylesheet" type="text/css" href="../css/jsUnitStyle.css">
+ </head>
+
+ <body>
+ <div><b>Runs:</b> 0</div>
+ </body>
+</html>
+
View
24 test/jsunit/app/main-counts.html
@@ -0,0 +1,24 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN"
+ "http://www.w3.org/TR/html4/frameset.dtd">
+<html>
+<!-- @author Edward Hieatt, edward@jsunit.net -->
+ <head>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+ <title></title>
+ </head>
+
+ <frameset cols="200,190,*">
+ <frame name="mainCountsRuns" src="main-counts-runs.html" scrolling="no" frameborder="0">
+ <frame name="mainCountsErrors" src="main-counts-errors.html" scrolling="no" frameborder="0">
+ <frame name="mainCountsFailures" src="main-counts-failures.html" scrolling="no" frameborder="0">
+
+ <noframes>
+ <body>
+ <p>jsUnit has been modified to use frames in order to remove
+ dependencies upon a browser's implementation of document.getElementById
+ and HTMLElement.innerHTML.</p>
+ </body>
+ </noframes>
+ </frameset>
+</html>
+
View
161 test/jsunit/app/main-data.html
@@ -0,0 +1,161 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
+ "http://www.w3.org/TR/html4/loose.dtd">
+<html>
+<!-- @author Edward Hieatt, edward@jsunit.net -->
+ <head>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+ <title>JsUnit main-data.html</title>
+ <link rel="stylesheet" type="text/css" href="../css/jsUnitStyle.css">
+ <script language="JavaScript" type="text/javascript" src="jsUnitCore.js"></script>
+ <script language="JavaScript" type="text/javascript">
+
+function kickOffTests() {
+ //
+ // Check if Init was called by onload handler
+ //
+ if (typeof(top.testManager) == 'undefined') {
+ top.init();
+ }
+
+
+ if (isBlank(top.testManager.getTestFileName())) {
+ alert('Please enter a file name.');
+ return;
+ }
+
+ top.testManager.setup();
+
+ top.testManager._currentSuite().addTestPage(top.testManager.resolveUserEnteredTestFileName());
+ top.tracer.initialize();
+
+ var traceLevel = document.forms.testRunnerForm.traceLevel;
+ if (traceLevel.value != '0')
+ {
+ var traceWindow = top.tracer._getTraceWindow();
+ if (traceWindow) {
+ traceWindow.focus();
+ }
+ else {
+ alert('Tracing requires popup windows which are blocked in your browser.\n\nPlease enable popups if you wish to use tracing.');
+ }
+ }
+
+ top.testManager.start();
+}
+ </script>
+ </head>
+
+ <body onload="document.testRunnerForm.testFileName.focus()">
+ <form name="testRunnerForm" action="">
+ <table width="100%" cellpadding="0" cellspacing="0" border="0" summary="jsUnit Information" bgcolor="#DDDDDD">
+ <tr>
+ <td align="left" valign="top"><img src="../images/logo_jsunit.gif" alt="JSUnit Logo"></td>
+ <th nowrap align="left" valign="middle">
+ JsUnit <script language="javascript">document.write(JSUNIT_VERSION);</script> TestRunner<br>
+ <font size="-2"><i>Running on <script language="javascript" type="text/javascript">document.write(navigator.userAgent);</script></i></font>
+ </th>
+
+ <td nowrap align="right" valign="middle">
+ <a href="http://www.jsunit.net/" target="_blank">JsUnit Home</a><br>
+ <a href="mailto:edward@jsunit.net">edward@jsunit.net</a><br>
+ </tr>
+ </table>
+
+ <p>Enter the filename of the Test Page to be run:</p>
+
+ <table cellpadding="0" cellspacing="0" border="0" summary="Form for entering test case location">
+ <tr>
+ <td align="center" valign="middle">
+ <script language="JavaScript" type="text/javascript">
+ document.write(top.getDocumentProtocol());
+ </script>
+ </td>
+
+ <td nowrap align="center" valign="bottom">
+ &nbsp;
+ <script language="JavaScript" type="text/javascript">
+ if (top.getDocumentProtocol() == 'file:///' && !jsUnitGetParm('testpage'))
+ {
+ document.write('<input type="file" name="testFileName" size="60">');
+ }
+ else
+ {
+ var inputStr = '<input type="text" name="testFileName" size="60" ';
+ if (jsUnitGetParm('testpage'))
+ {
+ inputStr += 'value="';
+ if (
+ (top.getDocumentProtocol() == 'http://' || top.getDocumentProtocol() == 'https://') &&
+ jsUnitGetParm('testpage').indexOf('/') == 0)
+ {
+ inputStr += top.location.host;
+ }
+ inputStr += jsUnitGetParm('testpage');
+ var testParms = top.jsUnitConstructTestParms();
+ if (testParms!='') {
+ inputStr += '?';
+ inputStr += testParms;
+ }
+ inputStr += '"';
+ }
+ inputStr += '>';
+ document.write(inputStr);
+ }
+
+ </script>
+ <input type="button" name="runButton" value="Run" onclick="kickOffTests()">
+ </td>
+ </tr>
+ </table>
+ <hr>
+
+ <table cellpadding="0" cellspacing="0" border="0" summary="Choose Trace Level">
+ <tr>
+ <td nowrap>Trace level:</td>
+
+ <td><select name="traceLevel">
+ <option value="0" selected>
+ no tracing
+ </option>
+
+ <option value="1">
+ warning (lowest)
+ </option>
+
+ <option value="2">
+ info
+ </option>
+
+ <option value="3">
+ debug (highest)
+ </option>
+ </select> </td>
+
+ <td>&nbsp;&nbsp;&nbsp;</td>
+
+ <td><input type="checkbox" name="closeTraceWindowOnNewRun" checked></td>
+ <td nowrap>Close old trace window on new run</td>
+
+ <td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>
+
+ <td nowrap>Page load timeout:</td>
+ <td>&nbsp;
+ <script language="javascript" type="text/javascript">
+ document.write('<input type="text" size="2" name="timeout" value="'+top.jsUnitTestManager.TESTPAGE_WAIT_SEC+'">');
+ </script>
+ </td>
+
+ <td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>
+
+ <td nowrap>Setup page timeout:</td>
+ <td>&nbsp;
+ <script language="javascript" type="text/javascript">
+ document.write('<input type="text" size="2" name="setUpPageTimeout" value="'+top.jsUnitTestManager.SETUPPAGE_TIMEOUT+'">');
+ </script>
+ </td>
+ </tr>
+ </table>
+ <hr>
+ </form>
+ </body>
+</html>
View
24 test/jsunit/app/main-errors.html
@@ -0,0 +1,24 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
+ "http://www.w3.org/TR/html4/loose.dtd">
+<html>
+<!-- @author Edward Hieatt, edward@jsunit.net -->
+ <head>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+ <title>JsUnit main-errors.html</title>
+ <link rel="stylesheet" type="text/css" href="../css/jsUnitStyle.css">
+ </head>
+ <body>
+ <hr>
+ <form name="testRunnerForm" action="javascript:top.testManager.showMessageForSelectedProblemTest()">
+ <p>Errors and failures:&nbsp;</p>
+ <select size="5" ondblclick="top.testManager.showMessageForSelectedProblemTest()" name="problemsList">
+ <option>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</option>
+ </select>
+ <br>
+ <input type="button" value="Show selected" onclick="top.testManager.showMessageForSelectedProblemTest()">
+ &nbsp;&nbsp;&nbsp;
+ <input type="button" value="Show all" onclick="top.testManager.showMessagesForAllProblemTests()">
+ </form>
+ </body>
+</html>
+
View
22 test/jsunit/app/main-frame.html
@@ -0,0 +1,22 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN"
+ "http://www.w3.org/TR/html4/frameset.dtd">
+<html>
+<!-- @author Edward Hieatt, edward@jsunit.net -->
+ <head>
+ <title>jsUnit Main Frame</title>
+ </head>
+ <frameset rows="200,30,30,30,0,*">
+ <frame name="mainData" src="main-data.html" scrolling="no" frameborder="0">
+ <frame name="mainStatus" src="main-status.html" scrolling="no" frameborder="0">
+ <frame name="mainProgress" src="main-progress.html" scrolling="no" frameborder="0">
+ <frame name="mainCounts" src="main-counts.html" scrolling="no" frameborder="0">
+ <frame name="mainResults" src="main-results.html" scrolling="no" frameborder="0">
+ <frame name="mainErrors" src="main-errors.html" scrolling="no" frameborder="0">
+ <noframes>
+ <body>
+ <p>Sorry, JsUnit requires frames.</p>
+ </body>
+ </noframes>
+ </frameset>
+</html>
+
View
50 test/jsunit/app/main-loader.html
@@ -0,0 +1,50 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
+ "http://www.w3.org/TR/html4/loose.dtd">
+<html>
+<!-- @author Edward Hieatt, edward@jsunit.net -->
+ <head>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+ <title>jsUnit External Data Document loader</title>
+<script language="JavaScript" type="text/javascript">
+
+ var loadStatus;
+ var callback = function () {};
+
+ function buffer()
+ {
+ return window.frames.documentBuffer;
+ }
+
+ function load(uri)
+ {
+ loadStatus = 'loading';
+ buffer().document.location.href = uri;
+ }
+
+ function loadComplete()
+ {
+ top.xbDEBUG.dump('main-loader.html:loadComplete(): loadStatus = ' + loadStatus + ' href=' + buffer().document.location.href);
+ if (loadStatus == 'loading')
+ {
+ loadStatus = 'complete';
+ callback();
+ callback = function () {};
+ }
+ }
+
+ if (top.xbDEBUG.on)
+ {
+ var scopeName = 'main_loader_' + (new Date()).getTime();
+ top[scopeName] = window;
+ top.xbDebugTraceFunction(scopeName, 'buffer');
+ top.xbDebugTraceFunction(scopeName, 'load');
+ top.xbDebugTraceFunction(scopeName, 'loadComplete');
+ }
+
+</script>
+</head>
+<body>
+<iframe name="documentBuffer" onload="loadComplete()"></iframe>
+</body>
+</html>
+
View
26 test/jsunit/app/main-progress.html
@@ -0,0 +1,26 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
+ "http://www.w3.org/TR/html4/loose.dtd">
+<html>
+<!-- @author Edward Hieatt, edward@jsunit.net -->
+ <head>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+ <title>JsUnit main-progress.html</title>
+ <link rel="stylesheet" type="text/css" href="../css/jsUnitStyle.css">
+ </head>
+ <body>
+ <table width="375" cellpadding="0" cellspacing="0" border="0" summary="Test progress indicator">
+ <tr>
+ <td width="65" valign="top"><b>Progress:</b></td>
+
+ <td width="300" height="14" valign="middle">
+ <table width="300" cellpadding="0" cellspacing="0" border="1" summary="Progress image">
+ <tr>
+ <td width="300" height="14" valign="top"><img name="progress" height="14" width="0" alt="progress image" src="../images/green.gif"></td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+ </table>
+ </body>
+</html>
+
View
52 test/jsunit/app/main-results.html
@@ -0,0 +1,52 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
+ "http://www.w3.org/TR/html4/loose.dtd">
+<html>
+<!-- @author Edward Hieatt, edward@jsunit.net -->
+ <head>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+ <title>JsUnit main-results.html</title>
+ <link rel="stylesheet" type="text/css" href="../css/jsUnitStyle.css">
+ </head>
+ <body>
+ <script language="javascript" type="text/javascript">
+ var url="http://";
+ if (top.wasResultUrlSpecified()) {
+ url += top.getSpecifiedResultUrl();
+ } else {
+ var webserver=top.getWebserver();
+ if (webserver==null)
+ webserver="localhost";
+ url+=webserver;
+ if (webserver.indexOf(":")==-1)
+ url+=":8080";
+ url+="/jsunit/acceptor";
+ }
+ var formString = "<form name=\"resultsForm\" action=\""+url+"\" method=\"post\" target=\"_top\">";
+ document.write(formString);
+ </script>
+ <input type="hidden" name="id">
+ <input type="hidden" name="userAgent">
+ <input type="hidden" name="JsUnitVersion">
+ <input type="hidden" name="time">
+ <input type="hidden" name="baseURL">
+ <select size="5" name="testCases" multiple></select>
+ </form>
+ <script language="javascript" type="text/javascript">
+ function populateHeaderFields(id, userAgent, jsUnitVersion, baseURL) {
+ document.resultsForm.id.value=id;
+ document.resultsForm.userAgent.value=userAgent;
+ document.resultsForm.JsUnitVersion.value=jsUnitVersion;
+ document.resultsForm.baseURL.value = baseURL;
+ }
+ function submitResults() {
+ var testCasesField = document.resultsForm.testCases;
+ for (var i=0; i<testCasesField.length; i++) {
+ testCasesField[i].selected=true;
+ }
+ document.resultsForm.submit();
+
+ }
+ </script>
+ </body>
+</html>
+
View
14 test/jsunit/app/main-status.html
@@ -0,0 +1,14 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
+ "http://www.w3.org/TR/html4/loose.dtd">
+<html>
+<!-- @author Edward Hieatt, edward@jsunit.net -->
+ <head>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+ <title>JsUnit main-status.html</title>
+ <link rel="stylesheet" type="text/css" href="../css/jsUnitStyle.css">
+ </head>
+ <body>
+ <div><b>Status:</b> (Idle)</div>
+ </body>
+</html>
+
View
18 test/jsunit/app/testContainer.html
@@ -0,0 +1,18 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN"
+ "http://www.w3.org/TR/html4/frameset.dtd">
+<html>
+<!-- @author Edward Hieatt, edward@jsunit.net -->
+ <head>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+ <title>JsUnit Test Container</title>
+ </head>
+ <frameset rows="0, *">
+ <frame name="testContainerController" src="testContainerController.html">
+ <frame name="testFrame" src="emptyPage.html">
+ <noframes>
+ <body>
+ <p>Sorry, JsUnit requires frames.</p>
+ </body>
+ </noframes>
+ </frameset>
+</html>
View
74 test/jsunit/app/testContainerController.html
@@ -0,0 +1,74 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
+ "http://www.w3.org/TR/html4/loose.dtd">
+<html>
+<!-- @author Edward Hieatt, edward@jsunit.net -->
+ <head>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+ <title>JsUnit Test Container Controller</title>
+<script language="javascript" type="text/javascript">
+var containerReady=false;
+
+function init()
+{
+ containerReady = true;
+}
+
+function isPageLoaded()
+{
+ if (!containerReady)
+ return false;
+
+ var isTestPageLoaded=false;
+
+ try
+ {
+ // attempt to access the var isTestPageLoaded in the testFrame
+ if (typeof(top.testManager.containerTestFrame.isTestPageLoaded) != 'undefined')
+ {
+ isTestPageLoaded=top.testManager.containerTestFrame.isTestPageLoaded;
+ }
+
+ // ok, if the above did not throw an exception, then the
+ // variable is defined. If the onload has not fired in the
+ // testFrame then isTestPageLoaded is still false. Otherwise
+ // the testFrame has set it to true
+ }
+ catch (e)
+ {
+ // an error occured while attempting to access the isTestPageLoaded
+ // in the testFrame, therefore the testFrame has not loaded yet
+ isTestPageLoaded=false;
+ }
+ return isTestPageLoaded;
+}
+
+function isContainerReady()
+{
+ return containerReady;
+}
+
+function setNotReady()
+{
+ try
+ {
+ // attempt to set the isTestPageLoaded variable
+ // in the test frame to false.
+ top.testManager.containerTestFrame.isTestPageLoaded=false;
+ }
+ catch (e)
+ {
+ // testFrame.isTestPageLoaded not available... ignore
+ }
+}
+function setTestPage(fileName) {
+ setNotReady();
+ top.jsUnitParseParms(fileName);
+ top.testManager.containerTestFrame.location.href=fileName;
+}
+</script>
+ </head>
+
+ <body onload="init()">
+ Test Container Controller
+ </body>
+</html>
View
305 test/jsunit/app/xbDebug.js
@@ -0,0 +1,305 @@
+// xbDebug.js revision: 0.003 2002-02-26
+
+/* ***** BEGIN LICENSE BLOCK *****
+ * Licensed under Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ * Full Terms at /xbProjects-srce/license/mpl-tri-license.txt
+ *
+ * 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 Netscape code.
+ *
+ * The Initial Developer of the Original Code is
+ * Netscape Corporation.
+ * Portions created by the Initial Developer are Copyright (C) 2001
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s): Bob Clary <bclary@netscape.com>
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+/*
+ChangeLog:
+
+2002-02-25: bclary - modified xbDebugTraceOject to make sure
+ that original versions of wrapped functions were not
+ rewrapped. This had caused an infinite loop in IE.
+
+2002-02-07: bclary - modified xbDebug.prototype.close to not null
+ the debug window reference. This can cause problems with
+ Internet Explorer if the page is refreshed. These issues will
+ be addressed at a later date.
+*/
+
+function xbDebug()
+{
+ this.on = false;
+ this.stack = new Array();
+ this.debugwindow = null;
+ this.execprofile = new Object();
+}
+
+xbDebug.prototype.push = function ()
+{
+ this.stack[this.stack.length] = this.on;
+ this.on = true;
+}
+
+xbDebug.prototype.pop = function ()
+{
+ this.on = this.stack[this.stack.length - 1];
+ --this.stack.length;
+}
+
+xbDebug.prototype.open = function ()
+{
+ if (this.debugwindow && !this.debugwindow.closed)
+ this.close();
+
+ this.debugwindow = window.open('about:blank', 'DEBUGWINDOW', 'height=400,width=600,resizable=yes,scrollbars=yes');
+
+ this.debugwindow.title = 'xbDebug Window';
+ this.debugwindow.document.write('<html><head><title>xbDebug Window</title></head><body><h3>Javascript Debug Window</h3></body></html>');
+ this.debugwindow.focus();
+}
+
+xbDebug.prototype.close = function ()
+{
+ if (!this.debugwindow)
+ return;
+
+ if (!this.debugwindow.closed)
+ this.debugwindow.close();
+
+ // bc 2002-02-07, other windows may still hold a reference to this: this.debugwindow = null;
+}
+
+xbDebug.prototype.dump = function (msg)
+{
+ if (!this.on)
+ return;
+
+ if (!this.debugwindow || this.debugwindow.closed)
+ this.open();
+
+ this.debugwindow.document.write(msg + '<br>');
+
+ return;
+}
+
+var xbDEBUG = new xbDebug();
+
+window.onunload = function () { xbDEBUG.close(); }
+
+function xbDebugGetFunctionName(funcref)
+{
+
+ if (!funcref)
+ {
+ return '';
+ }
+
+ if (funcref.name)
+ return funcref.name;
+
+ var name = funcref + '';
+ name = name.substring(name.indexOf(' ') + 1, name.indexOf('('));
+ funcref.name = name;
+
+ if (!name) alert('name not defined');
+ return name;
+}
+
+
+// emulate functionref.apply for IE mac and IE win < 5.5
+function xbDebugApplyFunction(funcname, funcref, thisref, argumentsref)
+{
+ var rv;
+
+ if (!funcref)
+ {
+ alert('xbDebugApplyFunction: funcref is null');
+ }
+
+ if (typeof(funcref.apply) != 'undefined')
+ return funcref.apply(thisref, argumentsref);
+
+ var applyexpr = 'thisref.xbDebug_orig_' + funcname + '(';
+ var i;
+
+ for (i = 0; i < argumentsref.length; i++)
+ {
+ applyexpr += 'argumentsref[' + i + '],';
+ }
+
+ if (argumentsref.length > 0)
+ {
+ applyexpr = applyexpr.substring(0, applyexpr.length - 1);
+ }
+
+ applyexpr += ')';
+
+ return eval(applyexpr);
+}
+
+function xbDebugCreateFunctionWrapper(scopename, funcname, precall, postcall)
+{
+ var wrappedfunc;
+ var scopeobject = eval(scopename);
+ var funcref = scopeobject[funcname];
+
+ scopeobject['xbDebug_orig_' + funcname] = funcref;
+
+ wrappedfunc = function ()
+ {
+ var rv;
+
+ precall(scopename, funcname, arguments);
+ rv = xbDebugApplyFunction(funcname, funcref, scopeobject, arguments);
+ postcall(scopename, funcname, arguments, rv);
+ return rv;
+ };
+
+ if (typeof(funcref.constructor) != 'undefined')
+ wrappedfunc.constructor = funcref.constuctor;
+
+ if (typeof(funcref.prototype) != 'undefined')
+ wrappedfunc.prototype = funcref.prototype;
+
+ scopeobject[funcname] = wrappedfunc;
+}
+
+function xbDebugCreateMethodWrapper(contextname, classname, methodname, precall, postcall)
+{
+ var context = eval(contextname);
+ var methodref = context[classname].prototype[methodname];
+
+ context[classname].prototype['xbDebug_orig_' + methodname] = methodref;
+
+ var wrappedmethod = function ()
+ {
+ var rv;
+ // eval 'this' at method run time to pick up reference to the object's instance
+ var thisref = eval('this');
+ // eval 'arguments' at method run time to pick up method's arguments
+ var argsref = arguments;
+
+ precall(contextname + '.' + classname, methodname, argsref);
+ rv = xbDebugApplyFunction(methodname, methodref, thisref, argsref);
+ postcall(contextname + '.' + classname, methodname, argsref, rv);
+ return rv;
+ };
+
+ return wrappedmethod;
+}
+
+function xbDebugPersistToString(obj)
+{
+ var s = '';
+ var p;
+
+ if (obj == null)
+ return 'null';
+
+ switch(typeof(obj))
+ {
+ case 'number':
+ return obj;
+ case 'string':
+ return '"' + obj + '"';
+ case 'undefined':
+ return 'undefined';
+ case 'boolean':
+ return obj + '';
+ }
+
+ if (obj.constructor)
+ return '[' + xbDebugGetFunctionName(obj.constructor) + ']';
+
+ return null;
+}
+
+function xbDebugTraceBefore(scopename, funcname, funcarguments)
+{
+ var i;
+ var s = '';
+ var execprofile = xbDEBUG.execprofile[scopename + '.' + funcname];
+ if (!execprofile)
+ execprofile = xbDEBUG.execprofile[scopename + '.' + funcname] = { started: 0, time: 0, count: 0 };
+
+ for (i = 0; i < funcarguments.length; i++)
+ {
+ s += xbDebugPersistToString(funcarguments[i]);
+ if (i < funcarguments.length - 1)
+ s += ', ';
+ }
+
+ xbDEBUG.dump('enter ' + scopename + '.' + funcname + '(' + s + ')');
+ execprofile.started = (new Date()).getTime();
+}
+
+function xbDebugTraceAfter(scopename, funcname, funcarguments, rv)
+{
+ var i;
+ var s = '';
+ var execprofile = xbDEBUG.execprofile[scopename + '.' + funcname];
+ if (!execprofile)
+ xbDEBUG.dump('xbDebugTraceAfter: execprofile not created for ' + scopename + '.' + funcname);
+ else if (execprofile.started == 0)
+ xbDEBUG.dump('xbDebugTraceAfter: execprofile.started == 0 for ' + scopename + '.' + funcname);
+ else
+ {
+ execprofile.time += (new Date()).getTime() - execprofile.started;
+ execprofile.count++;
+ execprofile.started = 0;
+ }
+
+ for (i = 0; i < funcarguments.length; i++)
+ {
+ s += xbDebugPersistToString(funcarguments[i]);
+ if (i < funcarguments.length - 1)
+ s += ', ';
+ }
+
+ xbDEBUG.dump('exit ' + scopename + '.' + funcname + '(' + s + ')==' + xbDebugPersistToString(rv));
+}
+
+function xbDebugTraceFunction(scopename, funcname)
+{
+ xbDebugCreateFunctionWrapper(scopename, funcname, xbDebugTraceBefore, xbDebugTraceAfter);
+}
+
+function xbDebugTraceObject(contextname, classname)
+{
+ var classref = eval(contextname + '.' + classname);
+ var p;
+ var sp;
+
+ if (!classref || !classref.prototype)
+ return;
+
+ for (p in classref.prototype)
+ {
+ sp = p + '';
+ if (typeof(classref.prototype[sp]) == 'function' && (sp).indexOf('xbDebug_orig') == -1)
+ {
+ classref.prototype[sp] = xbDebugCreateMethodWrapper(contextname, classname, sp, xbDebugTraceBefore, xbDebugTraceAfter);
+ }
+ }
+}
+
+function xbDebugDumpProfile()
+{
+ var p;
+ var execprofile;
+ var avg;
+
+ for (p in xbDEBUG.execprofile)
+ {
+ execprofile = xbDEBUG.execprofile[p];
+ avg = Math.round ( 100 * execprofile.time/execprofile.count) /100;
+ xbDEBUG.dump('Execution profile ' + p + ' called ' + execprofile.count + ' times. Total time=' + execprofile.time + 'ms. Avg Time=' + avg + 'ms.');
+ }
+}
View
83 test/jsunit/css/jsUnitStyle.css
@@ -0,0 +1,83 @@
+/* @author Edward Hieatt, edward@jsunit.net */
+
+body
+{
+ margin-top: 0;
+ margin-bottom: 0;
+ font-family: Verdana, Arial, Helvetica, sans-serif;
+ color: #000;
+ font-size: 0.8em;
+ background-color: #fff;
+}
+
+td
+{
+ padding: 0;
+ margin: 0;
+}
+
+td img
+{
+ padding: 0;
+ margin: 0;
+ vertical-align: baseline;
+ display: block;
+}
+
+input
+{
+}
+
+select
+{
+}
+
+a:link, a:visited
+{
+ color : #00F;
+}