Commit f23f5741 authored by weinig@apple.com's avatar weinig@apple.com

WebCore:

2009-06-21  Sam Weinig  <sam@webkit.org>

        Reviewed by Eric Seidel

        Fix for https://bugs.webkit.org/show_bug.cgi?id=26578
        event.currentTarget for listener registered on window should point to the window object like in Firefox

        Test: fast/events/event-trace.html

        * dom/Node.cpp:
        (WebCore::Node::dispatchGenericEvent): Make the DOMWindow the currentTarget when events are dispatched
        to it. We previously used the document because DOMWindow was not yet an EventTarget.

LayoutTests:

2009-06-21  Sam Weinig  <sam@webkit.org>

        Reviewed by Eric Seidel.

        Test for https://bugs.webkit.org/show_bug.cgi?id=26578
        event.currentTarget for listener registered on window should point to the window object like in Firefox

        * fast/events/event-trace-expected.txt: Added.
        * fast/events/event-trace.html: Added.



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@44913 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent c8cb8b8a
2009-06-21 Sam Weinig <sam@webkit.org>
Reviewed by Eric Seidel.
Test for https://bugs.webkit.org/show_bug.cgi?id=26578
event.currentTarget for listener registered on window should point to the window object like in Firefox
* fast/events/event-trace-expected.txt: Added.
* fast/events/event-trace.html: Added.
2009-06-21 Dan Bernstein <mitz@apple.com>
Reviewed by Sam Weinig.
......
This tests the target, currentEvent, and phase of a complete trace through event bubbling and capture.
Target = [object HTMLDivElement] (ID: Self); Phase = CAPTURE; CurrentTarget = [object DOMWindow];
Target = [object HTMLDivElement] (ID: Self); Phase = CAPTURE; CurrentTarget = [object HTMLDocument];
Target = [object HTMLDivElement] (ID: Self); Phase = CAPTURE; CurrentTarget = [object HTMLHtmlElement] (ID: HTML);
Target = [object HTMLDivElement] (ID: Self); Phase = CAPTURE; CurrentTarget = [object HTMLBodyElement] (ID: Body);
Target = [object HTMLDivElement] (ID: Self); Phase = CAPTURE; CurrentTarget = [object HTMLDivElement] (ID: Parent);
Target = [object HTMLDivElement] (ID: Self); Phase = AT TARGET; CurrentTarget = [object HTMLDivElement] (ID: Self);
Target = [object HTMLDivElement] (ID: Self); Phase = AT TARGET; CurrentTarget = [object HTMLDivElement] (ID: Self);
Target = [object HTMLDivElement] (ID: Self); Phase = BUBBLE; CurrentTarget = [object HTMLDivElement] (ID: Parent);
Target = [object HTMLDivElement] (ID: Self); Phase = BUBBLE; CurrentTarget = [object HTMLBodyElement] (ID: Body);
Target = [object HTMLDivElement] (ID: Self); Phase = BUBBLE; CurrentTarget = [object HTMLHtmlElement] (ID: HTML);
Target = [object HTMLDivElement] (ID: Self); Phase = BUBBLE; CurrentTarget = [object HTMLDocument];
Target = [object HTMLDivElement] (ID: Self); Phase = BUBBLE; CurrentTarget = [object DOMWindow];
Parent
Self
<html id="HTML">
<body id="Body">
<p>This tests the target, currentEvent, and phase of a complete trace through event bubbling and capture.</p>
<pre id="console"></pre>
<br>
<div id="Parent" style="background-color:lightblue;border:1px solid #000000; padding: 10px; margin: 10px;">
Parent
<div id="Self" style="background-color:blue; border:1px solid black; padding: 10px; margin: 10px;">
Self
</div>
</div>
<script>
if (window.layoutTestController)
layoutTestController.dumpAsText();
function log(msg)
{
document.getElementById('console').appendChild(document.createTextNode(msg + "\n"));
}
function traceEvent(event)
{
function targetString(target)
{
if (target instanceof window.Element)
return target.toString() + " (ID: " + target.id + ")";
return target.toString();
}
function phaseString(eventPhase)
{
if (eventPhase == Event.CAPTURING_PHASE)
return "CAPTURE";
else if (eventPhase == Event.BUBBLING_PHASE)
return "BUBBLE";
else if (eventPhase == Event.AT_TARGET)
return "AT TARGET";
}
var target = targetString(event.target);
var currentTarget = targetString(event.currentTarget);
var phase = phaseString(event.eventPhase);
log("Target = " + target + "; Phase = " + phase + "; CurrentTarget = " + currentTarget + ";");
}
window.addEventListener("customevent", traceEvent, true);
document.addEventListener("customevent", traceEvent, true);
document.getElementById("HTML").addEventListener("customevent", traceEvent, true);
document.getElementById("Body").addEventListener("customevent", traceEvent, true);
document.getElementById("Parent").addEventListener("customevent", traceEvent, true);
document.getElementById("Self").addEventListener("customevent", traceEvent, true);
window.addEventListener("customevent", traceEvent, false);
document.addEventListener("customevent", traceEvent, false);
document.getElementById("HTML").addEventListener("customevent", traceEvent, false);
document.getElementById("Body").addEventListener("customevent", traceEvent, false);
document.getElementById("Parent").addEventListener("customevent", traceEvent, false);
document.getElementById("Self").addEventListener("customevent", traceEvent, false);
var theEvent = document.createEvent("Event");
theEvent.initEvent("customevent", true, true);
document.getElementById("Self").dispatchEvent(theEvent);
</script>
</body>
</html>
2009-06-21 Sam Weinig <sam@webkit.org>
Reviewed by Eric Seidel
Fix for https://bugs.webkit.org/show_bug.cgi?id=26578
event.currentTarget for listener registered on window should point to the window object like in Firefox
Test: fast/events/event-trace.html
* dom/Node.cpp:
(WebCore::Node::dispatchGenericEvent): Make the DOMWindow the currentTarget when events are dispatched
to it. We previously used the document because DOMWindow was not yet an EventTarget.
2009-06-21 Dan Bernstein <mitz@apple.com>
Reviewed by Sam Weinig.
......
......@@ -2492,7 +2492,7 @@ bool Node::dispatchGenericEvent(PassRefPtr<Event> prpEvent)
event->setEventPhase(Event::CAPTURING_PHASE);
if (targetForWindowEvents) {
event->setCurrentTarget(targetForWindowEvents->document()); // FIXME: targetForWindowEvents should be the event target.
event->setCurrentTarget(targetForWindowEvents);
targetForWindowEvents->handleEvent(event.get(), true);
if (event->propagationStopped())
goto doneDispatching;
......@@ -2530,7 +2530,7 @@ bool Node::dispatchGenericEvent(PassRefPtr<Event> prpEvent)
goto doneDispatching;
}
if (targetForWindowEvents) {
event->setCurrentTarget(targetForWindowEvents->document()); // FIXME: targetForWindowEvents should be the event target.
event->setCurrentTarget(targetForWindowEvents);
targetForWindowEvents->handleEvent(event.get(), false);
if (event->propagationStopped() || event->cancelBubble())
goto doneDispatching;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment