Open Bug 470372 Opened 13 years ago Updated 4 years ago

DOMNodeInserted event doesn't fire on DIV where event listener was added to a DOM element accessible via window.content


(Core :: DOM: Events, defect, P5)

1.9.1 Branch
Windows XP





(Reporter: mort253, Unassigned)





(1 file)

User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.1b2) Gecko/20081201 Firefox/3.1b2
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.1b2) Gecko/20081201 Firefox/3.1b2

I have developed a Firefox extension that uses window.content to access the content-primary DOM loaded in the browser.  I have attached a DOMNodeInserted event to a DIV.  I obtain a reference to this DIV via window.content.document.getElementById("MainContent") where "MainContent" is the id attribute of the DIV element in

Next, I call the addEventListener method and attach an anonymous function to the element.  When elements are added to the DIV in previous versions of Firefox 2.x and 3.0.x the event fires.  However, in Firefox 3.1/b1 and Firefox 3.1/b2 this event does not fire.  I have tried with the captureFlag set to true as well as false.

Below is the code from the Firefox Extension:

			var frame = window.content.document.getElementById("MainContent");

			if(frame != undefined && frame != null) {
				log(" = " +;
frame.addEventListener('DOMNodeInserted',function (e) {
				  log('Calling DOMNodeInserted event...');

This code functions perfectly in Firefox 2 and Firefox 3.  This indicates a problem with either the DOMNodeInserted event or the addEventListener method.

There is an open bug related to other issues in Hotmail that are preventing users from being able to read their messages.  One possibility is that this bug is somehow related to that issue.

Please email if you have any questions.

James Mortensen

Reproducible: Always

Steps to Reproduce:
1.  Place the sample code I provided in a Firefox extension JavaScript file and ensure that the window.addEventListener event fires the code.
2.  Browse to  The window.addEventListener should fire and run the code.
3.  click the "New" button to create a new message, which is an AJAX operation.  This will not refresh the page but will add content to the DIV.  Observe that the DOMNodeInserted event does NOT fire in Firefox 3.1/b2 but does in Firefox 3 and 2.
Actual Results:  
The actual result is that the DOMNodeInserted event does not fire.  There are no error messages in the console.

Expected Results:  
The event did not fire.

I feel that the developers of Firefox should strive to maintain backwards compatibility as to not break existing Firefox extensions.

Again, if you need more information, please email and I'd be happy to answer any further questions.

James Mortensen
Version: unspecified → 3.1 Branch
Component: General → DOM: Events
Product: Firefox → Core
QA Contact: general → events
Version: 3.1 Branch → 1.9.1 Branch
Could you please attach a *minimal* testcase.
Or if you could try to find the regression range using nightly builds
Attached file testcase
This is WFM for me on: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.1b3pre) Gecko/20081218 Shiretoko/3.1b3pre


Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv: Gecko/2008120122 Firefox/3.0.5

Both with this testcase and when using similar code with window.content in the urlbar.

Move all DOM bugs that haven’t been updated in more than 3 years and has no one currently assigned to P5.

If you have questions, please contact :mdaly.
Priority: -- → P5
You need to log in before you can comment on or make changes to this bug.