I'm working on a unit test for a javascript library that has several handlers. I wish to fire those handlers in a "natural" way, by raising an event that gets caught. I am having trouble creating an event that gets caught in Firefox.

I do development in Firefox to take advantage of Firebug, but the software is for a closed intranet and IE 7 is the required browser (we support IE 8 insofar as we force it to IE 8 mode). This policy predate my hire, I'm trying to get the software to a browser agnostic state - first I have to replace an ActiveX object known as MeadCo Script X - but that's a whole other issue.

Anyway I need to raise events, specifically onchange events in Firefox. I have this so far...

Code javascript:
function fire(el, ev) {
			el = $(el);
			if (typeof(el.fireEvent) != 'undefined') { // IE 
			} else { // Firefox?
				var e = document.createEvent('HTMLEvents');
				e.initEvent(el, true, true);

Prototype library is in use for this project, though I haven't used it for this particular corner case.