PrologueAfter finding a couple bugs in the Observers JS module recently, I looked around for a simple test harness to exercise it and other JS modules. Weave's (based on Mozilla's xpcshell harness) seemed promising, although it has to hack around various limitations of xpcshell.
Atul Varma had suggested some time ago that a XULRunner-based harness might make sense, so I decided to see if I could modify Weave's harness to run JS module tests using XULRunner instead of xpcshell.
Act 1That proved doable, although some details were tricky. Sometimes I wondered whether I wouldn't have been better off reusing MochiTest, although it's heavier weight. Other times I wondered why I didn't find this bug about XULRunner-based unit tests sooner, although it's not clear that reusing the attachment in that bug would have been faster.
In any case, I got the harness working with XULRunner and wrote an initial set of tests of the Observers module. To run them, pull the
jsmodulesrepository, change to its
test/unit/subdirectory, and run
makewith the location of your XULRunner executable (or set the
XULRUNNER_BINenvironment variable to its location):
hg clone https://hg.mozdev.org/jsmodules
Since Firefox 3.0 comes with XULRunner, you can use any Firefox 3.0 (or newer) executable instead (except on Linux distros that ship Firefox as a XULRunner app--you have to use the XULRunner executable on those), like
/Applications/Firefox.app/Contents/MacOS/firefox-binon Mac and
/c/Program\ Files/Mozilla\ Firefox/firefox.exeon Windows.
EpilogueOnce I got the harness working for jsmodules, I backported it to Weave, where it mostly works, except that IWeaveCrypto.generateKeypair (which calls PK11_GenerateKeyPair) fails, apparently because of
I have no idea why, but if you do, comment here or in bug 476539, since that's the last blocker to Weave using this harness.