Closed Bug 304442 Opened 19 years ago Closed 19 years ago

window.open requires an alert to properly display

Categories

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

x86
Windows XP
defect
Not set
normal

Tracking

()

RESOLVED INVALID

People

(Reporter: danswer, Unassigned)

References

Details

(Keywords: regression, testcase)

Attachments

(2 files, 1 obsolete file)

User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8b2) Gecko/20050620 Firefox/1.0+
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8b2) Gecko/20050620 Firefox/1.0+

If, upon a button click, I do a window.open("javascript:'...'") then the new
window opens and displays.  If a subsequently attempt to update its DOM, I am
not permitted to unless I've clicked on an alert box before trying to do so.

Reproducible: Always

Steps to Reproduce:
Just bring up the attachment (the 'no alert' one).
Click on either button.

Actual Results:  
A new window will come up, but it won't show the button that is added.  HOWEVER,
it you watch closely, you'll see that the button (the Dlg button) is built and
then it disappears.  The JS console does not indicate any error.


Expected Results:  
The page should have let me add/modify the DOM without complaint.  I do have my
popup blocker active, but I initiated the opening of the window (which happened
just fine) via a user initiated action (click on a button).  So there is no
cause to have me click on an alert box.

It's pretty clear that the zone of the popup is different from the underlying
page since the popup is build via "javascript:".  At the same time, js has
(mostly) free reign over the underlying page so I see no security compromise by
treating the domain of the page as being that of the parent page.  This issue is
not addressed in the mozilla docs that I've seen.  Furthermore, the code works
as expected on my IE 6 (Win XP Pro, SP 2).

Csaba Gabor from Vienna
Added an attachment to show that if there is no alert between creating a popup
with window.open("javascript:'...'") and modifying it, then the mods are built
(watch the window closely) but don't make it onto the final window.
Comment on attachment 192512 [details]
'no alert' version will not show button on popup

<html><head><title>window.open() testing</title></head><body>
<button id=btn1 accesskey=c
onclick="window.setTimeout('showDlg()',10)"><u>C</u>lick me</button>
<button accesskey=t onclick="window.setTimeout('showDlg()',10)"><u>T</u>ry
me</button>
<script type='text/javascript'>
function showDlg() {
    var
nw=window.open("javascript:'<html><head><title>Test</title><head><body>There
should be a button showing </body>'");

//alert("alert for FF");	// enabling this line shows resultant page
correctly

    var btn = nw.document.createElement("button");
    btn.innerHTML = "Dlg <u>b</u>utton"
    btn.accessKey = "b";
    btn.onclick = function() {nw.alert("Button clicked");}
    nw.document.body.appendChild(btn);

    // FF occasionally disabled calling button and this fixed it.
    document.getElementById('btn1').onclick = function()
{window.setTimeout('showDlg()',10); }
}
</script>
</body></html>
Sorry, I seem to have attached the wrong file, and my editing attempt didn't
appear to modify it.  This should be the real test file.
Attachment #192512 - Attachment is obsolete: true
This shows the button on the popup page correctly, at the expense of having to
click on an alert box before the button is added to the popup.	We should not
have to do that alert.

The reason that there are two buttons on the base page is that while I was
testing (with the page embedded in a frame), there were times (which I can't
consistently reproduce or narrow) that the Try me button would disable itself
after a single press.  It would no longer fire the onClick event.  I got around
this by reassigning an event handler to it, as with the Click me button.  Thus,
the Click Me button should always generate a new page, while the Try me button
might get 'stuck'.

Csaba
confirming
Mozilla/5.0 (Windows; U; Win98; en-US; rv:1.9a1) Gecko/20050812 Firefox/1.0+
Mozilla/5.0 (Windows; U; Win98; en-US; rv:1.9a1) Gecko/20050813 SeaMonkey/1.0a

the non-alert version doesn't show the button, the alert version shows the
button, but also produces an error message in JS console.
both 'clickme' and 'tryme' were working sameway.

Error: uncaught exception: [Exception... "Component returned failure code:
0x80004005 (NS_ERROR_FAILURE) [nsIDOMWindowInternal.focus]"  nsresult:
"0x80004005 (NS_ERROR_FAILURE)"  location: "JS frame ::
chrome://global/content/bindings/tabbrowser.xml :: setFocus :: line 639"  data: no]
Status: UNCONFIRMED → NEW
Ever confirmed: true
Bug also seen on 1.7 Branch:
Mozilla/5.0 (Windows; U; Win98; de-DE; rv:1.7.10) Gecko/20050715 Firefox/1.0.6

Keywords: testcase
*** Bug 308136 has been marked as a duplicate of this bug. ***
*** Bug 306808 has been marked as a duplicate of this bug. ***
The error here started occuring after the check-in for bug 175893. I don't know
if this actually prevents any events from happening, but it does seem to be
causing some issues (per this bug and bug 306808).
Keywords: regression
Actually, this bug and bug 306808 are different issues.
The problem described in this bug is by design and considered to be invalid.
http://developer.mozilla.org/en/docs/DOM:window#Methods
If there is no alert(), nw.document.body.appendChild(btn); is
evaluated before the url given to window.open() is loaded.
Yep.  This is invalid.
Status: NEW → RESOLVED
Closed: 19 years ago
Resolution: --- → INVALID
Component: DOM: HTML → DOM: Core & HTML
QA Contact: ian → general
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: