User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; ja; rv:220.127.116.11) Gecko/20070309 Firefox/18.104.22.168 Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; ja; rv:22.214.171.124) Gecko/20070309 Firefox/126.96.36.199 If you create an XMLDocument, create a custom event and dispatch the event on the XMLDocument, dispatchEvent throws an exception NS_ERROR_FAILURE. See the attached example. This happens no matter whether the document has a "chrome:" URL or not. This does not happen if you use window.document instead of the XMLDocument created by script. Reproducible: Always Steps to Reproduce: 1. Open attachment. Actual Results: Nothing happens. The Console^2 extension shows: Component returned failure code: 0x80004005 (NS_ERROR_FAILURE) [nsIDOMEventTarget.dispatchEvent] Expected Results: Two alert boxes should appear, one saying "testevent" and the other "Completed."
Naturally you can work around this issue by maintaining event listeners on the custom event by yourself and avoiding using dispatchEvent.
This WFM in Fx 3.0 and higher. Likely due to bug 412567, but I can't prove it.