Sunday, June 22, 2008

Make JSUnit work in Firefox 3.0

I lost hours figuring out this one. I was getting an error: Permission denied to get property Window.xbDEBUG, and eventually getting timeout on running my test page. The first error was happening on different lines of code while I was debugging in Firebug. At the end it was probably some concurrency issue, timeout was happening due to JSUnit test runner not being able to load my test file.
Now, of course I checked if the file exists, and it did exist. I figured out that it cannot load file since it is stuck in function: isPageLoaded in testContainerController.html. Why? At the end I found an answer in an unlikely place: Why doesn't my test suite run under JSCoverage in Firefox 3?
The problem is in the tightened Firefox security regarding local files, and security.fileuri.origin_policy parameter is not the correct one as suggested by the FAQ, it is new configuration parameter that superseded it:
Security.fileuri.strict_origin_policy, it should be set to false so JSUnit will run correctly. The article is mumbling something about suggesting to keep it true for the improved security sake, but I'm too tired of banging my head of the wall to really pay attention.

*** UPDATE ***
I just realised that the version of JSUnit I'm using ( 2.2alpha11 ) is not working correctly when you brows for the test page. I am getting an error:
Reading Test Page file:///someTest.html timed out.
Make sure that the file exists and is a Test Page.
The page does not exist since I browsed to a different file - file:///c:\temp\someTest.html. So there is a bug with loading page.
However it works if I supply the test page through testPage url parameter like this:
If the tests were not working after fixing the configuration then this might be the next thing to try out.


  1. Thanks for the post. I was facing the xbDEBUG and load time out issues until I saw this.

    1. Hi, Great.. Tutorial is just awesome..It is really helpful for a newbie like me.. I am a regular follower of your blog. Really very informative post you shared here. Kindly keep blogging. If anyone wants to become a Front end developer learn from JQuery Training in Chennai . or learn thru JQuery Training . or learn thru ES6 Online Training. Nowadays JavaScript has tons of job opportunities on various vertical industry.

  2. should help with the remaining issue.

  3. Thanks for your help. I'm using Firefox 3 and I can't get Firefox to find the test file using either approach (can't insert it into the text box provided by the testrunner, and can't append the filename to the url, as suggested here). However, the testrunner page does work as expected when I run it in Chrome. Mostly I use Firefox, so I'd prefer to get it working there -- if anyone has got it figured out yet.