Open
Bug 362340
Opened 19 years ago
Updated 3 years ago
error event handler in invisible frames is not called
Categories
(Core :: DOM: Events, defect, P5)
Tracking
()
NEW
People
(Reporter: jwkbugzilla, Unassigned)
Details
Attachments
(2 files)
|
332 bytes,
text/html
|
Details | |
|
1.78 KB,
patch
|
jst
:
review+
jst
:
superreview+
|
Details | Diff | Splinter Review |
If I load a document into a hidden frame (display:none) the JavaScript executes correctly. However, if this frame has window.onerror defined this handler never gets called. Making the frame visible fixes the problem.
This came up when writing a testcase for bug 252326.
| Reporter | ||
Comment 1•19 years ago
|
||
Open this testcase. If you don't see an alert message pop up then the error handler hasn't been triggered. Removing "display:none" from the frame fixes it. Tested in:
Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9a1) Gecko/20061117 Minefield/3.0a1
Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1) Gecko/20061010 Firefox/2.0
| Reporter | ||
Comment 2•19 years ago
|
||
Found the reason for this behavior. Script errors are handled by the function NS_ScriptErrorReporter in nsJSEnvironment.cpp which requires a valid presContext to dispatch the event. In the case of an invisible iframe the presContext is null.
Comment 3•19 years ago
|
||
PresContext shouldn't be needed, I think.
Wladimir, will you post a patch? If not, assign this bug to me.
| Reporter | ||
Comment 4•19 years ago
|
||
Yes, I also cannot see why we depend on presContext here. I looked and there is in fact some code calling nsEventDispatcher::Dispatch without checking the presContext parameter first (there is some other code that does - these event probably won't be delivered in invisible frames either). I tried removing the presContext check and it fixed the problem for me without causing any obvious problems. I don't know the implications of this change however, maybe jst can tell...
Attachment #247071 -
Flags: review?(jst)
Comment 5•19 years ago
|
||
Comment on attachment 247071 [details] [diff] [review]
Possible solution
There shouldn't be need to get the prescontext from docshell at all, so you could simplify the code even more.
| Reporter | ||
Comment 6•19 years ago
|
||
Smaug, I don't know what this presContext is used for so I better wait for jst's comments. There is at the very least the possibility now to make NS_ScriptErrorReporter use NS_HandleScriptError as suggested in the comment before the function - the only concern isn't any more with this change.
The other code that checks presContext before dispatching events does in fact show the same behavior. Invisible frames don't receive DOMFrameContentLoaded events (nsDocument::DispatchContentLoadedEvents) and HTMLInputElement.click() in invisible frames doesn't create click events (nsHTMLInputElement::Click). I have testcases, can attach them here if requested. There is probably more of this but I don't have time right now to check everything.
Comment 7•19 years ago
|
||
Comment on attachment 247071 [details] [diff] [review]
Possible solution
Yeah, this is what we want. AFAIK event dispatch is always ok to do even if there is no pres shell/context around.
r+sr=jst
Attachment #247071 -
Flags: superreview+
Attachment #247071 -
Flags: review?(jst)
Attachment #247071 -
Flags: review+
Comment 8•19 years ago
|
||
but :
> There shouldn't be need to get the prescontext from docshell at
> all, so you
> could simplify the code even more.
Updated•16 years ago
|
Assignee: events → nobody
QA Contact: ian → events
Comment 9•15 years ago
|
||
Dup of bug #598438 ?
| Reporter | ||
Comment 10•15 years ago
|
||
How so? These two bugs seem unrelated to me.
Ouch, I left a reviewed patch bitrot here for four years...
Comment 11•15 years ago
|
||
Oups, yes, very old one. But invisible frames /iframes ... sounded similar?
At least I reminded you about this one ;)
Comment 12•7 years ago
|
||
https://bugzilla.mozilla.org/show_bug.cgi?id=1472046
Move all DOM bugs that haven’t been updated in more than 3 years and has no one currently assigned to P5.
If you have questions, please contact :mdaly.
Priority: -- → P5
Updated•3 years ago
|
Severity: normal → S3
You need to log in
before you can comment on or make changes to this bug.
Description
•