2010-04-02 Andy Estes <aestes@apple.com>
Reviewed by Adam Barth.
Tests for https://bugs.webkit.org/show_bug.cgi?id=37008.
* fast/events/popup-allowed-from-gesture-initiated-event-expected.txt: Added.
* fast/events/popup-allowed-from-gesture-initiated-event.html: Added.
* fast/events/popup-blocked-from-fake-button-click-expected.txt: Added.
* fast/events/popup-blocked-from-fake-button-click.html: Added.
* fast/events/popup-blocked-from-fake-focus-expected.txt: Added.
* fast/events/popup-blocked-from-fake-focus.html: Added.
2010-04-02 Andy Estes <aestes@apple.com>
Reviewed by Adam Barth.
The previous mechanism for testing whether an event was due to a user
gesture only checked the event type, not the source of the event. This
allowed scripts to defeat popup blocking by programatically emitting
certain types of events.
Change the user gesture detection to check for a flag that is only set
when the event in question was generated through the platform and not
through the DOM.
https://bugs.webkit.org/show_bug.cgi?id=37008
Tests: fast/events/popup-allowed-from-gesture-initiated-event.html
fast/events/popup-blocked-from-fake-button-click.html
fast/events/popup-blocked-from-fake-focus.html
* Android.mk: Add UserGestureIndicator.{cpp, h}.
* GNUmakefile.am: Same.
* WebCore.gypi: Same.
* WebCore.pro: Same.
* WebCore.vcproj/WebCore.vcproj: Same.
* WebCore.xcodeproj/project.pbxproj: Same.
* bindings/v8/ScriptController.cpp:
(WebCore::ScriptController::processingUserGesture): Check the value of
UserGesureIndicator::processingUserGesture().
* dom/Document.cpp:
(WebCore::Document::createEvent): Remove call to
Event::setCreatedByDOM().
* dom/Event.cpp:
(WebCore::Event::Event): Remove initializers for m_createdByDOM.
(WebCore::Event::fromUserGesture): Check the value of
UserGestureIndicator::processingUserGesture().
* dom/Event.h: Remove m_createdByDOM.
* dom/UserGestureIndicator.cpp: Added.
(WebCore::UserGestureIndicator::UserGestureIndicator): Save the previous
value of s_processingUserGesture before setting it to true.
(WebCore::UserGestureIndicator::~UserGestureIndicator): Restore
s_processingUserGesture to its previous value.
* dom/UserGestureIndicator.h: Added.
(WebCore::UserGestureIndicator::processingUserGesture): Return the value
of s_processingUserGesture.
* page/EventHandler.cpp:
(WebCore::EventHandler::handleMousePressEvent): Instantiate a
UserGestureIndicator object on the stack to indicate a user gesture is
being processed.
(WebCore::EventHandler::handleMouseDoubleClickEvent): Same.
(WebCore::EventHandler::handleMouseReleaseEvent): Same.
(WebCore::EventHandler::keyEvent): Same.
(WebCore::EventHandler::handleTouchEvent): Same.
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@57045 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebCore/WebCore.pro b/WebCore/WebCore.pro
index eaf97a9..d3aff91 100644
--- a/WebCore/WebCore.pro
+++ b/WebCore/WebCore.pro
@@ -538,6 +538,7 @@
dom/TreeWalker.cpp \
dom/UIEvent.cpp \
dom/UIEventWithKeyState.cpp \
+ dom/UserGestureIndicator.cpp \
dom/WebKitAnimationEvent.cpp \
dom/WebKitTransitionEvent.cpp \
dom/WheelEvent.cpp \
@@ -1250,6 +1251,7 @@
dom/TreeWalker.h \
dom/UIEvent.h \
dom/UIEventWithKeyState.h \
+ dom/UserGestureIndicator.h \
dom/WebKitAnimationEvent.h \
dom/WebKitTransitionEvent.h \
dom/WheelEvent.h \