{ib}document.write causes duplicated content

RESOLVED WORKSFORME

Status

()

P2
normal
RESOLVED WORKSFORME
17 years ago
3 years ago

People

(Reporter: mgalli, Assigned: waterson)

Tracking

({testcase})

Trunk
Future
testcase
Points:
---
Dependency tree / graph

Firefox Tracking Flags

(Not tracked)

Details

(URL)

Attachments

(1 attachment)

(Reporter)

Description

17 years ago
This is one special case from AOL site in Brazil. Note that the page have
content duplicated in the middle. I simplified the page to the following testcase:

<html>
<body>
<span>
        <script>
                document.write('<div>')
                document.write('</div>')
        </script>
---------------
This is content
---------------
        <script>
                document.write('<span>')
                document.write('<div></div>')
                document.write('</span>')
        </script>
</span>
</body>
</html>

Mozilla is displaying the content between the script areas twice. 
When I verify the generated content in the DOM, it's not duplicated, only in the
screen. Note that if you select the second text, this will actually select the
first. 

Confirmed with: Gecko/20020430
(Reporter)

Comment 1

17 years ago
Created attachment 81814 [details]
Simple testcase 1
(Reporter)

Comment 2

17 years ago
Changing OS to all. 
OS: Linux → All
Summary: document.write causes duplicated content → document.write causes duplicated content
more block-in-inline ugliness. :(
Hardware: PC → All
Summary: document.write causes duplicated content → {ib}document.write causes duplicated content
(Assignee)

Comment 4

17 years ago
Taking.
Assignee: attinasi → waterson

Updated

17 years ago
Keywords: testcase

Comment 5

17 years ago
Changing priority to P2
Priority: -- → P2
(Assignee)

Updated

17 years ago
Status: NEW → ASSIGNED
Target Milestone: --- → Future

Comment 7

14 years ago
worksforme with linux trunk 2005041521
is anybody still seeing this?
I see the duplicate output on Mozilla 1.7.11 Linux but not on 
branch nightly build
Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8b4) Gecko/20050827 Firefox/1.0+

-> WFM.
Researching the topic of document.write(), I found a way to create duplicate
output even on Deer Park 
Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8b4) Gecko/20050827 Firefox/1.0+

See the testcase: http://www.mobotix-service.de/~daniel/docwrite/

It contains two buttons, an iframe (top), a debug log (bottom) and javascript
code. If you press a button, the js code writes a small html document into the
iframe which contains <SCRIPT SRC=...> in the document head, effectively loading
javascript code. With the buttons you choose which script to load:
 left button : http://www.mobotix-service.de/~daniel/docwrite/alert.js
 right button: http://www.mobotix-service.de/~daniel/docwrite/documentwrite.js 

The latter contains two document.write calls and a callback to the parent page
(the one containing the iframe), sending a message to the debug log.

If you open the testpage and press the right button, this is what appears in the
iframe:

Hello! The current date and time is: Thu Sep 01 2005 18:13:10 GMT+0200 (CEST)
Hello! The current date and time is: Thu Sep 01 2005 18:13:10 GMT+0200
(CEST)IFrame Body starts here

The debug log message is missing, instead the javascript console shows an error:
Error: document has no properties
Source File: http://www.mobotix-service.de/~daniel/docwrite/documentwrite.js
Line: 2

Some questions arise:
- How does Gecko handle output of character data inside the document head?
- Does the script inside the iframe overwrite itself by calling document.write? 
- Why doesn't the output duplicate when documentwrite.js is included in a
"normale" browser frame, see 
http://www.mobotix-service.de/~daniel/docwrite/simple.html
- Is this problem created because the content of the iframe itself is created
dynamically and not just loaded through a src attribute?

Comment 10

13 years ago
I cannot submit a reliable example, but the Web interface to our application has been exhibiting issues that are almost certainly related to this bug...

On login, we load a three-frame document, with one hidden frame for "pseudo-AJAX" updates, a menu frame, and an application page frame.  The initial application frame is loaded with an image and a "quick-select" input box.  When the user enters a selection into the input box and presses ENTER or clicks the submit button, a form on the page is filled out and the onsubmit() function triggered; this targets the hidden frame, which loads JavaScript to replace the application page.  Occasionally, instead of replacing the application page, it appears to intersperse the new content with the old; the new content appears (mostly hidden) underneath the initial image, and DOM Inspector shows the new page elements as having been inserted BEFORE the image from the initial screen.  Likewise, header scripts appear to be duplicated, with new scripts appearing AFTER old scripts.  The stylesheet may also be loaded twice, though my only evidence of that so far is the resizing of the quick-select input label (our text elements are rendered in % from a fixed-pixel base...)  As with the example below, the JavaScript console shows "document has no properties" when this occurs.

According to spec, document.write() should either (a) append to a not-fully-rendered page, or (b) clear and replace a fully-rendered page.  This appears to be neither of the above...
QA Contact: chrispetersen → layout
Testcase works for me.  Please file a new bug if the problem still occurs in a recent Firefox.
Status: ASSIGNED → RESOLVED
Last Resolved: 3 years ago
Resolution: --- → WORKSFORME
You need to log in before you can comment on or make changes to this bug.