Improve how UI events are dispatched by WebKitTestRunner
authorap@apple.com <ap@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 21 Aug 2015 23:09:54 +0000 (23:09 +0000)
committerap@apple.com <ap@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 21 Aug 2015 23:09:54 +0000 (23:09 +0000)
commit0ca13807b666475a251d1284d4a007a06851200d
treec009fa3545c6daa44bd6355bcc894f3c05c7e11b
parentb5e33adde22e121085bd06f29ac29a76e2746c2c
Improve how UI events are dispatched by WebKitTestRunner
https://bugs.webkit.org/show_bug.cgi?id=148326

Reviewed by Anders Carlsson.

Source/WebKit2:

Added "fully synchronous mode for testing", in which all messages are dispatched
synchronously.

When an async message is sent in this mode, it is wrapped into a sync one automatically.

A client must opt in, either by using WKBundlePagePostSynchronousMessageForTesting(),
or by calling WKContextConfigurationAllowFullySynchronousModeForTesting().
This makes sure that we don't increase potential for IPC misuse.

* WebProcess/WebPage/WebPage.messages.in: Yay, fewer messages!

* UIProcess/API/C/WKPage.cpp:
(WKPageSetShouldSendEventsSynchronously): Deleted.
* UIProcess/API/C/WKPagePrivate.h:
We no longer need WKPageSetShouldSendEventsSynchronously and associated custom messages.

* WebProcess/WebPage/EventDispatcher.cpp:
(WebKit::EventDispatcher::wheelEvent):
(WebKit::updateWheelEventTestTriggersIfNeeded): Deleted.
Removed code that was only needed to support pseudo-syncronous scrolling in tests.

* Platform/IPC/Connection.cpp:
(IPC::Connection::sendMessage):
(IPC::Connection::dispatchSyncMessage):
(IPC::Connection::dispatchMessage):
* Platform/IPC/Connection.h:
(IPC::Connection::allowFullySynchronousModeForTesting):
(IPC::Connection::sendSync):
* Platform/IPC/MessageDecoder.cpp:
(IPC::MessageDecoder::shouldDispatchMessageWhenWaitingForSyncReply):
(IPC::MessageDecoder::shouldUseFullySynchronousModeForTesting):
(IPC::MessageDecoder::setImportanceAssertion):
(IPC::MessageDecoder::unwrapForTesting):
* Platform/IPC/MessageDecoder.h:
(IPC::MessageDecoder::UUID):
* Platform/IPC/MessageEncoder.cpp:
(IPC::MessageEncoder::setShouldDispatchMessageWhenWaitingForSyncReply):
(IPC::MessageEncoder::setFullySynchronousModeForTesting):
(IPC::MessageEncoder::wrapForTesting):
* Platform/IPC/MessageEncoder.h:
(IPC::MessageEncoder::UUID):
* Platform/IPC/MessageFlags.h:
* UIProcess/API/APIProcessPoolConfiguration.cpp:
(API::ProcessPoolConfiguration::copy):
* UIProcess/API/APIProcessPoolConfiguration.h:
* UIProcess/API/C/WKContextConfigurationRef.cpp:
(WKContextConfigurationSetMediaKeysStorageDirectory):
(WKContextConfigurationAllowFullySynchronousModeForTesting):
* UIProcess/API/C/WKContextConfigurationRef.h:

* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::WebPageProxy):
(WebKit::WebPageProxy::handleMouseEvent):
(WebKit::WebPageProxy::sendWheelEvent):
(WebKit::WebPageProxy::handleKeyboardEvent):
(WebKit::WebPageProxy::handleTouchEvent):
* UIProcess/WebPageProxy.h:
(WebKit::WebPageProxy::renderTreeSize):
(WebKit::WebPageProxy::setShouldSendEventsSynchronously): Deleted.
* UIProcess/WebProcessPool.cpp:
(WebKit::WebProcessPool::processDidFinishLaunching):
* WebProcess/InjectedBundle/API/c/WKBundlePage.cpp:
(WKBundlePagePostMessage):
(WKBundlePagePostSynchronousMessageForTesting):
(WKBundlePagePostSynchronousMessage): Deleted.
* WebProcess/InjectedBundle/API/c/WKBundlePage.h:
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::mouseEvent):
(WebKit::handleWheelEvent):
(WebKit::WebPage::wheelEvent):
(WebKit::handleKeyEvent):
(WebKit::WebPage::keyEvent):
(WebKit::WebPage::validateCommand):
(WebKit::WebPage::touchEvent):
(WebKit::WebPage::scroll):
(WebKit::WebPage::postMessage):
(WebKit::WebPage::postSynchronousMessageForTesting):
(WebKit::WebPage::mouseEventSyncForTesting): Deleted.
(WebKit::WebPage::wheelEventSyncForTesting): Deleted.
(WebKit::WebPage::keyEventSyncForTesting): Deleted.
(WebKit::WebPage::touchEventSyncForTesting): Deleted.
(WebKit::WebPage::postSynchronousMessage): Deleted.
* WebProcess/WebPage/WebPage.h:

Tools:

* WebKitTestRunner/InjectedBundle/Bindings/EventSendingController.idl:
* WebKitTestRunner/InjectedBundle/EventSendingController.h:
Removed asyncScrolling from mouseScrollByWithWheelAndMomentumPhases, it's now always
asynchronous (and really, it has always been for the most part).

* WebKitTestRunner/InjectedBundle/EventSendingController.cpp:
(WTR::EventSendingController::mouseDown): Updated for WKBundlePagePostSynchronousMessage renaming.
(WTR::EventSendingController::mouseUp): Ditto.
(WTR::EventSendingController::mouseMoveTo): Ditto.
(WTR::EventSendingController::mouseForceDown): Ditto.
(WTR::EventSendingController::mouseForceUp): Ditto.
(WTR::EventSendingController::mouseForceChanged): Ditto.
(WTR::EventSendingController::leapForward): Ditto.
(WTR::EventSendingController::scheduleAsynchronousClick): Ditto.
(WTR::EventSendingController::keyDown): Ditto.
(WTR::EventSendingController::scheduleAsynchronousKeyDown): Ditto.
(WTR::EventSendingController::mouseScrollBy): Force a scrolling tree commit. It used
to be done in custom WebKit2 code for test wheel event handling.
(WTR::EventSendingController::mouseScrollByWithWheelAndMomentumPhases): Got rid of sync version.
(WTR::EventSendingController::continuousMouseScrollBy): Added a FIXME. This one is weird.
(WTR::EventSendingController::contextClick): Updated for WKBundlePagePostSynchronousMessage renaming.
(WTR::EventSendingController::addTouchPoint): Ditto.
(WTR::EventSendingController::updateTouchPoint): Ditto.
(WTR::EventSendingController::setTouchModifier): Ditto.
(WTR::EventSendingController::setTouchPointRadius): Ditto.
(WTR::EventSendingController::touchStart): Ditto.
(WTR::EventSendingController::touchMove): Ditto.
(WTR::EventSendingController::touchEnd): Ditto.
(WTR::EventSendingController::touchCancel): Ditto.
(WTR::EventSendingController::clearTouchPoints): Ditto.
(WTR::EventSendingController::releaseTouchPoint): Ditto.
(WTR::EventSendingController::cancelTouchPoint): Ditto.

* WebKitTestRunner/InjectedBundle/InjectedBundle.cpp:
(WTR::InjectedBundle::postSetWindowIsKey):
(WTR::InjectedBundle::postSimulateWebNotificationClick):
(WTR::InjectedBundle::isGeolocationProviderActive):
(WTR::InjectedBundle::shouldProcessWorkQueue):
Updated for WKBundlePagePostSynchronousMessage renaming.

* WebKitTestRunner/InjectedBundle/TestRunner.cpp:
(WTR::TestRunner::secureEventInputIsEnabled): Ditto.

* WebKitTestRunner/TestController.cpp:
(WTR::TestController::initialize): Allow handling the new test style messages.
(WTR::TestController::didReceiveKeyDownMessageFromInjectedBundle): Removed calls
to WKPageSetShouldSendEventsSynchronously, which we no longer need.
(WTR::TestController::didReceiveMessageFromInjectedBundle):
(WTR::TestController::didReceiveSynchronousMessageFromInjectedBundle): Moved
"MouseScrollBy" to async section, and got rid of WKPageSetShouldSendEventsSynchronously.

* WebKitTestRunner/mac/EventSenderProxy.mm:
(WTR::EventSenderProxy::mouseMoveTo): Got rid of WKPageSetShouldSendEventsSynchronously.
(WTR::EventSenderProxy::keyDown): Ditto.
(WTR::EventSenderProxy::mouseScrollBy): Ditto.
(WTR::EventSenderProxy::mouseScrollByWithWheelAndMomentumPhases): Ditto.

LayoutTests:

* fast/events/clear-drag-state-expected.txt:
* fast/events/clear-drag-state.html:
* platform/mac-wk2/TestExpectations:
This test used to accidentally pass in WebKit2, but it didn't actually check
for the problem. This patch improves WK2 behavior, which makes the test fail.
Changed the test to not pass accidentally, and added it to WK2 test expectations.

* fast/events/scroll-in-scaled-page-with-overflow-hidden-expected.txt:
* fast/events/scroll-in-scaled-page-with-overflow-hidden.html:
Updated the test to be fully async.

* fast/events/wheelevent-basic-expected.txt:
* fast/events/wheelevent-basic.html:
Updated the test to be fully async, got rid of tab characters.

* fast/events/wheelevent-mousewheel-interaction.html:
* fast/forms/search/search-scroll-hidden-decoration-container-crash.html:
* fast/frames/flattening/scrolling-in-object.html:
Updated these tests to be fully async. Since they check for something that happens
asynchronously, and doesn't have an end event, they have to use setTimeout.

* fast/scrolling/latching/iframe_in_iframe.html:
* fast/scrolling/latching/scroll-div-latched-div.html:
* fast/scrolling/latching/scroll-div-latched-mainframe.html:
* fast/scrolling/latching/scroll-div-no-latching.html:
* fast/scrolling/latching/scroll-div-with-nested-nonscrollable-iframe.html:
* fast/scrolling/latching/scroll-iframe-fragment.html:
* fast/scrolling/latching/scroll-iframe-latched-iframe.html:
* fast/scrolling/latching/scroll-iframe-latched-mainframe.html:
* fast/scrolling/latching/scroll-iframe-webkit1-latching-bug.html:
* fast/scrolling/latching/scroll-latched-nested-div.html:
* fast/scrolling/latching/scroll-nested-iframe.html:
* fast/scrolling/latching/scroll-select-bottom-test.html:
* fast/scrolling/latching/scroll-select-latched-mainframe.html:
* fast/scrolling/latching/scroll-select-latched-select.html:
Removed extra testRunner.mouseScrollByWithWheelAndMomentumPhases() calls.
We no longer need multiple events for scroll snap animation to start, and due to
the way we coalesce events, having multiple events resulted in getting too high velocity.
Removed async scrolling argument form the function calls, because it's now always async.

* platform/mac-wk1/TestExpectations:
* platform/mac/TestExpectations:
Moved fast/scrolling/latching/scroll-div-with-nested-nonscrollable-iframe.html
to WK1 expectations, because the test needn't be skipped on WK2.

* scrollbars/scroll-rtl-or-bt-layer.html: Made the test fully async, and refactored
it for clarity.

* tiled-drawing/scrolling/fast-scroll-div-latched-div-with-handler.html:
* tiled-drawing/scrolling/fast-scroll-div-latched-div.html:
* tiled-drawing/scrolling/fast-scroll-div-latched-mainframe-with-handler.html:
* tiled-drawing/scrolling/fast-scroll-div-latched-mainframe.html:
* tiled-drawing/scrolling/fast-scroll-iframe-latched-iframe-with-handler.html:
* tiled-drawing/scrolling/fast-scroll-iframe-latched-iframe.html:
* tiled-drawing/scrolling/fast-scroll-iframe-latched-mainframe-with-handler.html:
* tiled-drawing/scrolling/fast-scroll-iframe-latched-mainframe.html:
* tiled-drawing/scrolling/fast-scroll-iframe-latched-select.html:
* tiled-drawing/scrolling/fast-scroll-mainframe-zoom.html:
* tiled-drawing/scrolling/fast-scroll-select-latched-mainframe-with-handler.html:
* tiled-drawing/scrolling/fast-scroll-select-latched-mainframe.html:
* tiled-drawing/scrolling/fast-scroll-select-latched-select.html:
* tiled-drawing/scrolling/iframe_in_iframe.html:
* tiled-drawing/scrolling/overflow-scroll-reduced-content.html:
* tiled-drawing/scrolling/overflow-scroll-zero-delta-wheel-events.html:
* tiled-drawing/scrolling/root-overflow-with-mousewheel.html:
* tiled-drawing/scrolling/scroll-snap/scroll-snap-iframe.html:
* tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-2d-overflow.html:
* tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-borders.html:
* tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-mainframe-horizontal.html:
* tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-mainframe-slow-horizontal.html:
* tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-mainframe-slow-vertical.html:
* tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-mainframe-vertical.html:
* tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-overflow-stateless.html:
* tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-overflow.html:
* tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-padding.html:
* tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-rotated.html:
* tiled-drawing/scrolling/wheel-events-with-no-delta.html:
Same testRunner.mouseScrollByWithWheelAndMomentumPhases changes as in fast/scrolling/latching.

* tiled-drawing/scrolling/fast-scroll-select-latched-select-with-handler-expected.txt:
* tiled-drawing/scrolling/fast-scroll-select-latched-select-with-handler.html:
Removed debug output about how many events are received. The number may vary due
to coalescing.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@188793 268f45cc-cd09-0410-ab3c-d52691b4dbfc
90 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/events/clear-drag-state-expected.txt
LayoutTests/fast/events/clear-drag-state.html
LayoutTests/fast/events/scroll-in-scaled-page-with-overflow-hidden-expected.txt
LayoutTests/fast/events/scroll-in-scaled-page-with-overflow-hidden.html
LayoutTests/fast/events/wheelevent-basic-expected.txt
LayoutTests/fast/events/wheelevent-basic.html
LayoutTests/fast/events/wheelevent-mousewheel-interaction.html
LayoutTests/fast/forms/search/search-scroll-hidden-decoration-container-crash.html
LayoutTests/fast/frames/flattening/scrolling-in-object.html
LayoutTests/fast/scrolling/latching/iframe_in_iframe.html
LayoutTests/fast/scrolling/latching/scroll-div-latched-div.html
LayoutTests/fast/scrolling/latching/scroll-div-latched-mainframe.html
LayoutTests/fast/scrolling/latching/scroll-div-no-latching.html
LayoutTests/fast/scrolling/latching/scroll-div-with-nested-nonscrollable-iframe.html
LayoutTests/fast/scrolling/latching/scroll-iframe-fragment.html
LayoutTests/fast/scrolling/latching/scroll-iframe-latched-iframe.html
LayoutTests/fast/scrolling/latching/scroll-iframe-latched-mainframe.html
LayoutTests/fast/scrolling/latching/scroll-iframe-webkit1-latching-bug.html
LayoutTests/fast/scrolling/latching/scroll-latched-nested-div.html
LayoutTests/fast/scrolling/latching/scroll-nested-iframe.html
LayoutTests/fast/scrolling/latching/scroll-select-bottom-test.html
LayoutTests/fast/scrolling/latching/scroll-select-latched-mainframe.html
LayoutTests/fast/scrolling/latching/scroll-select-latched-select.html
LayoutTests/platform/mac-wk1/TestExpectations
LayoutTests/platform/mac-wk2/TestExpectations
LayoutTests/platform/mac/TestExpectations
LayoutTests/scrollbars/scroll-rtl-or-bt-layer.html
LayoutTests/tiled-drawing/scrolling/fast-scroll-div-latched-div-with-handler.html
LayoutTests/tiled-drawing/scrolling/fast-scroll-div-latched-div.html
LayoutTests/tiled-drawing/scrolling/fast-scroll-div-latched-mainframe-with-handler.html
LayoutTests/tiled-drawing/scrolling/fast-scroll-div-latched-mainframe.html
LayoutTests/tiled-drawing/scrolling/fast-scroll-iframe-latched-iframe-with-handler.html
LayoutTests/tiled-drawing/scrolling/fast-scroll-iframe-latched-iframe.html
LayoutTests/tiled-drawing/scrolling/fast-scroll-iframe-latched-mainframe-with-handler.html
LayoutTests/tiled-drawing/scrolling/fast-scroll-iframe-latched-mainframe.html
LayoutTests/tiled-drawing/scrolling/fast-scroll-iframe-latched-select.html
LayoutTests/tiled-drawing/scrolling/fast-scroll-mainframe-zoom.html
LayoutTests/tiled-drawing/scrolling/fast-scroll-select-latched-mainframe-with-handler.html
LayoutTests/tiled-drawing/scrolling/fast-scroll-select-latched-mainframe.html
LayoutTests/tiled-drawing/scrolling/fast-scroll-select-latched-select-with-handler-expected.txt
LayoutTests/tiled-drawing/scrolling/fast-scroll-select-latched-select-with-handler.html
LayoutTests/tiled-drawing/scrolling/fast-scroll-select-latched-select.html
LayoutTests/tiled-drawing/scrolling/iframe_in_iframe.html
LayoutTests/tiled-drawing/scrolling/overflow-scroll-reduced-content.html
LayoutTests/tiled-drawing/scrolling/overflow-scroll-zero-delta-wheel-events.html
LayoutTests/tiled-drawing/scrolling/root-overflow-with-mousewheel.html
LayoutTests/tiled-drawing/scrolling/scroll-snap/scroll-snap-iframe.html
LayoutTests/tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-2d-overflow.html
LayoutTests/tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-borders.html
LayoutTests/tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-mainframe-horizontal.html
LayoutTests/tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-mainframe-slow-horizontal.html
LayoutTests/tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-mainframe-slow-vertical.html
LayoutTests/tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-mainframe-vertical.html
LayoutTests/tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-overflow-stateless.html
LayoutTests/tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-overflow.html
LayoutTests/tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-padding.html
LayoutTests/tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-rotated.html
LayoutTests/tiled-drawing/scrolling/wheel-events-with-no-delta.html
Source/WebKit2/ChangeLog
Source/WebKit2/Platform/IPC/Connection.cpp
Source/WebKit2/Platform/IPC/Connection.h
Source/WebKit2/Platform/IPC/MessageDecoder.cpp
Source/WebKit2/Platform/IPC/MessageDecoder.h
Source/WebKit2/Platform/IPC/MessageEncoder.cpp
Source/WebKit2/Platform/IPC/MessageEncoder.h
Source/WebKit2/Platform/IPC/MessageFlags.h
Source/WebKit2/UIProcess/API/APIProcessPoolConfiguration.cpp
Source/WebKit2/UIProcess/API/APIProcessPoolConfiguration.h
Source/WebKit2/UIProcess/API/C/WKContextConfigurationRef.cpp
Source/WebKit2/UIProcess/API/C/WKContextConfigurationRef.h
Source/WebKit2/UIProcess/API/C/WKPage.cpp
Source/WebKit2/UIProcess/API/C/WKPagePrivate.h
Source/WebKit2/UIProcess/WebPageProxy.cpp
Source/WebKit2/UIProcess/WebPageProxy.h
Source/WebKit2/UIProcess/WebProcessPool.cpp
Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePage.cpp
Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePage.h
Source/WebKit2/WebProcess/WebPage/EventDispatcher.cpp
Source/WebKit2/WebProcess/WebPage/WebPage.cpp
Source/WebKit2/WebProcess/WebPage/WebPage.h
Source/WebKit2/WebProcess/WebPage/WebPage.messages.in
Tools/ChangeLog
Tools/WebKitTestRunner/InjectedBundle/Bindings/EventSendingController.idl
Tools/WebKitTestRunner/InjectedBundle/EventSendingController.cpp
Tools/WebKitTestRunner/InjectedBundle/EventSendingController.h
Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.cpp
Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp
Tools/WebKitTestRunner/TestController.cpp
Tools/WebKitTestRunner/mac/EventSenderProxy.mm