W3C home > Mailing lists > Public > www-dom-ts@w3.org > February 2002

Modified jsUnitRunner that injects jsUnitCore.js into test case

From: Curt Arnold <carnold@houston.rr.com>
Date: Fri, 1 Feb 2002 03:53:23 -0600
Message-ID: <000a01c1ab06$4a3befc0$a800a8c0@CurtMicron>
To: <www-dom-ts@w3.org>
Cc: <edward@jsunit.net>, <jsunit@yahoogroups.com>
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

This archive was generated by hypermail 2.3.1 : Tuesday, 6 January 2015 20:34:04 UTC