Modified jsUnitRunner that injects jsUnitCore.js into test case

I've attached a modified jsUnitRunner.js and main.html that will "inject" the contents of jsUnitCore.js and jsUnitUtility.js (extracted from an inline script element in main.html) into a test case if jsUnitCore.js isn't referenced.  Code has been tested on IE 6/Win XP and Mozilla 0.9.7.

The modifications should have no affect on existing cases that have explicit <script> elements for jsUnitCore.js.

For cases that want to omit the explicit <script> elements (and the undesirable fixing of the relative location of test to test framework), the test case must contain a isLoaded() method that returns true when the case is fully loaded.  For the DOM TS work, this would be embedded in the DOMTestCase.js file.  For other use, you could add the following boilerplate code into the test:

var isTestPageLoaded=false;

function isLoaded() {
return isTestPageLoaded;
}
function newOnLoadEvent() {
isTestPageLoaded=true;
}

window.onload=newOnLoadEvent;


I had originally tried adding elements like <script src=".../jsUnitCore.js"/> but Netscape would not load the external resource early enough without throwing in an annoying alert(), hence the slightly undesireable duplication of jsUnitCore.js code within main.html.

I've also included variants of jsUnit's internal tests, but without the external script elements.

Received on Friday, 1 February 2002 04:53:50 UTC