2008-04-22 Feng Qian <ian.eng.webkit@gmail.com>
authormrowe@apple.com <mrowe@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 25 Apr 2008 00:47:15 +0000 (00:47 +0000)
committermrowe@apple.com <mrowe@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 25 Apr 2008 00:47:15 +0000 (00:47 +0000)
        Reviewed by Geoff Garen.

        Fix https://bugs.webkit.org/show_bug.cgi?id=18677
        Bug 18677: Synchronous event dispatch confuses the popup blocker into incorrectly blocking chat popups in gmail.com.

        Test: fast/events/nested-window-event.html

        * bindings/js/kjs_events.cpp:
        (WebCore::JSAbstractEventListener::handleEvent): Save and restore the current event around the event dispatch.

2008-04-22  Feng Qian  <ian.eng.webkit@gmail.com>

        Reviewed by Geoff Garen.

        Test for nested event handlers.

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

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

LayoutTests/ChangeLog
LayoutTests/fast/events/nested-window-event-expected.txt [new file with mode: 0644]
LayoutTests/fast/events/nested-window-event.html [new file with mode: 0644]
WebCore/ChangeLog
WebCore/bindings/js/kjs_events.cpp

index 09b8953..e0f6a97 100644 (file)
@@ -1,3 +1,12 @@
+2008-04-22  Feng Qian  <ian.eng.webkit@gmail.com>
+
+        Reviewed by Geoff Garen.
+
+        Test for nested event handlers.
+
+        * fast/events/nested-window-event-expected.txt: Added.
+        * fast/events/nested-window-event.html: Added.
+
 2008-04-24  Dan Bernstein  <mitz@apple.com>
 
         Reviewed by Darin Adler.
diff --git a/LayoutTests/fast/events/nested-window-event-expected.txt b/LayoutTests/fast/events/nested-window-event-expected.txt
new file mode 100644 (file)
index 0000000..9ff69c9
--- /dev/null
@@ -0,0 +1,2 @@
+This tests window.event was kept the same when nested event handling was called. You should see 'PASS' if the test passes. 
+PASS
diff --git a/LayoutTests/fast/events/nested-window-event.html b/LayoutTests/fast/events/nested-window-event.html
new file mode 100644 (file)
index 0000000..1d0db7b
--- /dev/null
@@ -0,0 +1,23 @@
+<html>
+
+<script>
+if (window.layoutTestController)
+  layoutTestController.dumpAsText();
+
+function run_test() {
+  var oldEvent = window.event;
+  var xhr = new XMLHttpRequest();
+  xhr.onreadystatechange = function() {}
+  xhr.open("GET", "test.html");
+  xhr.send();
+  // window.event should exist, and same as oldEvent.
+  document.getElementById('console').innerHTML = oldEvent == window.event ? 'PASS' : 'FAIL';
+}
+</script>
+<body onload="run_test()">
+This tests window.event was kept the same when nested event
+handling was called. You should see 'PASS' if the test passes.
+<br>
+<div id='console'></div>
+</body>
+</html>
index 9341cbb..a567ec9 100644 (file)
@@ -1,3 +1,15 @@
+2008-04-22  Feng Qian  <ian.eng.webkit@gmail.com>
+
+        Reviewed by Geoff Garen.
+
+        Fix https://bugs.webkit.org/show_bug.cgi?id=18677
+        Bug 18677: Synchronous event dispatch confuses the popup blocker into incorrectly blocking chat popups in gmail.com.
+
+        Test: fast/events/nested-window-event.html
+
+        * bindings/js/kjs_events.cpp:
+        (WebCore::JSAbstractEventListener::handleEvent): Save and restore the current event around the event dispatch.
+
 2008-04-24  Brady Eidson  <beidson@apple.com>
 
         Reviewed by Teh Mitzpettel
index cd86898..b21371d 100644 (file)
@@ -83,6 +83,7 @@ void JSAbstractEventListener::handleEvent(Event* ele, bool isWindowEvent)
         List args;
         args.append(toJS(exec, event));
 
+        Event* savedEvent = windowWrapper->window()->currentEvent();
         windowWrapper->window()->setCurrentEvent(event);
 
         JSValue* retval;
@@ -100,7 +101,7 @@ void JSAbstractEventListener::handleEvent(Event* ele, bool isWindowEvent)
         }
         windowWrapper->window()->stopTimeoutCheck();
 
-        windowWrapper->window()->setCurrentEvent(0);
+        windowWrapper->window()->setCurrentEvent(savedEvent);
 
         if (exec->hadException()) {
             JSObject* exception = exec->exception()->toObject(exec);