Closed Bug 615927 Opened 14 years ago Closed 6 years ago

document.open/write fails 2nd time through

Categories

(Core :: DOM: Core & HTML, defect, P5)

x86
Windows 7
defect

Tracking

()

RESOLVED WORKSFORME

People

(Reporter: stephen, Unassigned)

Details

Attachments

(1 file)

672 bytes, application/x-zip-compressed
Details
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();
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?
Attached file 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
NOTE: this now appears to have been fixed in the released version of 4.0b8.
https://bugzilla.mozilla.org/show_bug.cgi?id=1472046 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

Long-fixed per comment 4 and comment 5 (and testing on current tip).

Status: UNCONFIRMED → RESOLVED
Closed: 6 years ago
Resolution: --- → WORKSFORME
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: