Closed Bug 293642 Opened 20 years ago Closed 19 years ago

Copying script with document.write() displays output in new window instead of div

Categories

(Firefox :: General, defect)

x86
Windows XP
defect
Not set
normal

Tracking

()

RESOLVED INVALID

People

(Reporter: asefkow, Unassigned)

References

()

Details

User-Agent:       Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.7) Gecko/20050414 Firefox/1.0.3

This is relatively confusing bug, but it's a distilled-down testcase that's 
important for Oracle.  We're loading an iframe that, in its onLoad handler, 
copies scripts into the parent.  Some of those scripts have document.write() 
calls.

Reproducible: Always

Steps to Reproduce:
1. Download frames5.zip to your local machine, and open START.htm
2. Click the link.

Actual Results:  
Note that the document.write() appears to run in a new window, whereas in IE 
(Win) and Safari (Mac), it writes inside the IFRAME.

Also, the progress icon in the upper-right spins endlessly.  If you click 
STOP, you get an issue with the BACK button -- clicking Back does not have any 
effect (you have to go back 2-3 steps to really go back).  None of this is a 
problem on IE or Safari.

Expected Results:  
I should see text written inside the IFRAME.

I reproduced this on Firefox for Mac as well.  This is possibly related to bug 
293633, which is itself possibly related to bug 283389.  There are issues with 
copying scripts between documents (iframe to parent).
60 days inactive: INVALID in 72 hours, otherwise reassigning to owner.

Is this reproducable with a recent nightly build (http://www.mozilla.org/developer)?
Status: UNCONFIRMED → ASSIGNED
Ever confirmed: true
(In reply to comment #0)

INVALID.

(1) You have 2 scripts in div1.htm, "page.js" in <head>
    and document.write('hello') in <body>
(2) Your copyScripts function copies these 2 <script>s into <head> of parent
(3) Then <script>document.write('hello')</script> is put in <head> of parent
(4) On newest Mozilla, this newly inserted script is executed.
    Then parent's page becomes <head><body>hello</body></head>,
    and loading doen't complete due to lack of "document.close()".
    (See Bug 300322 for this phenomenon.)

If alert is inserted in each loop by "for (var i=0; i<srcScripts.length; i++)",
you can see your expected text in the IFRAME when first loop,
then see that parent page is replaced by "hello" when second loop. 

I don't know whether the "document.write('hello') was executed by older Mozilla
or not. (But if not executed, I believe it is bug, and corrected.)
I think IE doesn't execute the newly added "document.write", and I believe bug
of IE.

Another problem may occur on <script> modification.
"src" attribute value change of <script> tag in <head> didn't work on Mozilla in
the past.
 - attribute value is changed but re-loading was not executed when Mozilla. 
I do not know whetehr this is bug or design, and I don't know whether corrected
or not if bug.
But as far as I remember, Opera 7 reloaded new script if src of <script> was
modified by JavaScript.

(I reply to comment #1)
> 60 days inactive: ...
Is this message by automatic expiration? Has it been enabled?
If yes, I feel very happy :-)
Confirming INVALID.

It's not automatic, I just search for bugs 60+ days old and double-check to see
if they are still valid or, in this case, not.
Status: ASSIGNED → RESOLVED
Closed: 19 years ago
Resolution: --- → INVALID
See Bug 292792 for "Another problem" in my comment #2.
> Bug 292792 JS/Dom: setting src-attribute for script tag is only possible once.
>                    Any further setting is ignored
You need to log in before you can comment on or make changes to this bug.