LayoutTests:
authordarin <darin@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 29 Jan 2006 07:38:33 +0000 (07:38 +0000)
committerdarin <darin@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 29 Jan 2006 07:38:33 +0000 (07:38 +0000)
        Reviewed by Eric.

        - test for http://bugzilla.opendarwin.org/show_bug.cgi?id=6711
          crash if an event is dispatched to a listener that uses handleEvent

        * fast/events/dispatch-to-handle-event.html: Added.
        * fast/events/dispatch-to-handle-event-expected.txt: Added.

WebCore:

        Reviewed by Eric.

        - fix http://bugzilla.opendarwin.org/show_bug.cgi?id=6711
          crash if an event is dispatched to a listener that uses handleEvent

        Test: fast/events/dispatch-to-handle-event.html

        * khtml/ecma/kjs_events.cpp: (KJS::JSAbstractEventListener::handleEvent):
        Remove boolean that is always false, and correct the one place that was
        checking it to check the correct pointer instead.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@12444 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/fast/events/dispatch-to-handle-event-expected.txt [new file with mode: 0644]
LayoutTests/fast/events/dispatch-to-handle-event.html [new file with mode: 0644]
WebCore/ChangeLog
WebCore/khtml/ecma/kjs_events.cpp

index 8989505fd390d513abca350442b6d2bf23a53dd1..05391825f41feec3f2f7e1f17676d75a059ab483 100644 (file)
@@ -1,3 +1,13 @@
+2006-01-28  Darin Adler  <darin@apple.com>
+
+        Reviewed by Eric.
+
+        - test for http://bugzilla.opendarwin.org/show_bug.cgi?id=6711
+          crash if an event is dispatched to a listener that uses handleEvent
+
+        * fast/events/dispatch-to-handle-event.html: Added.
+        * fast/events/dispatch-to-handle-event-expected.txt: Added.
+
 2006-01-28  Mitz Pettel  <opendarwin.org@mitzpettel.com>
 
         Reviewed by Darin.
diff --git a/LayoutTests/fast/events/dispatch-to-handle-event-expected.txt b/LayoutTests/fast/events/dispatch-to-handle-event-expected.txt
new file mode 100644 (file)
index 0000000..5892eb8
--- /dev/null
@@ -0,0 +1,4 @@
+This test creates and sends an event to a handler that's implemented with a handleEvent function. If the test succeeds, there will be text below saying "Received event".
+
+Received event: [object Event]
+
diff --git a/LayoutTests/fast/events/dispatch-to-handle-event.html b/LayoutTests/fast/events/dispatch-to-handle-event.html
new file mode 100644 (file)
index 0000000..da755cb
--- /dev/null
@@ -0,0 +1,27 @@
+<html>
+<head>
+<script>
+
+var handler = new Object;
+handler.handleEvent = function (event) {
+    document.getElementById("console").appendChild(document.createTextNode("Received event: " + event));
+}
+
+function test() {
+    if (window.layoutTestController)
+        layoutTestController.dumpAsText();
+
+    document.addEventListener("event", handler, false);
+    var event = document.createEvent("Event");
+    event.initEvent("event", true, true);
+    document.dispatchEvent(event);
+}
+
+</script>
+
+<body onload="test()">
+<p>This test creates and sends an event to a handler that's implemented with a handleEvent function.
+If the test succeeds, there will be text below saying "Received event".</p>
+<div id="console"></div>
+</body>
+</html>
index ff6ff832f617705befa4df62d8c4fc14d9368a07..e656ded3e04524885f5e1f5c893d38e1fbbb5bfe 100644 (file)
@@ -1,3 +1,16 @@
+2006-01-28  Darin Adler  <darin@apple.com>
+
+        Reviewed by Eric.
+
+        - fix http://bugzilla.opendarwin.org/show_bug.cgi?id=6711
+          crash if an event is dispatched to a listener that uses handleEvent
+
+        Test: fast/events/dispatch-to-handle-event.html
+
+        * khtml/ecma/kjs_events.cpp: (KJS::JSAbstractEventListener::handleEvent):
+        Remove boolean that is always false, and correct the one place that was
+        checking it to check the correct pointer instead.
+
 2006-01-28  Maciej Stachowiak  <mjs@apple.com>
 
         Reviewed by Darin.
index 593e1d6a89adee37f5f29d6bfa8d812c6812f73d..c77c98b64eca565ee6e23864d12e7cc57de93f12 100644 (file)
@@ -77,7 +77,6 @@ void JSAbstractEventListener::handleEvent(EventListenerEvent ele, bool isWindowE
     ScriptInterpreter* interpreter = proxy->interpreter();
     ExecState* exec = interpreter->globalExec();
   
-    bool hasHandleEvent = false;
     JSValue* handleEventFuncValue = listener->get(exec, "handleEvent");
     JSObject* handleEventFunc = 0;
     if (handleEventFuncValue->isObject()) {      
@@ -98,7 +97,7 @@ void JSAbstractEventListener::handleEvent(EventListenerEvent ele, bool isWindowE
         interpreter->setCurrentEvent(event);
       
         JSValue* retval;
-        if (hasHandleEvent)
+        if (handleEventFunc)
             retval = handleEventFunc->call(exec, listener, args);
         else {
             JSObject* thisObj;