Bug 26578

Summary: event.currentTarget for listener registered on window should point to the window object like in Firefox
Product: WebKit Reporter: Michael A. Puls II <shadow2531>
Component: DOMAssignee: Sam Weinig <sam>
Status: RESOLVED FIXED    
Severity: Normal CC: ap, arv
Priority: P2 Keywords: EasyFix
Version: 528+ (Nightly build)   
Hardware: PC   
OS: Windows XP   
Attachments:
Description Flags
TC that uses the 'input' event
none
patch eric: review+

Description Michael A. Puls II 2009-06-20 18:13:31 PDT
Safari 4 530.17 with WebKit-r44837

When you register an event listener on the window object, event.currentTarget and 'this' in the callback function should point to the window object. In Firefox, this is true. In Safari, 'this' points to the window, but event.currentTarget points to the document instead. In Opera, they both point to the document.

Firefox's behavior makes the most sense to me.

I asked for clarification at <http://lists.w3.org/Archives/Public/public-html/2009Jun/0566.html>.

This affect the 'input' and 'change' events for example.
Comment 1 Michael A. Puls II 2009-06-20 18:14:07 PDT
Created attachment 31604 [details]
TC that uses the 'input' event
Comment 2 Sam Weinig 2009-06-20 19:02:26 PDT
This is possible now that DOMWindow inherits from EventTarget.  The fix should be in Node.cpp:

2487:        event->setCurrentTarget(targetForWindowEvents->document()); // FIXME: targetForWindowEvents should be the event target.
 
2525:            event->setCurrentTarget(targetForWindowEvents->document()); // FIXME: targetForWindowEvents should be the event target.

Comment 3 Sam Weinig 2009-06-21 13:28:44 PDT
Created attachment 31619 [details]
patch
Comment 4 Eric Seidel (no email) 2009-06-21 13:30:44 PDT
Comment on attachment 31619 [details]
patch

Looks good.
Comment 5 Sam Weinig 2009-06-21 13:48:40 PDT
Fixed in r44913.