blob: b5f4fb863594cd9befbb753298894fc603bf7675 [file] [log] [blame]
bdakin@apple.com29f01022013-08-09 19:58:51 +00001/*
2 * Copyright (C) 2013 Apple Inc. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 *
13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
14 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
17 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23 * THE POSSIBILITY OF SUCH DAMAGE.
24 */
25
26#include "config.h"
simon.fraser@apple.comaead0ac2014-12-18 19:22:48 +000027
28#if WK_HAVE_C_SPI
29
bdakin@apple.com29f01022013-08-09 19:58:51 +000030#include "JavaScriptTest.h"
31#include "PlatformUtilities.h"
32#include "PlatformWebView.h"
ossy@webkit.org87ea0ef2014-05-16 08:53:19 +000033#include <WebKit/WKRetainPtr.h>
bdakin@apple.com29f01022013-08-09 19:58:51 +000034
35namespace TestWebKitAPI {
36
37static bool didFinishTest;
38static bool didNotHandleKeyDownEvent;
39
40static void didFinishLoadForFrame(WKPageRef, WKFrameRef, WKTypeRef, const void*)
41{
42}
43
44static void didNotHandleKeyEventCallback(WKPageRef, WKNativeEventPtr event, const void*)
45{
46 if (Util::isKeyDown(event))
47 didNotHandleKeyDownEvent = true;
48 didFinishTest = true;
49}
50
51TEST(WebKit2, DidNotHandleKeyDown)
52{
53 WKRetainPtr<WKContextRef> context(AdoptWK, Util::createContextWithInjectedBundle());
54 PlatformWebView webView(context.get());
55
andersca@apple.coma8996642013-12-04 18:49:49 +000056 WKPageLoaderClientV0 loaderClient;
bdakin@apple.com29f01022013-08-09 19:58:51 +000057 memset(&loaderClient, 0, sizeof(loaderClient));
58
andersca@apple.coma8996642013-12-04 18:49:49 +000059 loaderClient.base.version = 0;
bdakin@apple.com29f01022013-08-09 19:58:51 +000060 loaderClient.didFinishLoadForFrame = didFinishLoadForFrame;
bdakin@apple.com29f01022013-08-09 19:58:51 +000061
andersca@apple.coma8996642013-12-04 18:49:49 +000062 WKPageSetPageLoaderClient(webView.page(), &loaderClient.base);
63
64 WKPageUIClientV0 uiClient;
bdakin@apple.com29f01022013-08-09 19:58:51 +000065 memset(&uiClient, 0, sizeof(uiClient));
66
andersca@apple.coma8996642013-12-04 18:49:49 +000067 uiClient.base.version = 0;
bdakin@apple.com29f01022013-08-09 19:58:51 +000068 uiClient.didNotHandleKeyEvent = didNotHandleKeyEventCallback;
andersca@apple.coma8996642013-12-04 18:49:49 +000069
70 WKPageSetPageUIClient(webView.page(), &uiClient.base);
bdakin@apple.com29f01022013-08-09 19:58:51 +000071
72 WKRetainPtr<WKURLRef> url(AdoptWK, Util::createURLForResource("simple", "html"));
73 WKPageLoadURL(webView.page(), url.get());
74
75 webView.simulateSpacebarKeyPress();
76
77 Util::run(&didFinishTest);
78 EXPECT_TRUE(didNotHandleKeyDownEvent);
79}
80
81} // namespace TestWebKitAPI
simon.fraser@apple.comaead0ac2014-12-18 19:22:48 +000082
83#endif