The default bug view has changed. See this FAQ. fails 2nd time through




DOM: Core & HTML
6 years ago
6 years ago


(Reporter: stephen, Unassigned)


Firefox Tracking Flags

(Not tracked)



(1 attachment)

672 bytes, application/x-zip-compressed


6 years ago
User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US) AppleWebKit/534.7 (KHTML, like Gecko) Chrome/7.0.517.44 Safari/534.7
Build Identifier: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:2.0b7) Gecko/20100101 Firefox/4.0b7

It appears that the snippet below will work the first time through but then the second time through document will be null after

	try {
		if (document == null) { throw new Error("before open"); };
		if (document == null) { throw new Error("before write"); }
		if (document == null) { throw new Error("before close"); }
	} catch (ex) {
		if (window.console) {
		} else {

Reproducible: Always

Steps to Reproduce:
1. load a page with a button to trigger
2. trigger the script (everything works fine)
3. trigger it again (document becomes null)
Actual Results:  
document is null

Expected Results:  
In FF 3.x this could be repeated indefinitely.

The page source has the script in an external JavaScript file, so it should be executing it each time the page is rebuilt. document is being refereced (not stored) so it should be pointing to the current document (rather than an old instance).

Storing the value returned from and using that for the remaining steps seems to be a workaround.

	var doc =;

Comment 1

6 years ago
I forgot to mention the alert that pops up says "before write".

Note also there's a typo in the console line.
Can you attach a complete web page that shows the problem?

Comment 3

6 years ago
Created attachment 494459 [details]
repro example

Attachment is a simple web page and script which demonstrates the problem. Works fine in Firefox 3.6.13 but not in Firefox 4.0b7. Thanks.
Hmm.  I see the issue in b7, but not on trunk.  Looks like this got fixed somewhere in this range:

Comment 5

6 years ago
NOTE: this now appears to have been fixed in the released version of 4.0b8.
You need to log in before you can comment on or make changes to this bug.