AX: Not able to use arrow keys to read text in a WK2 app
authorbdakin@apple.com <bdakin@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 9 Aug 2013 19:58:51 +0000 (19:58 +0000)
committerbdakin@apple.com <bdakin@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 9 Aug 2013 19:58:51 +0000 (19:58 +0000)
https://bugs.webkit.org/show_bug.cgi?id=119605
-and corresponding-
<rdar://problem/14281275>

Reviewed by Darin Adler.

Source/WebCore:

This code from defaultKeyboardEventHandler() is the magic that makes this AX
functionality work. This patch moves that into a separate function so that we can
call it from WK2.
* WebCore.exp.in:
* page/EventHandler.cpp:
(WebCore::EventHandler::handleKeyboardSelectionMovementForAccessibility):
(WebCore::EventHandler::defaultKeyboardEventHandler):
* page/EventHandler.h:

Source/WebKit2:

Make all of these scrolling functions actually return the WebCore bools that
indicate whether or not scrolling happened.
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::scroll):
(WebKit::WebPage::logicalScroll):
(WebKit::WebPage::scrollBy):
* WebProcess/WebPage/WebPage.h:
* WebProcess/WebPage/mac/WebPageMac.mm:
(WebKit::WebPage::executeKeypressCommandsInternal):

This function now gives accessibility a chance to handle the event too. And it
also actually tracks whether or not the event was handled by scrolling instead of
assuming that it was and universally returning true.
(WebKit::WebPage::performNonEditingBehaviorForSelector):

Tools:

New test verifies that didNotHandleKeyEvent will be called when there is nothing
to scroll.
* TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
* TestWebKitAPI/Tests/WebKit2/DidNotHandleKeyDown.cpp: Added.
(TestWebKitAPI::didFinishLoadForFrame):
(TestWebKitAPI::didNotHandleKeyEventCallback):
(TestWebKitAPI::TEST):

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

Source/WebCore/ChangeLog
Source/WebCore/WebCore.exp.in
Source/WebCore/page/EventHandler.cpp
Source/WebCore/page/EventHandler.h
Source/WebKit2/ChangeLog
Source/WebKit2/WebProcess/WebPage/WebPage.cpp
Source/WebKit2/WebProcess/WebPage/WebPage.h
Source/WebKit2/WebProcess/WebPage/mac/WebPageMac.mm
Tools/ChangeLog
Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj
Tools/TestWebKitAPI/Tests/WebKit2/DidNotHandleKeyDown.cpp [new file with mode: 0644]

index 52b23eb..fb7e376 100644 (file)
@@ -1,3 +1,21 @@
+2013-08-09  Beth Dakin  <bdakin@apple.com>
+
+        AX: Not able to use arrow keys to read text in a WK2 app
+        https://bugs.webkit.org/show_bug.cgi?id=119605
+        -and corresponding-
+        <rdar://problem/14281275>
+
+        Reviewed by Darin Adler.
+
+        This code from defaultKeyboardEventHandler() is the magic that makes this AX 
+        functionality work. This patch moves that into a separate function so that we can 
+        call it from WK2.
+        * WebCore.exp.in:
+        * page/EventHandler.cpp:
+        (WebCore::EventHandler::handleKeyboardSelectionMovementForAccessibility):
+        (WebCore::EventHandler::defaultKeyboardEventHandler):
+        * page/EventHandler.h:
+
 2013-08-09  Antti Koivisto  <antti@apple.com>
 
         Move static StyleResolver functions to Style namespace
index 235e562..42edfd8 100644 (file)
@@ -1837,6 +1837,7 @@ __ZN7WebCore12EventHandler10wheelEventEP7NSEvent
 __ZN7WebCore12EventHandler12mouseDraggedEP7NSEvent
 __ZN7WebCore12EventHandler14currentNSEventEv
 __ZN7WebCore12EventHandler31passMouseMovedEventToScrollbarsEP7NSEvent
+__ZN7WebCore12EventHandler47handleKeyboardSelectionMovementForAccessibilityEPNS_13KeyboardEventE
 __ZN7WebCore12EventHandler7mouseUpEP7NSEvent
 __ZN7WebCore12EventHandler8keyEventEP7NSEvent
 __ZN7WebCore12EventHandler9mouseDownEP7NSEvent
index d5ac2e8..89f41be 100644 (file)
@@ -3342,7 +3342,15 @@ static void handleKeyboardSelectionMovement(FrameSelection* selection, KeyboardE
     selection->modify(alternation, direction, granularity, UserTriggered);
     event->setDefaultHandled();
 }
-    
+
+void EventHandler::handleKeyboardSelectionMovementForAccessibility(KeyboardEvent* event)
+{
+    if (event->type() == eventNames().keydownEvent) {
+        if (AXObjectCache::accessibilityEnhancedUserInterfaceEnabled())
+            handleKeyboardSelectionMovement(m_frame->selection(), event);
+    }
+}
+
 void EventHandler::defaultKeyboardEventHandler(KeyboardEvent* event)
 {
     if (event->type() == eventNames().keydownEvent) {
@@ -3359,9 +3367,7 @@ void EventHandler::defaultKeyboardEventHandler(KeyboardEvent* event)
                 defaultArrowEventHandler(direction, event);
         }
 
-        // provides KB navigation and selection for enhanced accessibility users
-        if (AXObjectCache::accessibilityEnhancedUserInterfaceEnabled())
-            handleKeyboardSelectionMovement(m_frame->selection(), event);
+        handleKeyboardSelectionMovementForAccessibility(event);
     }
     if (event->type() == eventNames().keypressEvent) {
         m_frame->editor().handleKeyboardEvent(event);
index a72eb97..184ad2f 100644 (file)
@@ -216,6 +216,8 @@ public:
     bool keyEvent(const PlatformKeyboardEvent&);
     void defaultKeyboardEventHandler(KeyboardEvent*);
 
+    void handleKeyboardSelectionMovementForAccessibility(KeyboardEvent*);
+
     bool handleTextInputEvent(const String& text, Event* underlyingEvent = 0, TextEventInputType = TextEventInputKeyboard);
     void defaultTextInputEventHandler(TextEvent*);
 
index 9eb20c6..7a55431 100644 (file)
@@ -1,3 +1,27 @@
+2013-08-09  Beth Dakin  <bdakin@apple.com>
+
+        AX: Not able to use arrow keys to read text in a WK2 app
+        https://bugs.webkit.org/show_bug.cgi?id=119605
+        -and corresponding-
+        <rdar://problem/14281275>
+
+        Reviewed by Darin Adler.
+
+        Make all of these scrolling functions actually return the WebCore bools that 
+        indicate whether or not scrolling happened. 
+        * WebProcess/WebPage/WebPage.cpp:
+        (WebKit::WebPage::scroll):
+        (WebKit::WebPage::logicalScroll):
+        (WebKit::WebPage::scrollBy):
+        * WebProcess/WebPage/WebPage.h:
+        * WebProcess/WebPage/mac/WebPageMac.mm:
+        (WebKit::WebPage::executeKeypressCommandsInternal):
+
+        This function now gives accessibility a chance to handle the event too. And it 
+        also actually tracks whether or not the event was handled by scrolling instead of 
+        assuming that it was and universally returning true.
+        (WebKit::WebPage::performNonEditingBehaviorForSelector):
+
 2013-08-09  Brian Holt  <brian.holt@samsung.com>
 
         [GTK] [WebKit2] Add an 'authenticate' signal to WebKitWebView
index d8b4fe4..89cfbaa 100644 (file)
@@ -1974,19 +1974,19 @@ void WebPage::touchEventSyncForTesting(const WebTouchEvent& touchEvent, bool& ha
 }
 #endif
 
-void WebPage::scroll(Page* page, ScrollDirection direction, ScrollGranularity granularity)
+bool WebPage::scroll(Page* page, ScrollDirection direction, ScrollGranularity granularity)
 {
-    page->focusController()->focusedOrMainFrame()->eventHandler()->scrollRecursively(direction, granularity);
+    return page->focusController()->focusedOrMainFrame()->eventHandler()->scrollRecursively(direction, granularity);
 }
 
-void WebPage::logicalScroll(Page* page, ScrollLogicalDirection direction, ScrollGranularity granularity)
+bool WebPage::logicalScroll(Page* page, ScrollLogicalDirection direction, ScrollGranularity granularity)
 {
-    page->focusController()->focusedOrMainFrame()->eventHandler()->logicalScrollRecursively(direction, granularity);
+    return page->focusController()->focusedOrMainFrame()->eventHandler()->logicalScrollRecursively(direction, granularity);
 }
 
-void WebPage::scrollBy(uint32_t scrollDirection, uint32_t scrollGranularity)
+bool WebPage::scrollBy(uint32_t scrollDirection, uint32_t scrollGranularity)
 {
-    scroll(m_page.get(), static_cast<ScrollDirection>(scrollDirection), static_cast<ScrollGranularity>(scrollGranularity));
+    return scroll(m_page.get(), static_cast<ScrollDirection>(scrollDirection), static_cast<ScrollGranularity>(scrollGranularity));
 }
 
 void WebPage::centerSelectionInVisibleArea()
index be7e84b..1dc1249 100644 (file)
@@ -190,7 +190,7 @@ public:
 
     void scrollMainFrameIfNotAtMaxScrollPosition(const WebCore::IntSize& scrollOffset);
 
-    void scrollBy(uint32_t scrollDirection, uint32_t scrollGranularity);
+    bool scrollBy(uint32_t scrollDirection, uint32_t scrollGranularity);
 
     void centerSelectionInVisibleArea();
 
@@ -481,7 +481,7 @@ public:
     void getDataSelectionForPasteboard(const WTF::String pasteboardType, SharedMemory::Handle& handle, uint64_t& size);
     void shouldDelayWindowOrderingEvent(const WebKit::WebMouseEvent&, bool& result);
     void acceptsFirstMouse(int eventNumber, const WebKit::WebMouseEvent&, bool& result);
-    bool performNonEditingBehaviorForSelector(const String&);
+    bool performNonEditingBehaviorForSelector(const String&, WebCore::KeyboardEvent*);
     void insertDictatedText(const String& text, uint64_t replacementRangeStart, uint64_t replacementRangeEnd, const Vector<WebCore::DictationAlternative>& dictationAlternativeLocations, bool& handled, EditorState& newState);
 #elif PLATFORM(EFL)
     void confirmComposition(const String& compositionString);
@@ -729,8 +729,8 @@ private:
     void contextMenuHidden() { m_isShowingContextMenu = false; }
 #endif
 
-    static void scroll(WebCore::Page*, WebCore::ScrollDirection, WebCore::ScrollGranularity);
-    static void logicalScroll(WebCore::Page*, WebCore::ScrollLogicalDirection, WebCore::ScrollGranularity);
+    static bool scroll(WebCore::Page*, WebCore::ScrollDirection, WebCore::ScrollGranularity);
+    static bool logicalScroll(WebCore::Page*, WebCore::ScrollLogicalDirection, WebCore::ScrollGranularity);
 
     uint64_t restoreSession(const SessionState&);
     void restoreSessionAndNavigateToCurrentItem(const SessionState&);
index 6c6a7e7..2be2a53 100644 (file)
@@ -186,7 +186,7 @@ bool WebPage::executeKeypressCommandsInternal(const Vector<WebCore::KeypressComm
                 bool commandExecutedByEditor = command.execute(event);
                 eventWasHandled |= commandExecutedByEditor;
                 if (!commandExecutedByEditor) {
-                    bool performedNonEditingBehavior = event->keyEvent()->type() == PlatformEvent::RawKeyDown && performNonEditingBehaviorForSelector(commands[i].commandName);
+                    bool performedNonEditingBehavior = event->keyEvent()->type() == PlatformEvent::RawKeyDown && performNonEditingBehaviorForSelector(commands[i].commandName, event);
                     eventWasHandled |= performedNonEditingBehavior;
                 }
             } else {
@@ -624,40 +624,47 @@ void WebPage::performDictionaryLookupForRange(Frame* frame, Range* range, NSDict
     send(Messages::WebPageProxy::DidPerformDictionaryLookup(attributedString, dictionaryPopupInfo));
 }
 
-bool WebPage::performNonEditingBehaviorForSelector(const String& selector)
+bool WebPage::performNonEditingBehaviorForSelector(const String& selector, KeyboardEvent* event)
 {
+    // First give accessibility a chance to handle the event.
+    Frame* frame = frameForEvent(event);
+    frame->eventHandler()->handleKeyboardSelectionMovementForAccessibility(event);
+    if (event->defaultHandled())
+        return true;
+
     // FIXME: All these selectors have corresponding Editor commands, but the commands only work in editable content.
     // Should such non-editing behaviors be implemented in Editor or EventHandler::defaultArrowEventHandler() perhaps?
+    
+    bool didPerformAction = false;
+
     if (selector == "moveUp:")
-        scroll(m_page.get(), ScrollUp, ScrollByLine);
+        didPerformAction = scroll(m_page.get(), ScrollUp, ScrollByLine);
     else if (selector == "moveToBeginningOfParagraph:")
-        scroll(m_page.get(), ScrollUp, ScrollByPage);
+        didPerformAction = scroll(m_page.get(), ScrollUp, ScrollByPage);
     else if (selector == "moveToBeginningOfDocument:") {
-        scroll(m_page.get(), ScrollUp, ScrollByDocument);
-        scroll(m_page.get(), ScrollLeft, ScrollByDocument);
+        didPerformAction = scroll(m_page.get(), ScrollUp, ScrollByDocument);
+        didPerformAction |= scroll(m_page.get(), ScrollLeft, ScrollByDocument);
     } else if (selector == "moveDown:")
-        scroll(m_page.get(), ScrollDown, ScrollByLine);
+        didPerformAction = scroll(m_page.get(), ScrollDown, ScrollByLine);
     else if (selector == "moveToEndOfParagraph:")
-        scroll(m_page.get(), ScrollDown, ScrollByPage);
+        didPerformAction = scroll(m_page.get(), ScrollDown, ScrollByPage);
     else if (selector == "moveToEndOfDocument:") {
-        scroll(m_page.get(), ScrollDown, ScrollByDocument);
-        scroll(m_page.get(), ScrollLeft, ScrollByDocument);
+        didPerformAction = scroll(m_page.get(), ScrollDown, ScrollByDocument);
+        didPerformAction |= scroll(m_page.get(), ScrollLeft, ScrollByDocument);
     } else if (selector == "moveLeft:")
-        scroll(m_page.get(), ScrollLeft, ScrollByLine);
+        didPerformAction = scroll(m_page.get(), ScrollLeft, ScrollByLine);
     else if (selector == "moveWordLeft:")
-        scroll(m_page.get(), ScrollLeft, ScrollByPage);
+        didPerformAction = scroll(m_page.get(), ScrollLeft, ScrollByPage);
     else if (selector == "moveToLeftEndOfLine:")
-        m_page->goBack();
+        didPerformAction = m_page->goBack();
     else if (selector == "moveRight:")
-        scroll(m_page.get(), ScrollRight, ScrollByLine);
+        didPerformAction = scroll(m_page.get(), ScrollRight, ScrollByLine);
     else if (selector == "moveWordRight:")
-        scroll(m_page.get(), ScrollRight, ScrollByPage);
+        didPerformAction = scroll(m_page.get(), ScrollRight, ScrollByPage);
     else if (selector == "moveToRightEndOfLine:")
-        m_page->goForward();
-    else
-        return false;
+        didPerformAction = m_page->goForward();
 
-    return true;
+    return didPerformAction;
 }
 
 bool WebPage::performDefaultBehaviorForKeyEvent(const WebKeyboardEvent&)
index c1fe5eb..b43ea16 100644 (file)
@@ -1,3 +1,20 @@
+2013-08-09  Beth Dakin  <bdakin@apple.com>
+
+        AX: Not able to use arrow keys to read text in a WK2 app
+        https://bugs.webkit.org/show_bug.cgi?id=119605
+        -and corresponding-
+        <rdar://problem/14281275>
+
+        Reviewed by Darin Adler.
+
+        New test verifies that didNotHandleKeyEvent will be called when there is nothing 
+        to scroll. 
+        * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
+        * TestWebKitAPI/Tests/WebKit2/DidNotHandleKeyDown.cpp: Added.
+        (TestWebKitAPI::didFinishLoadForFrame):
+        (TestWebKitAPI::didNotHandleKeyEventCallback):
+        (TestWebKitAPI::TEST):
+
 2013-08-09  Christophe Dumez  <ch.dumez@sisa.samsung.com>
 
         Add support for KeyboardEvent.location attribute
index 6eee6b0..7f1e952 100644 (file)
                8AA28C1A16D2FA7B002FF4DB /* LoadPageOnCrash.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8AA28C1916D2FA7B002FF4DB /* LoadPageOnCrash.cpp */; };
                930AD402150698D00067970F /* lots-of-text.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 930AD401150698B30067970F /* lots-of-text.html */; };
                9318778915EEC57700A9CCE3 /* NewFirstVisuallyNonEmptyLayoutForImages.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 93AF4ECA1506F035007FD57E /* NewFirstVisuallyNonEmptyLayoutForImages.cpp */; };
+               9331407C17B4419000F083B1 /* DidNotHandleKeyDown.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9331407B17B4419000F083B1 /* DidNotHandleKeyDown.cpp */; };
                9361002914DC95A70061379D /* lots-of-iframes.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 9361002814DC957B0061379D /* lots-of-iframes.html */; };
                939BA91714103412001A01BD /* DeviceScaleFactorOnBack.mm in Sources */ = {isa = PBXBuildFile; fileRef = 939BA91614103412001A01BD /* DeviceScaleFactorOnBack.mm */; };
                93ABA80916DDAB91002DB2FA /* StringHasher.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 93ABA80816DDAB91002DB2FA /* StringHasher.cpp */; };
                8AA28C1916D2FA7B002FF4DB /* LoadPageOnCrash.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = LoadPageOnCrash.cpp; sourceTree = "<group>"; };
                8DD76FA10486AA7600D96B5E /* TestWebKitAPI */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = TestWebKitAPI; sourceTree = BUILT_PRODUCTS_DIR; };
                930AD401150698B30067970F /* lots-of-text.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "lots-of-text.html"; sourceTree = "<group>"; };
+               9331407B17B4419000F083B1 /* DidNotHandleKeyDown.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DidNotHandleKeyDown.cpp; sourceTree = "<group>"; };
                9361002814DC957B0061379D /* lots-of-iframes.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "lots-of-iframes.html"; sourceTree = "<group>"; };
                939BA91614103412001A01BD /* DeviceScaleFactorOnBack.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = DeviceScaleFactorOnBack.mm; sourceTree = "<group>"; };
                93ABA80816DDAB91002DB2FA /* StringHasher.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = StringHasher.cpp; path = WTF/StringHasher.cpp; sourceTree = "<group>"; };
                                F6F3F29013342FEB00A6BF19 /* CookieManager.cpp */,
                                F6B7BE93174691EF008A3445 /* DidAssociateFormControls.cpp */,
                                F6B7BE92174691EF008A3445 /* DidAssociateFormControls_Bundle.cpp */,
+                               9331407B17B4419000F083B1 /* DidNotHandleKeyDown.cpp */,
                                BCB6803F126FBFE100642A61 /* DocumentStartUserScriptAlertCrash.cpp */,
                                BCB68041126FBFF100642A61 /* DocumentStartUserScriptAlertCrash_Bundle.cpp */,
                                51393E1E1523944A005F39C5 /* DOMWindowExtensionBasic.cpp */,
                                93F7E86C14DC8E4D00C84A99 /* NewFirstVisuallyNonEmptyLayoutFrames.cpp in Sources */,
                                BC90977A125571AB00083756 /* PageLoadBasic.cpp in Sources */,
                                BC2D004912A9FDFA00E732A3 /* PageLoadDidChangeLocationWithinPageForFrame.cpp in Sources */,
+                               9331407C17B4419000F083B1 /* DidNotHandleKeyDown.cpp in Sources */,
                                A51B650916ADF9B1007AA5D9 /* PageVisibilityState.cpp in Sources */,
                                A57A34F016AF677200C2501F /* PageVisibilityStateWithWindowChanges.mm in Sources */,
                                52E5CE4614D21E9D003B2BD8 /* ParentFrame.cpp in Sources */,
diff --git a/Tools/TestWebKitAPI/Tests/WebKit2/DidNotHandleKeyDown.cpp b/Tools/TestWebKitAPI/Tests/WebKit2/DidNotHandleKeyDown.cpp
new file mode 100644 (file)
index 0000000..0a59f62
--- /dev/null
@@ -0,0 +1,75 @@
+/*
+ * Copyright (C) 2013 Apple Inc. All rights reserved.
+ *
+ * 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.
+ */
+
+#include "config.h"
+#include "JavaScriptTest.h"
+#include "PlatformUtilities.h"
+#include "PlatformWebView.h"
+#include <WebKit2/WKRetainPtr.h>
+
+namespace TestWebKitAPI {
+
+static bool didFinishTest;
+static bool didNotHandleKeyDownEvent;
+
+static void didFinishLoadForFrame(WKPageRef, WKFrameRef, WKTypeRef, const void*)
+{
+}
+
+static void didNotHandleKeyEventCallback(WKPageRef, WKNativeEventPtr event, const void*)
+{
+    if (Util::isKeyDown(event))
+        didNotHandleKeyDownEvent = true;
+    didFinishTest = true;
+}
+
+TEST(WebKit2, DidNotHandleKeyDown)
+{
+    WKRetainPtr<WKContextRef> context(AdoptWK, Util::createContextWithInjectedBundle());
+    PlatformWebView webView(context.get());
+
+    WKPageLoaderClient loaderClient;
+    memset(&loaderClient, 0, sizeof(loaderClient));
+    
+    loaderClient.version = 0;
+    loaderClient.didFinishLoadForFrame = didFinishLoadForFrame;
+    WKPageSetPageLoaderClient(webView.page(), &loaderClient);
+
+    WKPageUIClient uiClient;
+    memset(&uiClient, 0, sizeof(uiClient));
+
+    uiClient.didNotHandleKeyEvent = didNotHandleKeyEventCallback;
+    WKPageSetPageUIClient(webView.page(), &uiClient);
+
+    WKRetainPtr<WKURLRef> url(AdoptWK, Util::createURLForResource("simple", "html"));
+    WKPageLoadURL(webView.page(), url.get());
+
+    webView.simulateSpacebarKeyPress();
+
+    Util::run(&didFinishTest);
+    EXPECT_TRUE(didNotHandleKeyDownEvent);
+}
+
+} // namespace TestWebKitAPI