Firefox 3 security and jqUnit

I recently upgraded to Firefox 3, and immediately began having problems with jqUnit unit tests.


The failing tests make Ajax requests, using URLs like "../templates/some_fragment.html". That is, the requested documents reside in the web application's source tree; they are not in a subdirectory of the directory containing the jqUnit test.

Under Firefox 2 (and Safari 3) this was no problem. The browser would simply go out to the filesystem and retrieve the file, no matter its relative location.

Under Firefox 3 the requests failed. The error console showed messages like

Security Error: Content at file:///path/to/unit_tests/foo.html may not load data from file:///path/to/templates/bar.html.
Firebug would report
Error: [Exception... "Access to restricted URI denied" code: "1012" nsresult: "0x805303f4 (NS_ERROR_DOM_BAD_URI)" location:...


A quick fix is to load Firefox's about:config page and revert to the less-secure behavior of Firefox 2, by setting security.fileuri.strict_origin_policy to false. explains in detail.


Long-term, I need to see about restructuring my unit test directories. This should be easy for organizing static .json files, but I'm not sure what to do in cases where I need to retrieve things like markup, from parent or sibling directories.

More Information

John Resig's weblog provided a great summary of the problem. The comments section was especially helpful.