Closed Bug 342235 Opened 19 years ago Closed 19 years ago

[FIX]XBL method trying to use event parameter gets exception

Categories

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

defect

Tracking

()

RESOLVED FIXED
mozilla1.9alpha1

People

(Reporter: aaronr, Assigned: bzbarsky)

References

Details

(Keywords: regression)

Attachments

(3 files)

The attached testcase doesn't work on trunk but works in Firefox 1.5.0.5 nightly. I get the following in the java script console: "Error: uncaught exception: Permission denied to get property MouseEvent.originalTarget". If I had to guess, I'd say that it just broke within the last week. The immediate impact is that this bug is killing some of the controls in the XForms extension. I've looked at this a little and if you try to get the event.originalTarget using a method that is set directly as the onclick handler on the DOM element, it works fine. It also works fine if it is used in a click handler using xbl:handler. The issue seems to be with an anonymous content element passing the event to a xbl:method.
Attached file testcase
I can first time see this bug in 2006-06-13 nightlies. Perhaps Bug 255942 or Bug 176182
Flags: blocking1.9a1?
Keywords: regression
Attached file simpler testcase
So for some reason anonymous content can't access any properties of the event.
So when we get into nsScriptSecurityManager::CheckSameOriginDOMProp (called from nsScriptSecurityManager::CheckPropertyAccessImpl), the subject principal is the principal of the page, as expected, but the object principal is the hidden window's principal. So it looks like we're wrapping the event in the wrong scope or something....
Flags: blocking1.9a1? → blocking1.9a1+
So what _used_ to happen is that in nsJSEventListener::HandleEvent we'd do: rv = xpc->WrapNative(cx, obj, aEvent, NS_GET_IID(nsIDOMEvent), getter_AddRefs(wrapper)); where |obj| was the JSObject for the target. Now what we do instead is: rv = mContext->CallEventHandler(mTarget, mScopeObject, funcval, iargv, getter_AddRefs(vrv)); and CallEventHandler does: rv = ConvertSupportsTojsvals(aargv, aScope, &argc, NS_REINTERPRET_CAST(void **, &argv), &mark); I suspect that the latter call should pass |target| instead of aScope.
Yeah, that fixes it.
Assignee: general → general
Component: XBL → DOM
OS: Windows XP → All
Priority: -- → P1
Hardware: PC → All
Summary: XBL method trying to use event parameter gets exception → [FIX]XBL method trying to use event parameter gets exception
Target Milestone: --- → mozilla1.9alpha
Attached patch Like soSplinter Review
Assignee: general → bzbarsky
Status: NEW → ASSIGNED
Attachment #226497 - Flags: superreview?(jst)
Attachment #226497 - Flags: review?(mhammond)
Comment on attachment 226497 [details] [diff] [review] Like so sr=jst
Attachment #226497 - Flags: superreview?(jst) → superreview+
Attachment #226497 - Flags: superreview?(jst)
Attachment #226497 - Flags: superreview+
Attachment #226497 - Flags: review?(mhammond)
Attachment #226497 - Flags: review+
Comment on attachment 226497 [details] [diff] [review] Like so Er, I screwed up the review flags, but whatever. r+sr=jst for this, even.
Attachment #226497 - Flags: superreview?(jst) → superreview+
Ugh, bugzilla conflict handling screwup between my and Mark's reviews. Oh well.
Fixed.
Status: ASSIGNED → RESOLVED
Closed: 19 years ago
Resolution: --- → FIXED
Component: DOM → DOM: Core & HTML
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: