Closed
Bug 282573
Opened 21 years ago
Closed 18 years ago
Element created in a page from popup can't open popup
Categories
(Firefox :: General, defect)
Tracking
()
RESOLVED
WORKSFORME
People
(Reporter: maurizio.merli, Unassigned)
Details
Attachments
(1 file)
|
1.27 KB,
application/octet-stream
|
Details |
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322)
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; it-IT; rv:1.7.5) Gecko/20041110 Firefox/1.0
If a add a row in a table in the main window from a popup javascript. That row
can't use javascript command window.open to open another popup!!!!
Reproducible: Always
Steps to Reproduce:
Comment 1•21 years ago
|
||
Do you have a URL or testcase?
Normally one would put a javascript command such as window.open() in a <script>
element rather than a <tr>.
| Reporter | ||
Comment 2•21 years ago
|
||
Try that: IS A BUG!!!! With MSIE it works!
Launch FILE 1, then click on TEST and open popup
click on ADD DIV IN OPENER and add line to main window
NOW click on new lines and you have a BUG
---- FILE 1 -----
<html>
<body>
<script>
function addDiv() {
var el = document.createElement('DIV');
el.innerHTML = '<div onclick="window.open
(\'fxpubug.html\')">TEST</div>';
document.body.appendChild(el);
}
</script>
<div onclick="var w = window.open('fxpubug.html'); w.addDiv =
addDiv;">TEST</div>
</body>
</html>
---- FILE 2: fxpubug.html -----
<html>
<body>
<script>
function addDiv2() {
window.opener.addDiv();
}
</script>
<div onclick="addDiv2()">ADD DIV IN OPENER</div>
</body>
</html>
(In reply to comment #0)
> User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;
SV1; .NET CLR 1.1.4322)
> Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; it-IT; rv:1.7.5)
Gecko/20041110 Firefox/1.0
> If a add a row in a table in the main window from a popup javascript. That
row
> can't use javascript command window.open to open another popup!!!!
> Reproducible: Always
> Steps to Reproduce:
Comment 3•21 years ago
|
||
Mozilla/5.0 (Macintosh; U; PPC Mac OS X Mach-O; en-US; rv:1.8b) Gecko/20050217
Firefox/1.0+
I have taken the liberty of tweaking your files slightly so that they
are valid html, videlicet:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head></head>
<body>
<script type="application/x-javascript">
function addDiv() {
var el = document.createElement('DIV');
el.innerHTML = '<div onclick="window.open(\'fxpubug.html\')">TEST<'+'/div>';
document.body.appendChild(el);
}
</script>
<div onclick="var w = window.open('fxpubug.html'); w.addDiv=addDiv;">TEST</div>
</body>
</html>
and (fxpubug.html),
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head></head>
<body>
<script type="application/x-javascript">
function addDiv2() {
window.opener.addDiv();
}
</script>
<div onclick="addDiv2()">ADD DIV IN OPENER</div>
</body>
</html>
I can't be sure whether what I am seeing is a bug without knowing the expected
behaviour.
Here is what happens.
1. This first file renders showing the word 'TEST' in the top left
corner.
2. The cursor over this is an insertion point. I click once,
3. The cursor changes to an arrow.
4. The second page comes up, and I get three errors in the Javascript
Console, to wit,
Error: [Exception... "'Permission denied to get property XULElement.accessKey'
when calling method: [nsIDOMXULLabelElement::accessKey]" nsresult: "0x8057001e
(NS_ERROR_XPC_JS_THREW_STRING)" location: "JS frame ::
file:///Users/bfowler/Documents/BUGS/Bug.282573/Bug.282573-1.html :: onclick ::
line 1" data: no]
Source File: file:///Users/bfowler/Documents/BUGS/Bug.282573/Bug.282573-1.html
Line: 1
Error: [Exception... "'Permission denied to get property XULElement.accessKey'
when calling method: [nsIDOMXULLabelElement::accessKey]" nsresult: "0x8057001e
(NS_ERROR_XPC_JS_THREW_STRING)" location: "JS frame ::
file:///Users/bfowler/Documents/BUGS/Bug.282573/Bug.282573-1.html :: onclick ::
line 1" data: no]
Source File: file:///Users/bfowler/Documents/BUGS/Bug.282573/Bug.282573-1.html
Line: 1
Error: [Exception... "'Permission denied to get property XULElement.columns'
when calling method: [nsIDOMXULTreeElement::columns]" nsresult: "0x8057001e
(NS_ERROR_XPC_JS_THREW_STRING)" location: "JS frame ::
file:///Users/bfowler/Documents/BUGS/Bug.282573/Bug.282573-1.html :: onclick ::
line 1" data: no]
Source File: file:///Users/bfowler/Documents/BUGS/Bug.282573/Bug.282573-1.html
Line: 1
5. On the second page is the string 'ADD DIV IN OPENER', each time I click on this
string, a new line saying 'TEXT' is added to the first document. I can do this
ten, twenty times without ill effect.
6. When I close the the second window, I see these two messages in the Javascript
Console:
Error: uncaught exception: [Exception... "Component returned failure code:
0x80004005 (NS_ERROR_FAILURE) [nsIObserverService.removeObserver]" nsresult:
"0x80004005 (NS_ERROR_FAILURE)" location: "JS frame ::
chrome://global/content/bindings/browser.xml :: destroy :: line 572" data: no]
Error: uncaught exception: [Exception... "Component returned failure code:
0x80004005 (NS_ERROR_FAILURE) [nsIObserverService.removeObserver]" nsresult:
"0x80004005 (NS_ERROR_FAILURE)" location: "JS frame ::
chrome://global/content/bindings/browser.xml :: destroy :: line 572" data: no]
There are several questions:
Given that there are messages in the Javascript Console, are you certain that
your javascript code contains no bugs or defects itself?
What is the expected behaviour? Does it, in fact, differ from what I observed?
Should I be checking that the new 'TEST's are capable of opening fxpubug.html
popups?
Kindly note that even if you do believe that there is a bug in Firefox's
behaviour here, you should confirm it in a recent build.
| Reporter | ||
Comment 4•21 years ago
|
||
Try this! Always with that example.
Click on TEST in the main window and open popup. Then create click on TEXT on
the popup end create some other line.
Now CLOSE your popup and only after close it try to click on the NEW test
LINES in the main window and you have bug.
Not all. Try also that, put the popup file in another folder and open popup
with a RELATIVE url in window.open, for example window.open
('../mytestfolder/fxpubug.html'). Click on text and create other line in the
main.
NOW do non close popup otherwise you coudn't see BUG, but click on NEW TEXT
line in the main and you have surprise. The RELATIVE url of the new elements
now is relative to the popup window NOT to the main.
Is like if a Javascript insertion point is ALWAYS child of tha windows that
create it.
Comment 5•21 years ago
|
||
(In reply to comment #4)
> Try this! With the same example file, click on TEST in the main window
> and open popup. Then click on ADD DIV IN OPENER on the popup to create
> one more div 'TEST' in the main window.
> Next close the popup and after it is gone click on the NEW test div.
I did this. When I closed the pop up, I got this message in the Javascript
Console:
Error: uncaught exception: [Exception... "Component returned failure code:
0x80004005 (NS_ERROR_FAILURE) [nsIObserverService.removeObserver]" nsresult:
"0x80004005 (NS_ERROR_FAILURE)" location: "JS frame ::
chrome://global/content/bindings/browser.xml :: destroy :: line 572" data: no]
(as before)
When I clicked on the new div, the cursor did not change, and I got this
message:
Error: uncaught exception: [Exception... "Component returned failure code:
0x80004005 (NS_ERROR_FAILURE) [nsIDOMJSWindow.open]" nsresult: "0x80004005
(NS_ERROR_FAILURE)" location: "JS frame ::
file:///Users/bfowler/Documents/BUGS/Bug.282573/Bug.282573-1.html :: onclick ::
line 1" data: no]
I have to say again. Is there an error in your javascript? Is it doing what
you intend it to? It would be much easier to test the correctness of Firefox's
behaviour if we were completely confident of the scripting.
I have also checked the DOM of the main window (as I suspect that you have
done), and I found that the second div has no nodes, but actually contains
an inner div with a node named 'onclick' whose value is
"window.open('fxpubug.html')", and which has the #text 'TEST'. Is this
what you found.
Are you sure that the click is being received by the correct element?
Should there be the two divs? Is this a bug in Firefox?
To get some traction on this you may need to be very specific about the
expected behaviour.
| Reporter | ||
Comment 6•21 years ago
|
||
Ok. If you try that with MS Internet Explorer it works! Then with firefox
don't.
I have this problem i need to create some DOM element in the opener page from
a popup and be able to open tha same popup with onclick on these new elements.
With Firefox this is impossible because of the bug that i show you.
| Reporter | ||
Comment 7•21 years ago
|
||
The Javascript is correct: I'm sure! Only the window.open fails, all other js
function works great and SURE the only function that fail with new created
node is window.open
(In reply to comment #5)
Comment 8•21 years ago
|
||
(In reply to comment #3)
> Mozilla/5.0 (Macintosh; U; PPC Mac OS X Mach-O; en-US; rv:1.8b) Gecko/20050217
> Firefox/1.0+
>
> I have taken the liberty of tweaking your files slightly so that they
> are valid html, videlicet:
>
> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
> "http://www.w3.org/TR/html4/loose.dtd">
> <html>
> <head></head>
> <body>
> <script type="application/x-javascript">
> function addDiv() {
> var el = document.createElement('DIV');
> el.innerHTML = '<div onclick="window.open(\'fxpubug.html\')">TEST<'+'/div>';
> document.body.appendChild(el);
> }
> </script>
> <div onclick="var w = window.open('fxpubug.html'); w.addDiv=addDiv;">TEST</div>
> </body>
> </html>
> ...
If I change
var el = document.createElement('DIV');
to
var el = document.createElement('P');
then the added element is a <p> containing a <div> with an onclick handler.
The DOM inspector shows this very clearly. The <div> seems not to receive
clicks, as though they were absorbed by the containing <p>.
Are you sure that innerHTML is the way to go?
Comment 9•21 years ago
|
||
(In reply to comment #6)
> ...
> I have this problem i need to create some DOM element in the opener page from
> a popup and be able to open tha same popup with onclick on these new elements.
Bugzilla is primarily for people who are identifying and fixing bugs
in Firefox.
User support can be found at these links:
http://forums.mozillazine.org/viewtopic.php?t=106431
http://forums.mozillazine.org/viewforum.php?f=38
| Reporter | ||
Comment 10•21 years ago
|
||
(In reply to comment #9)
I know that and I tell you of this bug, maybe my poor english it's tha
problem, but if you try that js that i Send you you could see bug
Comment 11•21 years ago
|
||
(In reply to comment #7)
> The Javascript is correct: I'm sure!
Take a look at this page in the DOM Inspector:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head></head>
<body>
<script type="application/x-javascript">
function addDiv() {
var el = document.createElement('P');
el.innerHTML = '<div onclick="window.open(\'fxpubug.html\')">TEST<'+'/div>';
document.body.appendChild(el);
}
</script>
<div onclick="var w = window.open('fxpubug.html'); w.addDiv=addDiv;">TEST IN
DIV</div>
<div>
<div onclick="window.open('fxpubug.html')">TEST IN NESTED DIV</div>
</div>
</body>
</html>
It really does seem to be the innerHTML that is associated with the problem.
Do you have any reference material for how this is supposed to work?
| Reporter | ||
Comment 12•21 years ago
|
||
yes you ar right.
if you use
function addDiv() {
var el = document.createElement('P');
el.onclick = new Function(window.open(\'fxpubug.html\')">');
document.body.appendChild(el);
}
it works
the BUG is in window.open in element created with innerHTML
Comment 13•21 years ago
|
||
(In reply to comment #10)
> (In reply to comment #9)
> I know that and I tell you of this bug, maybe it's my poor English
> that is the
> problem,
Not at all. I study carefully what you write, note my misunderstandings
and ask for clarification. Your English is fine for communication
concerning software development.
> but if you try that JS that I sent you, you could the see bug.
I can certainly see the problem, and I am aware of the observed
behaviour, but I don't have a clear mental picture of the expected
behaviour; and more importantly, I don't see where the error
messages in the Javascript Console are coming from, and why you
appear to dismiss them as of no consequence.
To be sure that there is a defect in Firefox, we need to note where
its behaviour deviates from any applicable standard, specification
or design criterion.
| Reporter | ||
Comment 14•21 years ago
|
||
instead of innerHTML try this
var range = document.createRange();
range.setStartBefore(e);
var f = range.createContextualFragment(****HTML fragment****);
e.appendChild(f);
you have the same bug: only if in the HTML fragment you use window.open
function
or try olso this lines
---- FILE 1 -----
<html>
<body>
<script>
function addDiv() {
var el = document.createElement('DIV');
el.innerHTML = '<div onclick="op()">TEST</div>';
document.body.appendChild(el);
}
function op() {
alert('ok');
window.open(\'fxpubug.html\')
}
</script>
<div onclick="var w = op();">TEST</div>
</body>
</html>
---- FILE 2: fxpubug.html -----
<html>
<body>
<script>
function addDiv2() {
window.opener.addDiv();
}
</script>
<div onclick="addDiv2()">ADD DIV IN OPENER</div>
</body>
</html>
you could see that the error is the window.open function when used in
innerHTML or similar
Comment 15•21 years ago
|
||
(In reply to comment #12)
> yes you are right.
It is great when people say that to me. I have a friendship lasting decades
with a gentleman (whose English is far less than yours), sustained
by those words.
Note that you probably know 100 times as much javascript and
maybe twice as much about the DOM as I do.
See http://c2.com/cgi/wiki?CardboardProgrammer . You could have got
the same effect by explaining your problem to a passing stuffed
penguin (or at a pinch a rubber duck - a child's bathtime toy).
This is why I referred you to the forums: You will get better help
there faster than here.
Good luck!
| Reporter | ||
Comment 16•21 years ago
|
||
(In reply to comment #15)
BUT i find A workaround to this bug... YESSSSSSSS :)))) just now :)))
it was obvious
BUT the bug remain, i hope you you solve that in the future!
And I hope in the future that your GREATFULL browser will be able to better
than IE
Is thare a WAY i cuold help you in developing Firefox? I will like do it very
much!
Comment 17•21 years ago
|
||
There could very well be a bug here, depending on the status of innerHTML
support, and how closely Firefox tracks IE.
See
Bug 169429 "window.open fails, when the caller-code of a previous 'open' call is
overwritten"
Bug 49637 "Content of <DIV> isn't updated if JavaScript set innerHTML"
Bug 33577 "[DOM] event's in createContextualFragment"
Comment 18•21 years ago
|
||
(In reply to comment #16)
> (In reply to comment #15)
>
> [ snip ]
>
> Is thare a WAY I could help you in developing Firefox? I will like do it very
> much!
The main point of contact is: http://www.mozilla.org/developer/ just pick
up a role you would like, or tasks that are appropriate.
Comment 19•20 years ago
|
||
Comment 20•20 years ago
|
||
I can confirm that bug. I've created test case attachement zip. Please unpack it
and run index.html.
Then click on "add row from this window" link. A new table row with input
containing "1000" should be created. Then double click on input field - a new
window would be created with "It works". Everything is ok by now.
But now click on "add row from new window" link. A new window would be opened
for a moment, new row would be created and then window closes itself. Newly
created input should contain "2000". Then try to double click on that input. On
JS Console you'll get an error:
B³±d: uncaught exception: [Exception... "Component returned failure code:
0x80004005 (NS_ERROR_FAILURE) [nsIDOMJSWindow.open]" nsresult: "0x80004005
(NS_ERROR_FAILURE)" location: "JS frame :: file:///home/motzel/temp/index.html
:: doIt :: line 17" data: no]
Expected behaviour of double clicking on second input is the same like first one
(new window newpage.html with "It works" should be opened). Moreover, both of
them are created by the same js function: addRow() (from index.html). Difference
is that first one is created by calling function directly from the same file
(index.html) and second one is created by calling function from new window
(add.html) and then new window is closed.
I've done also another test. When I've commented line containing window.close()
in add.html so window is not closed, then switch to main window (without closing
empty opened window) and it works as expected! When I've closed an empty window
it stoped working again.
So now I'm sure what is a problem - every dynamic content created by window that
then has been closed can not use JS window.open() function.
Problem existing in both linux and windows version, even in the newest 1.0.4.
ps. Sorry for my bad english, I'm hope you've understood that. If sth is not
clear I'll try to explain it in other way.
Comment 21•20 years ago
|
||
I also confirm this bug. If code run in a popup, generates dynamic
HTML/javascript in another window, then the newly generted HTML/javascript code
cannot open another popup. In my case the generated HTML/Javascript has an
onclick() handler which tries to call window.open() and gets error 0x80004005. I
tested on Windows 2000 with Firefox 1.0.5 and the bug still exists there.
Comment 22•20 years ago
|
||
This bug also seems to affect JS Alert windows and the "Do you want to close
multiple tabs?" alert when closing FF (neither appear as they should). And the
error is not restricted to JS--clicking on a Flash applet that is designed to
open a new window (i.e. Gameday on MLB.com) fails to work.
This may be related to running Adobe Acrobat 7's plugin; it seems to occur after
I open a PDF (but not always).
I've seen this bug on FF 1.5 Betas 1 and 2. Earlier versions didn't have this
problem.
Error always pulls up failure code 0x80004005 in the JS console, regardless of
whether or not the error involves a popup window, JS alert, or an attempt to
spawn a new window from an SWF file's link.
Comment 23•20 years ago
|
||
The JS console output when closing FF (the multiple tabs warning does not
appear) is
Error: uncaught exception: [Exception... "Component returned failure code:
0x80004005 (NS_ERROR_FAILURE) [nsIPromptService.confirmEx]" nsresult:
"0x80004005 (NS_ERROR_FAILURE)" location: "JS frame ::
chrome://global/content/bindings/tabbrowser.xml :: warnAboutClosingTabs :: line
1134" data: no]
(In reply to comment #22)
> This bug also seems to affect JS Alert windows and the "Do you want to close
> multiple tabs?" alert when closing FF (neither appear as they should). And the
> error is not restricted to JS--clicking on a Flash applet that is designed to
> open a new window (i.e. Gameday on MLB.com) fails to work.
>
> This may be related to running Adobe Acrobat 7's plugin; it seems to occur after
> I open a PDF (but not always).
>
> I've seen this bug on FF 1.5 Betas 1 and 2. Earlier versions didn't have this
> problem.
>
> Error always pulls up failure code 0x80004005 in the JS console, regardless of
> whether or not the error involves a popup window, JS alert, or an attempt to
> spawn a new window from an SWF file's link.
Updated•18 years ago
|
Assignee: bross2 → nobody
Comment 24•18 years ago
|
||
This works for me using Firefox 2.0.0.3 on both Windows XP and Mac OS X 10.4.9. I'm resolving as such. If you still see this bug, please open a new bug and attach the testcase from comment 19 as well as reference this bug.
Status: UNCONFIRMED → RESOLVED
Closed: 18 years ago
Resolution: --- → WORKSFORME
You need to log in
before you can comment on or make changes to this bug.
Description
•