Closed Bug 603535 Opened 15 years ago Closed 15 years ago

nsIEventListenerService.getEventTargetChainFor failure on TM nightly

Categories

(Core :: XPConnect, defect)

x86
Windows 7
defect
Not set
normal

Tracking

()

RESOLVED FIXED
Tracking Status
blocking2.0 --- final+

People

(Reporter: Felipe, Assigned: smaug)

References

Details

(Keywords: regression)

Attachments

(1 file)

Using bsmedberg's "AeroWindowTitle" add-on (https://addons.mozilla.org/en-US/firefox/addon/221514/) on latest TM nightly (20101011), I get the following exception on the error console: Error: uncaught exception: [Exception... "Component returned failure code: 0x80004005 (NS_ERROR_FAILURE) [nsIEventListenerService.getEventTargetChainFor]" nsresult: "0x80004005 (NS_ERROR_FAILURE)" location: "JS frame :: jar:file:///C:/Users/Felipe/AppData/Roaming/Mozilla/Firefox/Profiles/zb2xkbgt.default/extensions/aero-window-title@benjamin.smedbergs.us.xpi!/aero-overlay.xul :: anonymous :: line 111" data: no] That line in question from aero-overlay.xul is: 109 var els = Components.classes["@mozilla.org/eventlistenerservice;1"]. 110 getService(Components.interfaces.nsIEventListenerService); 111 var lastListener = els.getEventTargetChainFor(window).pop(). 112 QueryInterface(Components.interfaces.nsIDOMNSEventTarget);
blocking2.0: --- → ?
blocking2.0: ? → final+
Keywords: regression
In nsEventListenerService::GetEventTargetChainFor, we call nsEventDispatcher::Dispatch. This does: 542 if (!targetEtci->IsValid()) { 543 nsEventTargetChainItem::Destroy(pool.GetPool(), targetEtci); 544 return NS_ERROR_FAILURE; 545 } in our case, IsValid() tests false: targetEtci has a null mTarget. And the reason for that is that is that the event target that got passed to nsEventListenerService::GetEventTargetChainFor is the _inner_ window. So this frame: #1 0x000000010074a75c in nsEventTargetChainItem::nsEventTargetChainItem (this=0x10689d7c0, aTarget=0x11d0b34d8, aChild=0x0) at /Users/bzbarsky/mozilla/tracemonkey/mozilla/content/events/src/nsEventDispatcher.cpp:258 258 mTarget = aTarget->GetTargetForEventTargetChain(); which calls this: #0 nsGlobalWindow::GetTargetForEventTargetChain (this=0x11d0b3450) at nsGlobalWindow.h:376 376 return static_cast<nsPIDOMEventTarget*>(GetCurrentInnerWindowInternal()); ends up setting mTarget to null. Why are we ending up with an inner window here? As a separate question, should GetTargetForEventTargetChain() be made to work on inner windows?
ccing smaug for that last question.
I don't quite understand the question. How is GetTargetForEventTargetChain() not working atm?
Ah, I see.
(In reply to comment #1) > > ends up setting mTarget to null. > Why are we ending up with an inner window here? However, this is more interesting question.
>> Why are we ending up with an inner window here? >However, this is more interesting question. Sure; that was the actual behavior change. ;)
This is one of the changes that was required for brain transplants. Because we don't have an XPCWrappedNative for the outer window anymore, we can't pass the outer window when we're passed 'window' from JS. This means that places that depend on having an outer window need to outerize at some point (at the same time, they can assume that they get an inner window).
So when should we use inner window and when outer? I'm don't know how "brain transplants" work. Currently inner window is used when creating event target chain, but event.target/.currentTarget etc. return the outer window.
That part is all fine. What Blake is saying is that any time a Window is passed from JS into C++ via XPConnect what you will end up with on the C++ side is the inner window. It used to be the outer window before he brain transplants change. So now the argument to GetEventTargetChainFor is an inner window, not an outer one, and the inner window ends up getting passed to Dispatch(). The event code right now works only if the target passed to Dispatch() is either not a window or is an outer window. Blake, is there no way we can change xpconnect unwrapping to preserve the old behavior? It's easy to fix the event code here, but this change in what window we get is kinda scary...
Summary: nsIEventListenerManager.getEventTargetChainFor failure on TM nightly → nsIEventListenerService.getEventTargetChainFor failure on TM nightly
Attached patch patchSplinter Review
So does this fix the problem?
Comment on attachment 482926 [details] [diff] [review] patch Where should this patch land? To TM? If so, could someone who has TM branch locally land it there.
Attachment #482926 - Flags: review?(mrbkap)
I guess I could land this to m-c.
oops, this wasn't reviewed yet :)
Attachment #482926 - Flags: review?(mrbkap) → review+
Status: NEW → RESOLVED
Closed: 15 years ago
Resolution: --- → FIXED
Blocks: 580128
Assignee: nobody → Olli.Pettay
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: