Title: [139419] trunk
Revision
139419
Author
[email protected]
Date
2013-01-11 02:07:49 -0800 (Fri, 11 Jan 2013)

Log Message

Connect UserGestureIndicator for mousedown and mouseup events
https://bugs.webkit.org/show_bug.cgi?id=105138

Reviewed by Adam Barth.

Source/WebCore:

Ports that consume user gestures to prevent certain types of pop-ups
need to be able to connect mousedown and mouseup events, otherwise, a
single mouse click will allow for opening multiple pop-ups.

Note that a mousedown is not always followed by a mouseup and vice
versa, e.g. when the mousedown results in a context menu being shown, or
something is dragged into the page.

Test: platform/chromium/fast/events/popup-allowed-from-gesture-only-once-two-events.html

* page/EventHandler.cpp:
(WebCore::EventHandler::clear):
(WebCore::EventHandler::handleMousePressEvent):
(WebCore::EventHandler::handleMouseReleaseEvent):
* page/EventHandler.h:

LayoutTests:

* platform/chromium/fast/events/popup-allowed-from-gesture-only-once-two-events-expected.txt: Added.
* platform/chromium/fast/events/popup-allowed-from-gesture-only-once-two-events.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (139418 => 139419)


--- trunk/LayoutTests/ChangeLog	2013-01-11 10:06:11 UTC (rev 139418)
+++ trunk/LayoutTests/ChangeLog	2013-01-11 10:07:49 UTC (rev 139419)
@@ -1,3 +1,13 @@
+2013-01-11  Jochen Eisinger  <[email protected]>
+
+        Connect UserGestureIndicator for mousedown and mouseup events
+        https://bugs.webkit.org/show_bug.cgi?id=105138
+
+        Reviewed by Adam Barth.
+
+        * platform/chromium/fast/events/popup-allowed-from-gesture-only-once-two-events-expected.txt: Added.
+        * platform/chromium/fast/events/popup-allowed-from-gesture-only-once-two-events.html: Added.
+
 2013-01-11  Eugene Klyuchnikov  <[email protected]>
 
         Web Inspector: [Resources] "Delete" cookie deletes all cookies with matching name.

Added: trunk/LayoutTests/platform/chromium/fast/events/popup-allowed-from-gesture-only-once-two-events-expected.txt (0 => 139419)


--- trunk/LayoutTests/platform/chromium/fast/events/popup-allowed-from-gesture-only-once-two-events-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/platform/chromium/fast/events/popup-allowed-from-gesture-only-once-two-events-expected.txt	2013-01-11 10:07:49 UTC (rev 139419)
@@ -0,0 +1,4 @@
+Test that only a single popup is allowed in response to a single user action, even if the the user action triggers multiple events. The test passes if only one popup is created.
+
+Click Here
+PASSED

Added: trunk/LayoutTests/platform/chromium/fast/events/popup-allowed-from-gesture-only-once-two-events.html (0 => 139419)


--- trunk/LayoutTests/platform/chromium/fast/events/popup-allowed-from-gesture-only-once-two-events.html	                        (rev 0)
+++ trunk/LayoutTests/platform/chromium/fast/events/popup-allowed-from-gesture-only-once-two-events.html	2013-01-11 10:07:49 UTC (rev 139419)
@@ -0,0 +1,45 @@
+<!DOCTYPE html>
+<html> 
+    <body>
+        <p>
+            Test that only a single popup is allowed in response to a single
+            user action, even if the the user action triggers multiple events.
+            The test passes if only one popup is created.
+        </p>
+        <button id="button" _onmousedown_="popup1()" _onmouseup_="popup2()">Click Here</button>
+        <div id="console"></div>
+        <script>
+            function popup1() {
+                window.open("about:blank", "window1");
+            }
+
+            function popup2() {
+                window.open("about:blank", "window2");
+                if (window.testRunner) {
+                    if (testRunner.windowCount() == windowCount + 1)
+                        document.getElementById("console").innerText = "PASSED";
+                    else
+                        document.getElementById("console").innerText = "FAILED";
+                    testRunner.notifyDone();
+                }
+            }
+
+            if (window.testRunner) {
+                testRunner.dumpAsText();
+                testRunner.setCanOpenWindows();
+                testRunner.setPopupBlockingEnabled(true);
+                testRunner.setCloseRemainingWindowsWhenComplete(true);
+                testRunner.waitUntilDone();
+                windowCount = testRunner.windowCount();
+
+                var button = document.getElementById("button");
+
+                if (window.eventSender) {
+                    eventSender.mouseMoveTo(button.offsetLeft + button.offsetWidth / 2, button.offsetTop + button.offsetHeight / 2);
+                    eventSender.mouseDown();
+                    eventSender.mouseUp();
+                }
+            }
+        </script>
+    </body>
+  </html>

Modified: trunk/Source/WebCore/ChangeLog (139418 => 139419)


--- trunk/Source/WebCore/ChangeLog	2013-01-11 10:06:11 UTC (rev 139418)
+++ trunk/Source/WebCore/ChangeLog	2013-01-11 10:07:49 UTC (rev 139419)
@@ -1,3 +1,26 @@
+2013-01-11  Jochen Eisinger  <[email protected]>
+
+        Connect UserGestureIndicator for mousedown and mouseup events
+        https://bugs.webkit.org/show_bug.cgi?id=105138
+
+        Reviewed by Adam Barth.
+
+        Ports that consume user gestures to prevent certain types of pop-ups
+        need to be able to connect mousedown and mouseup events, otherwise, a
+        single mouse click will allow for opening multiple pop-ups.
+
+        Note that a mousedown is not always followed by a mouseup and vice
+        versa, e.g. when the mousedown results in a context menu being shown, or
+        something is dragged into the page.
+
+        Test: platform/chromium/fast/events/popup-allowed-from-gesture-only-once-two-events.html
+
+        * page/EventHandler.cpp:
+        (WebCore::EventHandler::clear):
+        (WebCore::EventHandler::handleMousePressEvent):
+        (WebCore::EventHandler::handleMouseReleaseEvent):
+        * page/EventHandler.h:
+
 2013-01-11  Eugene Klyuchnikov  <[email protected]>
 
         Web Inspector: [Resources] "Delete" cookie deletes all cookies with matching name.

Modified: trunk/Source/WebCore/page/EventHandler.cpp (139418 => 139419)


--- trunk/Source/WebCore/page/EventHandler.cpp	2013-01-11 10:06:11 UTC (rev 139418)
+++ trunk/Source/WebCore/page/EventHandler.cpp	2013-01-11 10:07:49 UTC (rev 139419)
@@ -82,7 +82,6 @@
 #include "StyleCachedImage.h"
 #include "TextEvent.h"
 #include "TextIterator.h"
-#include "UserGestureIndicator.h"
 #include "UserTypingGestureIndicator.h"
 #include "WheelEvent.h"
 #include "WindowsKeyboardCodes.h"
@@ -383,6 +382,7 @@
     m_mousePositionIsUnknown = true;
     m_lastKnownMousePosition = IntPoint();
     m_lastKnownMouseGlobalPosition = IntPoint();
+    m_lastMouseDownUserGestureToken.clear();
     m_mousePressNode = 0;
     m_mousePressed = false;
     m_capturesDragging = false;
@@ -1422,6 +1422,7 @@
 #endif
 
     UserGestureIndicator gestureIndicator(DefinitelyProcessingUserGesture);
+    m_lastMouseDownUserGestureToken = gestureIndicator.currentToken();
 
     // FIXME (bug 68185): this call should be made at another abstraction layer
     m_frame->loader()->resetMultipleFormSubmissionProtection();
@@ -1766,8 +1767,13 @@
         return true;
 #endif
 
-    UserGestureIndicator gestureIndicator(DefinitelyProcessingUserGesture);
+    OwnPtr<UserGestureIndicator> gestureIndicator;
 
+    if (m_lastMouseDownUserGestureToken)
+        gestureIndicator = adoptPtr(new UserGestureIndicator(m_lastMouseDownUserGestureToken.release()));
+    else
+        gestureIndicator = adoptPtr(new UserGestureIndicator(DefinitelyProcessingUserGesture));
+
 #if ENABLE(PAN_SCROLLING)
     m_autoscrollController->handleMouseReleaseEvent(mouseEvent);
 #endif

Modified: trunk/Source/WebCore/page/EventHandler.h (139418 => 139419)


--- trunk/Source/WebCore/page/EventHandler.h	2013-01-11 10:06:11 UTC (rev 139418)
+++ trunk/Source/WebCore/page/EventHandler.h	2013-01-11 10:07:49 UTC (rev 139419)
@@ -37,6 +37,7 @@
 #include "TextEventInputType.h"
 #include "TextGranularity.h"
 #include "Timer.h"
+#include "UserGestureIndicator.h"
 #include <wtf/Forward.h>
 #include <wtf/OwnPtr.h>
 #include <wtf/RefPtr.h>
@@ -445,6 +446,7 @@
     IntPoint m_mouseDownPos; // In our view's coords.
     double m_mouseDownTimestamp;
     PlatformMouseEvent m_mouseDown;
+    RefPtr<UserGestureIndicator::Token> m_lastMouseDownUserGestureToken;
 
     RefPtr<Node> m_latchedWheelEventNode;
     bool m_widgetIsLatched;
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to