document.open/write fails 2nd time through

UNCONFIRMED
Unassigned

Status

()

Core
DOM: Core & HTML
UNCONFIRMED
7 years ago
7 years ago

People

(Reporter: stephen, Unassigned)

Tracking

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(1 attachment)

672 bytes, application/x-zip-compressed
Details
(Reporter)

Description

7 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 document.open().

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


Reproducible: Always

Steps to Reproduce:
1. load a page with a button to trigger document.open()/write()/close()
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 document.open() and using that for the remaining steps seems to be a workaround.

	var doc = document.open();
	doc.write(...);
	doc.close();
(Reporter)

Comment 1

7 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?
(Reporter)

Comment 3

7 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: http://hg.mozilla.org/mozilla-central/pushloghtml?fromchange=ad227939db82&tochange=789f0f85f75a
(Reporter)

Comment 5

7 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.