Closed Bug 788547 Opened 7 years ago Closed 9 months ago

URL changes to wyciwyg://N/<old URL> after document.write


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

15 Branch
Windows 7





(Reporter: gtisza, Unassigned)



(Whiteboard: DUPEME)


(1 file, 1 obsolete file)

Attached file test.html (obsolete) —
User Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:15.0) Gecko/20100101 Firefox/15.0
Build ID: 20120824154833

Steps to reproduce:

Execute document.write on a web page after the page has been fully loaded.

Actual results:

The contents of the page are replaced by the output of document.write, the browser starts loading (the load icon is spinning) and never stops. Upon pressing Esc, the URL bar changes to wyciwyg://N/<old URL> where N is a number. Trying to reload the page (with F5 or the circle-arrow icon) seems to have no effect, and the network tab of Firebug does not show anything at all.

Expected results:

The contents of the page are replaced by the output of document.write. The URL is unchanged, and reloading works as expected.
> the browser starts loading (the load icon is spinning) and never stops.

That's because the document is not done loading.  If you make more document.write calls, they will add to the document.  If the document were done loading, a document.write call would replace the document.
Whiteboard: DUPEME
Attachment #658514 - Attachment is obsolete: true
(In reply to Boris Zbarsky (:bz) from comment #2)
> That's because the document is not done loading.

document.write was called in the domready event handler. But just to be sure, I updated the test page to run document.write on click and the behavior is the same.
No, the point is that when you call write() on a document that is no longer being parsed, the document is reopened and goes back into a loading state.  And it stays in that state until you call document.close().
experiencing the same behavior here. Confirmed that the document.close() solve the issue. But the bug is that it's happening on some pages (maybe they are not well written enough), but it's NOT happening with other browsers.
Additionally, thanks to your analysis, I found out that the code causing this behavior was an old one given by Google for sites analytics. Which code can be found in many personal sites.

<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "' type='text/javascript'%3E%3C/script%3E"));
<script type="text/javascript">
try {
var pageTracker = _gat._getTracker("UA-numberss-1");
} catch(err) {}</script>
Attachment #658531 - Attachment mime type: text/plain → text/html
I've recently run into this problem (Windows 7, FF version 50.0.2. Some previous comments indicate a cause related to doing document.write(...) and indeed my app is doing that. Those comments seem to suggest that the lack of a document.close() is the culprit, but in all cases in my app, doc.write(...) is immediately followed by doc.close() so I'm still at a loss as to what our app is doing to cause this, or what workarounds might exist to prevent it. It happens with our app like clockwork (sometimes all it takes is a single click of the refresh/reload button and it happens), and never with any of the other browsers we're using to access our app (mostly IE and Chrome). Any advice would be most appreciated.
See Also: → 1456313
Priority: -- → P3

Bug 1489308 is aligning Firefox's behavior with with other browsers, so maybe it will address this issue.

Depends on: 1489308
Closed: 9 months ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.