[WK2] [Mac] Implement KeyDown function for WebKit2 EventSender.

https://bugs.webkit.org/show_bug.cgi?id=57515

Source/WebKit2:

The code change in WebKit2 allows key events being sent to WebProcess from UIProcess synchronously.

Patch by Chang Shu <cshu@webkit.org> on 2011-09-13
Reviewed by Darin Adler.

* UIProcess/API/C/WKPage.cpp:
(WKPageSetShouldSendKeyboardEventSynchronously):
* UIProcess/API/C/WKPagePrivate.h:
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::WebPageProxy):
(WebKit::WebPageProxy::handleKeyboardEvent):
* UIProcess/WebPageProxy.h:
(WebKit::WebPageProxy::setShouldSendKeyboardEventSynchronously):
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::keyEventSyncForTesting):
* WebProcess/WebPage/WebPage.h:
* WebProcess/WebPage/WebPage.messages.in:

Tools:

The code change in WebKitTestRunner first sends keydown event from InjectedBundle to
TestController synchronously. The latter then sends simulated event to WebKit2 module,
which is synchronous, too.

Patch by Chang Shu <cshu@webkit.org> on 2011-09-13
Reviewed by Darin Adler.

* WebKitTestRunner/EventSenderProxy.h: Added.
(WTR::EventSenderProxy::EventSenderProxy):
* WebKitTestRunner/InjectedBundle/Bindings/EventSendingController.idl:
* WebKitTestRunner/InjectedBundle/EventSendingController.cpp:
(WTR::EventSendingController::keyDown):
* WebKitTestRunner/InjectedBundle/EventSendingController.h:
* WebKitTestRunner/PlatformWebView.h:
(WTR::PlatformWebView::platformWindow):
* WebKitTestRunner/TestController.cpp:
(WTR::TestController::TestController):
(WTR::TestController::didReceiveSynchronousMessageFromInjectedBundle):
* WebKitTestRunner/TestController.h:
* WebKitTestRunner/WebKitTestRunner.xcodeproj/project.pbxproj:
* WebKitTestRunner/mac/EventSenderProxy.mm: Added.
(WTR::buildModifierFlags):
(WTR::EventSenderProxy::keyDown):

LayoutTests:

Unskip passed tests for Mac.

Patch by Chang Shu <cshu@webkit.org> on 2011-09-13
Reviewed by Darin Adler.

* platform/mac-wk2/Skipped:
* platform/qt-wk2/Skipped:
* platform/win-wk2/Skipped:
* platform/wk2/Skipped:

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@95039 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent eefe7d42
2011-09-13 Chang Shu <cshu@webkit.org>
[WK2] [Mac] Implement KeyDown function for WebKit2 EventSender.
https://bugs.webkit.org/show_bug.cgi?id=57515
Unskip passed tests for Mac.
Reviewed by Darin Adler.
* platform/mac-wk2/Skipped:
* platform/qt-wk2/Skipped:
* platform/win-wk2/Skipped:
* platform/wk2/Skipped:
2011-09-13 Joseph Pecoraro <joepeck@webkit.org>
CRASH under WebCore::ArchiveResourceCollection::addAllResources loading WebArchive
......@@ -38,6 +38,221 @@
########################################
### START OF (1) Classified failures with bug reports
# WebKitTestRunner needs an implementation of eventSender
# <https://bugs.webkit.org/show_bug.cgi?id=42194>
editing/deleting/delete-ligature-003.html
editing/deleting/smart-delete-001.html
editing/deleting/smart-delete-002.html
editing/deleting/smart-delete-003.html
editing/deleting/smart-delete-004.html
editing/execCommand/findString-2.html
editing/pasteboard/4944770-2.html
editing/pasteboard/4947130.html
editing/pasteboard/copy-standalone-image-crash.html
editing/pasteboard/drag-and-drop-image-contenteditable.html
editing/pasteboard/drag-and-drop-inputimage-contenteditable.html
editing/pasteboard/drag-and-drop-objectimage-contenteditable.html
editing/pasteboard/drag-drop-dead-frame.html
editing/pasteboard/drag-drop-input-textarea.html
editing/pasteboard/drag-drop-list.html
editing/pasteboard/drag-drop-modifies-page.html
editing/pasteboard/drag-drop-url-text.html
editing/pasteboard/drag-image-in-about-blank-frame.html
editing/pasteboard/drag-image-to-contenteditable-in-iframe.html
editing/pasteboard/drag-selected-image-to-contenteditable.html
editing/pasteboard/drop-file-svg.html
editing/pasteboard/drop-inputtext-acquires-style.html
editing/pasteboard/drop-link.html
editing/pasteboard/drop-text-events.html
editing/pasteboard/drop-text-without-selection.html
editing/pasteboard/emacs-cntl-y-001.html
editing/pasteboard/emacs-ctrl-a-k-y.html
editing/pasteboard/emacs-ctrl-k-y-001.html
editing/pasteboard/file-input-files-access.html
editing/pasteboard/files-during-page-drags.html
editing/pasteboard/get-data-text-plain-drop.html
editing/pasteboard/smart-drag-drop.html
editing/pasteboard/smart-paste-001.html
editing/pasteboard/smart-paste-002.html
editing/pasteboard/smart-paste-003.html
editing/pasteboard/smart-paste-004.html
editing/pasteboard/smart-paste-005.html
editing/pasteboard/smart-paste-007.html
editing/pasteboard/smart-paste-008.html
editing/pasteboard/subframe-dragndrop-1.html
editing/selection/14971.html
editing/selection/4895428-1.html
editing/selection/4895428-4.html
editing/selection/5057506.html
editing/selection/5232159.html
editing/selection/5333725.html
editing/selection/5354455-1.html
editing/selection/5354455-2.html
editing/selection/anchor-focus2.html
editing/selection/anchor-focus3.html
editing/selection/button-right-click.html
editing/selection/click-in-focusable-link-should-not-clear-selection.html
editing/selection/click-in-margins-inside-editable-div.html
editing/selection/click-in-padding-with-multiple-line-boxes.html
editing/selection/contains-boundaries.html
editing/selection/context-menu-on-text.html
editing/selection/doubleclick-beside-cr-span.html
editing/selection/doubleclick-crash.html
editing/selection/doubleclick-whitespace-crash.html
editing/selection/doubleclick-whitespace-img-crash.html
editing/selection/doubleclick-whitespace.html
editing/selection/drag-select-1.html
editing/selection/drag-select-rapidly.html
editing/selection/drag-start-event-client-x-y.html
editing/selection/drag-to-contenteditable-iframe.html
editing/selection/empty-cell-right-click.html
editing/selection/expanding-selections.html
editing/selection/expanding-selections2.html
editing/selection/extend-after-mouse-selection.html
editing/selection/extend-selection-after-double-click.html
editing/selection/fake-doubleclick.html
editing/selection/fake-drag.html
editing/selection/inline-closest-leaf-child.html
editing/selection/last-empty-inline.html
editing/selection/mixed-editability-10.html
editing/selection/paragraph-granularity.html
editing/selection/select-from-textfield-outwards.html
editing/selection/select-out-of-editable.html
editing/selection/select-out-of-floated-contenteditable.html
editing/selection/select-out-of-floated-input.html
editing/selection/select-out-of-floated-textarea.html
editing/selection/selection-actions.html
editing/selection/shift-click.html
editing/selection/user-drag-element-and-user-select-none.html
editing/selection/word-granularity.html
editing/spelling/context-menu-suggestions.html
editing/spelling/spellcheck-paste.html
editing/undo/undo-deleteWord.html
editing/undo/undo-smart-delete-reversed-selection.html
editing/undo/undo-smart-delete-word.html
fast/block/positioning/hittest-on-relative-positioned-children.html
fast/css/user-drag-none.html
fast/dom/Window/window-postmessage-clone-frames.html
fast/dom/Window/window-postmessage-clone.html
fast/dom/horizontal-scrollbar-in-rtl.html
fast/dom/vertical-scrollbar-in-rtl.html
fast/dynamic/layer-hit-test-crash.html
fast/encoding/mailto-always-utf-8.html
fast/events/5056619.html
fast/events/autoscroll-in-textfield.html
fast/events/autoscroll-nonscrollable-iframe-in-scrollable-div.html
fast/events/autoscroll-with-non-scrollable-parent.html
fast/events/autoscroll.html
fast/events/bogus-dropEffect-effectAllowed.html
fast/events/click-count.html
fast/events/content-changed-during-drop.html
fast/events/context-no-deselect.html
fast/events/context-onmousedown-event.html
fast/events/contextmenu-scrolled-page-with-frame.html
fast/events/continuous-platform-wheelevent-in-scrolling-div.html
fast/events/crash-on-mutate-during-drop.html
fast/events/dblclick-addEventListener.html
fast/events/drag-and-drop-dataTransfer-types-nocrash.html
fast/events/drag-and-drop-fire-drag-dragover.html
fast/events/drag-and-drop.html
fast/events/drag-file-crash.html
fast/events/drag-in-frames.html
fast/events/drag-parent-node.html
fast/events/drag-to-navigate.html
fast/events/dropzone-001.html
fast/events/dropzone-002.html
fast/events/dropzone-003.html
fast/events/dropzone-004.html
fast/events/keydown-numpad-keys.html
fast/events/mouse-click-events.html
fast/events/mouseup-from-button2.html
fast/events/node-event-anchor-lock.html
fast/events/ondragenter.html
fast/events/open-window-from-another-frame.html
fast/events/platform-wheelevent-in-scrolling-div.html
fast/events/popup-blocking-click-in-iframe.html
fast/events/popup-when-select-change.html
fast/events/prevent-drag-to-navigate.html
fast/events/remove-child-onscroll.html
fast/events/right-click-focus.html
fast/events/scroll-after-click-on-tab-index.html
fast/events/scroll-in-scaled-page-with-overflow-hidden.html
fast/events/scrollbar-double-click.html
fast/events/selectstart-by-double-triple-clicks.html
fast/events/selectstart-by-drag.html
fast/events/selectstart-prevent-selection-on-right-click.html
fast/events/standalone-image-drag-to-editable.html
fast/events/wheelevent-in-horizontal-scrollbar-in-rtl.html
fast/events/wheelevent-in-vertical-scrollbar-in-rtl.html
fast/events/zoom-dblclick.html
fast/files/apply-blob-url-to-xhr.html
fast/files/file-reader-abort.html
fast/files/read-blob-async.html
fast/files/read-file-async.html
fast/forms/drag-into-textarea.html
fast/forms/drag-out-of-textarea.html
fast/forms/get-file-upload.html
fast/forms/input-file-re-render.html
fast/forms/input-readonly-autoscroll.html
fast/forms/input-text-double-click.html
fast/forms/input-text-drag-down.html
fast/forms/listbox-typeahead-cyrillic.html
fast/forms/listbox-typeahead-greek.html
fast/forms/onselect-textarea.html
fast/forms/onselect-textfield.html
fast/forms/option-mouseevents.html
fast/forms/range/slider-delete-while-dragging-thumb.html
fast/forms/range/slider-mouse-events.html
fast/forms/range/slider-onchange-event.html
fast/forms/select-type-ahead-non-latin.html
fast/history/window-open.html
fast/lists/drag-into-marker.html
fast/loader/policy-delegate-action-hit-test-zoomed.html
fast/repaint/japanese-rl-selection-repaint.html
fast/repaint/repaint-across-writing-mode-boundary.html
fast/repaint/selection-rl.html
fast/text/atsui-rtl-override-selection.html
fast/text/international/khmer-selection.html
fast/text/offsetForPosition-complex-fallback.html
fast/text/reset-drag-on-mouse-down.html
fast/writing-mode/horizontal-bt-replaced-selection.html
fast/writing-mode/japanese-lr-selection.html
fast/writing-mode/japanese-rl-selection.html
fast/writing-mode/vertical-lr-replaced-selection.html
fast/writing-mode/vertical-rl-replaced-selection.html
http/tests/local/blob/send-hybrid-blob.html
http/tests/local/drag-over-remote-content.html
http/tests/local/fileapi/file-last-modified.html
http/tests/local/fileapi/send-dragged-file.html
http/tests/local/fileapi/send-sliced-dragged-file.html
http/tests/local/formdata/form-data-with-unknown-file-extension.html
http/tests/local/formdata/send-form-data-constructed-from-form.html
http/tests/local/formdata/send-form-data-with-sliced-file.html
http/tests/local/formdata/send-form-data.html
http/tests/local/formdata/upload-events.html
http/tests/misc/bubble-drag-events.html
http/tests/security/clipboard/clipboard-file-access.html
http/tests/security/dataTransfer-set-data-file-url.html
http/tests/security/drag-drop-same-unique-origin.html
http/tests/security/drag-over-remote-content-iframe.html
media/controls-right-click-on-timebar.html
platform/mac/editing/pasteboard/dataTransfer-set-data-file-url.html
platform/mac/editing/pasteboard/drag-selections-to-contenteditable.html
platform/mac/editing/selection/doubleclick-should-not-expand-across-lines.html
platform/mac/editing/selection/word-thai.html
platform/mac/fast/forms/listbox-scrollbar-hit-test.html
platform/mac/fast/overflow/overflow-scrollbar-hit-test.html
plugins/clicking-missing-plugin-fires-delegate.html
scrollbars/scrollbar-iframe-click-does-not-blur-content.html
scrollbars/scrollevent-iframe-no-scrolling-wheel.html
svg/custom/foreignObject-crash-on-hover.xml
svg/custom/mouse-move-on-svg-container-standalone.svg
svg/custom/mouse-move-on-svg-container.xhtml
svg/custom/mouse-move-on-svg-root-standalone.svg
svg/custom/mouse-move-on-svg-root.xhtml
svg/custom/use-events-crash.svg
### END OF (1) Classified failures with bug reports
########################################
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
2011-09-13 Chang Shu <cshu@webkit.org>
[WK2] [Mac] Implement KeyDown function for WebKit2 EventSender.
https://bugs.webkit.org/show_bug.cgi?id=57515
The code change in WebKit2 allows key events being sent to WebProcess from UIProcess synchronously.
Reviewed by Darin Adler.
* UIProcess/API/C/WKPage.cpp:
(WKPageSetShouldSendKeyboardEventSynchronously):
* UIProcess/API/C/WKPagePrivate.h:
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::WebPageProxy):
(WebKit::WebPageProxy::handleKeyboardEvent):
* UIProcess/WebPageProxy.h:
(WebKit::WebPageProxy::setShouldSendKeyboardEventSynchronously):
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::keyEventSyncForTesting):
* WebProcess/WebPage/WebPage.h:
* WebProcess/WebPage/WebPage.messages.in:
2011-09-12 Ryuan Choi <ryuan.choi@samsung.com>
Reviewed by Eric Seidel.
......
......@@ -581,3 +581,7 @@ WKImageRef WKPageCreateSnapshotOfVisibleContent(WKPageRef)
return 0;
}
void WKPageSetShouldSendKeyboardEventSynchronously(WKPageRef page, bool sync)
{
toImpl(page)->setShouldSendKeyboardEventSynchronously(sync);
}
......@@ -69,6 +69,8 @@ WK_EXPORT void WKPageDrawPagesToPDF(WKPageRef page, WKFrameRef frame, uint32_t f
// FIXME https://bugs.webkit.org/show_bug.cgi?id=66979: Remove this sync call.
WK_EXPORT WKImageRef WKPageCreateSnapshotOfVisibleContent(WKPageRef page);
WK_EXPORT void WKPageSetShouldSendKeyboardEventSynchronously(WKPageRef page, bool sync);
#ifdef __cplusplus
}
#endif
......
......@@ -180,6 +180,7 @@ WebPageProxy::WebPageProxy(PageClient* pageClient, PassRefPtr<WebProcessProxy> p
, m_mainFrameIsPinnedToLeftSide(false)
, m_mainFrameIsPinnedToRightSide(false)
, m_renderTreeSize(0)
, m_shouldSendKeyboardEventSynchronously(false)
{
#ifndef NDEBUG
webPageProxyCounter.increment();
......@@ -860,7 +861,12 @@ void WebPageProxy::handleKeyboardEvent(const NativeWebKeyboardEvent& event)
m_keyEventQueue.append(event);
process()->responsivenessTimer()->start();
process()->send(Messages::WebPage::KeyEvent(event), m_pageID);
if (m_shouldSendKeyboardEventSynchronously) {
bool handled = false;
process()->sendSync(Messages::WebPage::KeyEventSyncForTesting(event), Messages::WebPage::KeyEventSyncForTesting::Reply(handled), m_pageID);
didReceiveEvent(event.type(), handled);
} else
process()->send(Messages::WebPage::KeyEvent(event), m_pageID);
}
#if ENABLE(GESTURE_EVENTS)
......
......@@ -560,7 +560,9 @@ public:
WebCore::IntRect visibleScrollerThumbRect() const { return m_visibleScrollerThumbRect; }
uint64_t renderTreeSize() const { return m_renderTreeSize; }
void setShouldSendKeyboardEventSynchronously(bool sync) { m_shouldSendKeyboardEventSynchronously = sync; };
private:
WebPageProxy(PageClient*, PassRefPtr<WebProcessProxy>, WebPageGroup*, uint64_t pageID);
......@@ -930,6 +932,8 @@ private:
uint64_t m_renderTreeSize;
static WKPageDebugPaintFlags s_debugPaintFlags;
bool m_shouldSendKeyboardEventSynchronously;
};
} // namespace WebKit
......
......@@ -1100,6 +1100,15 @@ void WebPage::keyEvent(const WebKeyboardEvent& keyboardEvent)
send(Messages::WebPageProxy::DidReceiveEvent(static_cast<uint32_t>(keyboardEvent.type()), handled));
}
void WebPage::keyEventSyncForTesting(const WebKeyboardEvent& keyboardEvent, bool& handled)
{
CurrentEvent currentEvent(keyboardEvent);
handled = handleKeyEvent(keyboardEvent, m_page.get());
if (!handled)
handled = performDefaultBehaviorForKeyEvent(keyboardEvent);
}
#if ENABLE(GESTURE_EVENTS)
static bool handleGestureEvent(const WebGestureEvent& gestureEvent, Page* page)
{
......
......@@ -477,6 +477,7 @@ private:
void mouseEvent(const WebMouseEvent&);
void wheelEvent(const WebWheelEvent&);
void keyEvent(const WebKeyboardEvent&);
void keyEventSyncForTesting(const WebKeyboardEvent&, bool&);
#if ENABLE(GESTURE_EVENTS)
void gestureEvent(const WebGestureEvent&);
#endif
......
......@@ -33,6 +33,7 @@ messages -> WebPage {
ViewWillEndLiveResize()
KeyEvent(WebKit::WebKeyboardEvent event)
KeyEventSyncForTesting(WebKit::WebKeyboardEvent event) -> (bool handled)
MouseEvent(WebKit::WebMouseEvent event)
WheelEvent(WebKit::WebWheelEvent event)
#if ENABLE(GESTURE_EVENTS)
......
2011-09-13 Chang Shu <cshu@webkit.org>
[WK2] [Mac] Implement KeyDown function for WebKit2 EventSender.
https://bugs.webkit.org/show_bug.cgi?id=57515
The code change in WebKitTestRunner first sends keydown event from InjectedBundle to
TestController synchronously. The latter then sends simulated event to WebKit2 module,
which is synchronous, too.
Reviewed by Darin Adler.
* WebKitTestRunner/EventSenderProxy.h: Added.
(WTR::EventSenderProxy::EventSenderProxy):
* WebKitTestRunner/InjectedBundle/Bindings/EventSendingController.idl:
* WebKitTestRunner/InjectedBundle/EventSendingController.cpp:
(WTR::EventSendingController::keyDown):
* WebKitTestRunner/InjectedBundle/EventSendingController.h:
* WebKitTestRunner/PlatformWebView.h:
(WTR::PlatformWebView::platformWindow):
* WebKitTestRunner/TestController.cpp:
(WTR::TestController::TestController):
(WTR::TestController::didReceiveSynchronousMessageFromInjectedBundle):
* WebKitTestRunner/TestController.h:
* WebKitTestRunner/WebKitTestRunner.xcodeproj/project.pbxproj:
* WebKitTestRunner/mac/EventSenderProxy.mm: Added.
(WTR::buildModifierFlags):
(WTR::EventSenderProxy::keyDown):
2011-09-12 Leandro Pereira <leandro@profusion.mobi>
[EFL] DRT: Add DumpRenderTreeEfl.h
/*
* Copyright (C) 2011 Apple Inc. All rights reserved.
* Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef EventSenderProxy_h
#define EventSenderProxy_h
namespace WTR {
class TestController;
class EventSenderProxy {
public:
EventSenderProxy(TestController* testController) : m_testController(testController) { }
void keyDown(WKStringRef key, WKEventModifiers, unsigned location, double timestamp);
private:
TestController* m_testController;
};
} // namespace WTR
#endif // EventSenderProxy_h
......@@ -31,6 +31,8 @@ module WTR {
void mouseMoveTo(in long x, in long y);
void leapForward(in long milliseconds);
void keyDown(in DOMString key, in object modifierArray, in long location);
// Zoom functions.
void textZoomIn();
void textZoomOut();
......
......@@ -29,9 +29,13 @@
#include "InjectedBundle.h"
#include "InjectedBundlePage.h"
#include "JSEventSendingController.h"
#include "StringFunctions.h"
#include <WebKit2/WKBundle.h>
#include <WebKit2/WKBundleFrame.h>
#include <WebKit2/WKBundlePagePrivate.h>
#include <WebKit2/WKBundlePrivate.h>
#include <WebKit2/WKMutableDictionary.h>
#include <WebKit2/WKNumber.h>
namespace WTR {
......@@ -205,4 +209,36 @@ void EventSendingController::makeWindowObject(JSContextRef context, JSObjectRef
setProperty(context, windowObject, "eventSender", this, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete, exception);
}
void EventSendingController::keyDown(JSStringRef key, JSValueRef modifierArray, int location)
{
WKBundlePageRef page = InjectedBundle::shared().page()->page();
WKBundleFrameRef frame = WKBundlePageGetMainFrame(page);
JSContextRef context = WKBundleFrameGetJavaScriptContext(frame);
WKEventModifiers modifiers = parseModifierArray(context, modifierArray);
WKRetainPtr<WKStringRef> EventSenderMessageName(AdoptWK, WKStringCreateWithUTF8CString("EventSender"));
WKRetainPtr<WKMutableDictionaryRef> EventSenderMessageBody(AdoptWK, WKMutableDictionaryCreate());
WKRetainPtr<WKStringRef> subMessageKey(AdoptWK, WKStringCreateWithUTF8CString("SubMessage"));
WKRetainPtr<WKStringRef> subMessageName(AdoptWK, WKStringCreateWithUTF8CString("KeyDown"));
WKDictionaryAddItem(EventSenderMessageBody.get(), subMessageKey.get(), subMessageName.get());
WKRetainPtr<WKStringRef> keyKey = adoptWK(WKStringCreateWithUTF8CString("Key"));
WKDictionaryAddItem(EventSenderMessageBody.get(), keyKey.get(), toWK(key).get());
WKRetainPtr<WKStringRef> modifiersKey = adoptWK(WKStringCreateWithUTF8CString("Modifiers"));
WKRetainPtr<WKUInt64Ref> modifiersRef = WKUInt64Create(modifiers);
WKDictionaryAddItem(EventSenderMessageBody.get(), modifiersKey.get(), modifiersRef.get());
WKRetainPtr<WKStringRef> locationKey = adoptWK(WKStringCreateWithUTF8CString("Location"));
WKRetainPtr<WKUInt64Ref> locationRef = WKUInt64Create(location);
WKDictionaryAddItem(EventSenderMessageBody.get(), locationKey.get(), locationRef.get());
WKRetainPtr<WKStringRef> timestampKey = adoptWK(WKStringCreateWithUTF8CString("Timestamp"));
WKRetainPtr<WKDoubleRef> timeRef = WKDoubleCreate(m_time);
WKDictionaryAddItem(EventSenderMessageBody.get(), timestampKey.get(), timeRef.get());
WKBundlePostSynchronousMessage(InjectedBundle::shared().bundle(), EventSenderMessageName.get(), EventSenderMessageBody.get(), 0);
}
} // namespace WTR
......@@ -48,6 +48,8 @@ public:
void mouseMoveTo(int x, int y);
void leapForward(int milliseconds);
void keyDown(JSStringRef key, JSValueRef modifierArray, int location);
// Zoom functions.
void textZoomIn();
void textZoomOut();
......
......@@ -61,6 +61,7 @@ public:
WKPageRef page();
PlatformWKView platformView() { return m_view; }
PlatformWindow platformWindow() { return m_window; }
void resizeTo(unsigned width, unsigned height);
void focus();
......
......@@ -37,6 +37,10 @@
#include <cstdio>
#include <wtf/PassOwnPtr.h>
#if PLATFORM(MAC)
#include "EventSenderProxy.h"
#endif
namespace WTR {
static const double defaultLongTimeout = 30;
......@@ -69,6 +73,9 @@ TestController::TestController(int argc, const char* argv[])
, m_didPrintWebProcessCrashedMessage(false)
, m_shouldExitWhenWebProcessCrashes(true)
, m_beforeUnloadReturnValue(true)
#if PLATFORM(MAC)
, m_eventSenderProxy(new EventSenderProxy(this))
#endif
{
initialize(argc, argv);
controller = this;
......@@ -501,6 +508,34 @@ void TestController::didReceiveMessageFromInjectedBundle(WKStringRef messageName
WKRetainPtr<WKTypeRef> TestController::didReceiveSynchronousMessageFromInjectedBundle(WKStringRef messageName, WKTypeRef messageBody)
{
#if PLATFORM(MAC)
if (WKStringIsEqualToUTF8CString(messageName, "EventSender")) {
ASSERT(WKGetTypeID(messageBody) == WKDictionaryGetTypeID());
WKDictionaryRef messageBodyDictionary = static_cast<WKDictionaryRef>(messageBody);
WKRetainPtr<WKStringRef> subMessageKey(AdoptWK, WKStringCreateWithUTF8CString("SubMessage"));
WKStringRef subMessageName = static_cast<WKStringRef>(WKDictionaryGetItemForKey(messageBodyDictionary, subMessageKey.get()));
if (WKStringIsEqualToUTF8CString(subMessageName, "KeyDown")) {
WKRetainPtr<WKStringRef> keyKey = adoptWK(WKStringCreateWithUTF8CString("Key"));
WKStringRef key = static_cast<WKStringRef>(WKDictionaryGetItemForKey(messageBodyDictionary, keyKey.get()));
WKRetainPtr<WKStringRef> modifiersKey = adoptWK(WKStringCreateWithUTF8CString("Modifiers"));
WKEventModifiers modifiers = static_cast<WKEventModifiers>(WKUInt64GetValue(static_cast<WKUInt64Ref>(WKDictionaryGetItemForKey(messageBodyDictionary, modifiersKey.get()))));
WKRetainPtr<WKStringRef> locationKey = adoptWK(WKStringCreateWithUTF8CString("Location"));
unsigned location = static_cast<unsigned>(WKUInt64GetValue(static_cast<WKUInt64Ref>(WKDictionaryGetItemForKey(messageBodyDictionary, locationKey.get()))));
WKRetainPtr<WKStringRef> timestampKey = adoptWK(WKStringCreateWithUTF8CString("Timestamp"));
double timestamp = WKDoubleGetValue(static_cast<WKDoubleRef>(WKDictionaryGetItemForKey(messageBodyDictionary, timestampKey.get())));
// Forward to WebProcess
m_eventSenderProxy->keyDown(key, modifiers, location, timestamp);
return 0;
}
ASSERT_NOT_REACHED();
}
#endif
return m_currentInvocation->didReceiveSynchronousMessageFromInjectedBundle(messageName, messageBody);
}
......
......@@ -35,6 +35,7 @@ namespace WTR {
class TestInvocation;
class PlatformWebView;
class EventSenderProxy;
// FIXME: Rename this TestRunner?
class TestController {
......@@ -126,6 +127,8 @@ private:
bool m_shouldExitWhenWebProcessCrashes;
bool m_beforeUnloadReturnValue;
EventSenderProxy* m_eventSenderProxy;
};
} // namespace WTR
......
......@@ -23,6 +23,7 @@
/* Begin PBXBuildFile section */
5322FB4313FDA0CD0041ABCC /* CyclicRedundancyCheck.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5322FB4113FDA0CD0041ABCC /* CyclicRedundancyCheck.cpp */; };
5322FB4613FDA0EA0041ABCC /* PixelDumpSupport.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5322FB4413FDA0EA0041ABCC /* PixelDumpSupport.cpp */; };
5670B8281386FCA5002EB355 /* EventSenderProxy.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5670B8271386FCA5002EB355 /* EventSenderProxy.mm */; };
6510A78211EC643800410867 /* AHEM____.TTF in Resources */ = {isa = PBXBuildFile; fileRef = 6510A77711EC643800410867 /* AHEM____.TTF */; };
6510A78311EC643800410867 /* ColorBits.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 6510A77811EC643800410867 /* ColorBits.ttf */; };
6510A78411EC643800410867 /* WebKitWeightWatcher100.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 6510A77911EC643800410867 /* WebKitWeightWatcher100.ttf */; };
......@@ -87,6 +88,8 @@
5322FB4213FDA0CD0041ABCC /* CyclicRedundancyCheck.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CyclicRedundancyCheck.h; sourceTree = "<group>"; };
5322FB4413FDA0EA0041ABCC /* PixelDumpSupport.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PixelDumpSupport.cpp; sourceTree = "<group>"; };
5322FB4513FDA0EA0041ABCC /* PixelDumpSupport.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PixelDumpSupport.h; sourceTree = "<group>"; };
5670B8261386FC13002EB355 /* EventSenderProxy.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EventSenderProxy.h; sourceTree = "<group>"; };
5670B8271386FCA5002EB355 /* EventSenderProxy.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = EventSenderProxy.mm; sourceTree = "<group>"; };
6510A77711EC643800410867 /* AHEM____.TTF */ = {isa = PBXFileReference; lastKnownFileType = file; name = "AHEM____.TTF"; path = "fonts/AHEM____.TTF"; sourceTree = "<group>"; };
6510A77811EC643800410867 /* ColorBits.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; name = ColorBits.ttf; path = fonts/ColorBits.ttf; sourceTree = "<group>"; };
6510A77911EC643800410867 /* WebKitWeightWatcher100.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; name = WebKitWeightWatcher100.ttf; path = fonts/WebKitWeightWatcher100.ttf; sourceTree = "<group>"; };
......@@ -197,6 +200,7 @@
BC7933FE118F7C74005EA8E2 /* mac */,
5322FB4113FDA0CD0041ABCC /* CyclicRedundancyCheck.cpp */,
5322FB4213FDA0CD0041ABCC /* CyclicRedundancyCheck.h */,
5670B8261386FC13002EB355 /* EventSenderProxy.h */,
5322FB4413FDA0EA0041ABCC /* PixelDumpSupport.cpp */,
5322FB4513FDA0EA0041ABCC /* PixelDumpSupport.h */,
BC7934DD119066EC005EA8E2 /* PlatformWebView.h */,
......@@ -292,6 +296,7 @@
BC7933FE118F7C74005EA8E2 /* mac */ = {
isa = PBXGroup;
children = (
5670B8271386FCA5002EB355 /* EventSenderProxy.mm */,