Commit 04e047f0 authored by benjamin@webkit.org's avatar benjamin@webkit.org

[WK2] Add basic testing support for Geolocation

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

Patch by Benjamin Poulain <bpoulain@apple.com> on 2012-09-21
Reviewed by Kenneth Rohde Christiansen.

Source/WebKit2: 

* Shared/API/c/WKNumber.h: Fix an unfortunate copy-paste :)

* WebProcess/InjectedBundle/API/c/WKBundle.cpp:
* WebProcess/InjectedBundle/API/c/WKBundlePrivate.h:
* WebProcess/InjectedBundle/InjectedBundle.cpp:
* WebProcess/InjectedBundle/InjectedBundle.h:
(InjectedBundle):
Remove the code forcing the Geolocation permissions. It was working around the normal
Geolocation code and updating all the GeolocationController, which is a terrible idea.

Tools: 

Update the Geolocation testing to use the proper API in the UIProcess.

* WebKitTestRunner/CMakeLists.txt:
* WebKitTestRunner/GNUmakefile.am:

* WebKitTestRunner/GeolocationProviderMock.cpp: Added.
(WTR::startUpdatingCallback):
(WTR::stopUpdatingCallback):
(WTR::GeolocationProviderMock::GeolocationProvierMock):
(WTR::GeolocationProviderMock::setMockGeolocationPosition):
(WTR::GeolocationProviderMock::startUpdating):
(WTR::GeolocationProviderMock::stopUpdating):
(GeolocationProviderMock):
The GeolocationProvider store the location update and deliver them as needed.

WebCore GeolocationController do not support asynchronous update on start/stop. This is not
a problem in this case because all the messages between the WebProcess and the UIProcess are
asynchronous. Because of this, unlike GeolocationClientMock, we do not use a timer for event
delivery.

* WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl:
* WebKitTestRunner/InjectedBundle/InjectedBundle.cpp:
(WTR::InjectedBundle::setGeolocationPermission):
(WTR::InjectedBundle::setMockGeolocationPosition):
* WebKitTestRunner/InjectedBundle/InjectedBundle.h:
(InjectedBundle):
* WebKitTestRunner/InjectedBundle/TestRunner.cpp:
(WTR::TestRunner::setGeolocationPermission):
(WTR::TestRunner::setMockGeolocationPosition):
From the InjectedBundle, we now pass the information to the UIProcess so that
GeolocationProvider and the TestController can respond appropriately.

* WebKitTestRunner/InjectedBundle/TestRunner.h:
(TestRunner):
* WebKitTestRunner/Target.pri:
* WebKitTestRunner/TestController.cpp:
(WTR::TestController::TestController):
(WTR::decidePolicyForGeolocationPermissionRequest):
(WTR::TestController::createOtherPage):
(WTR::TestController::initialize):
(WTR::TestController::setMockGeolocationPosition):
* WebKitTestRunner/TestController.h:
(TestController):
(WTR::TestController::setGeolocationPermission):
(WTR::TestController::isGeolocationPermissionAllowed):
* WebKitTestRunner/TestInvocation.cpp:
(WTR::TestInvocation::didReceiveMessageFromInjectedBundle):
* WebKitTestRunner/WebKitTestRunner.xcodeproj/project.pbxproj:
* WebKitTestRunner/win/WebKitTestRunner.vcproj:

LayoutTests: 

* platform/wk2/Skipped: Unskip the passing tests.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@129252 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 0cffe019
2012-09-21 Benjamin Poulain <bpoulain@apple.com>
[WK2] Add basic testing support for Geolocation
https://bugs.webkit.org/show_bug.cgi?id=97278
Reviewed by Kenneth Rohde Christiansen.
* platform/wk2/Skipped: Unskip the passing tests.
2012-09-21 Joanmarie Diggs <jdiggs@igalia.com>
REGRESSION (r127882): accessibility/spinbutton-value.html failing on GTK
......@@ -288,40 +288,16 @@ platform/mac/editing/deleting/deletionUI-differing-background.html
platform/mac/editing/deleting/deletionUI-minimum-size.html
platform/mac/editing/deleting/deletionUI-successful-deletion.html
# WebKitTestRunner needs layoutTestController.setMockGeolocationPosition
# and layoutTestController.setMockGeolocationError
# <https://bugs.webkit.org/show_bug.cgi?id=59201>
fast/dom/Geolocation/callback-exception.html
fast/dom/Geolocation/callback-to-deleted-context.html
fast/dom/Geolocation/callback-to-remote-context.html
fast/dom/Geolocation/callback-to-remote-context2.html
fast/dom/Geolocation/clear-watch-invalid-id-crash.html
# Geolocation Tests for which WebKitTestRunner still misses support.
fast/dom/Geolocation/delayed-permission-allowed-for-multiple-requests.html
fast/dom/Geolocation/delayed-permission-allowed.html
fast/dom/Geolocation/delayed-permission-denied-for-multiple-requests.html
fast/dom/Geolocation/delayed-permission-denied.html
fast/dom/Geolocation/disconnected-frame-already.html
fast/dom/Geolocation/disconnected-frame-permission-denied.html
fast/dom/Geolocation/disconnected-frame.html
fast/dom/Geolocation/error-clear-watch.html
fast/dom/Geolocation/error.html
fast/dom/Geolocation/maximum-age.html
fast/dom/Geolocation/multiple-requests.html
fast/dom/Geolocation/permission-denied-already-clear-watch.html
fast/dom/Geolocation/permission-denied-already-error.html
fast/dom/Geolocation/permission-denied-already-success.html
fast/dom/Geolocation/permission-denied-stops-watches.html
fast/dom/Geolocation/permission-denied.html
fast/dom/Geolocation/position-string.html
fast/dom/Geolocation/reentrant-error.html
fast/dom/Geolocation/reentrant-permission-denied.html
fast/dom/Geolocation/reentrant-success.html
fast/dom/Geolocation/success-clear-watch.html
fast/dom/Geolocation/success.html
fast/dom/Geolocation/timeout.html
fast/dom/Geolocation/timeout-clear-watch.html
fast/dom/Geolocation/timeout-zero.html
fast/dom/Geolocation/timestamp.html
fast/dom/Geolocation/watch.html
fast/dom/Geolocation/window-close-crash.html
......
2012-09-21 Benjamin Poulain <bpoulain@apple.com>
[WK2] Add basic testing support for Geolocation
https://bugs.webkit.org/show_bug.cgi?id=97278
Reviewed by Kenneth Rohde Christiansen.
* Shared/API/c/WKNumber.h: Fix an unfortunate copy-paste :)
* WebProcess/InjectedBundle/API/c/WKBundle.cpp:
* WebProcess/InjectedBundle/API/c/WKBundlePrivate.h:
* WebProcess/InjectedBundle/InjectedBundle.cpp:
* WebProcess/InjectedBundle/InjectedBundle.h:
(InjectedBundle):
Remove the code forcing the Geolocation permissions. It was working around the normal
Geolocation code and updating all the GeolocationController, which is a terrible idea.
2012-09-21 Alexey Proskuryakov <ap@apple.com>
[WK2] Make Web Inspector work in multiple web process mode
......
......@@ -45,7 +45,7 @@ WK_EXPORT double WKDoubleGetValue(WKDoubleRef doubleRef);
/* WKUInt64 */
WK_EXPORT WKTypeID WKUInt64GetTypeID();
WK_EXPORT WKUInt64Ref WKUInt64Create(uint64_t value);
WK_EXPORT uint64_t WKUInt64GetValue(WKUInt64Ref doubleRef);
WK_EXPORT uint64_t WKUInt64GetValue(WKUInt64Ref integerRef);
#ifdef __cplusplus
}
......
......@@ -162,11 +162,6 @@ void WKBundleSetPluginsEnabled(WKBundleRef bundleRef, WKBundlePageGroupRef pageG
toImpl(bundleRef)->setPluginsEnabled(toImpl(pageGroupRef), enabled);
}
void WKBundleSetGeolocationPermission(WKBundleRef bundleRef, WKBundlePageGroupRef pageGroupRef, bool enabled)
{
toImpl(bundleRef)->setGeoLocationPermission(toImpl(pageGroupRef), enabled);
}
void WKBundleSetJavaScriptCanAccessClipboard(WKBundleRef bundleRef, WKBundlePageGroupRef pageGroupRef, bool enabled)
{
toImpl(bundleRef)->setJavaScriptCanAccessClipboard(toImpl(pageGroupRef), enabled);
......
......@@ -60,7 +60,6 @@ WK_EXPORT void WKBundleSetAllowFileAccessFromFileURLs(WKBundleRef bundle, WKBund
WK_EXPORT void WKBundleSetMinimumLogicalFontSize(WKBundleRef bundleRef, WKBundlePageGroupRef pageGroupRef, int size);
WK_EXPORT void WKBundleSetFrameFlatteningEnabled(WKBundleRef bundle, WKBundlePageGroupRef pageGroup, bool enabled);
WK_EXPORT void WKBundleSetPluginsEnabled(WKBundleRef bundle, WKBundlePageGroupRef pageGroup, bool enabled);
WK_EXPORT void WKBundleSetGeolocationPermission(WKBundleRef bundle, WKBundlePageGroupRef pageGroup, bool enabled);
WK_EXPORT void WKBundleSetJavaScriptCanAccessClipboard(WKBundleRef bundle, WKBundlePageGroupRef pageGroup, bool enabled);
WK_EXPORT void WKBundleSetPrivateBrowsingEnabled(WKBundleRef bundle, WKBundlePageGroupRef pageGroup, bool enabled);
WK_EXPORT void WKBundleSetPopupBlockingEnabled(WKBundleRef bundle, WKBundlePageGroupRef pageGroup, bool enabled);
......
......@@ -248,18 +248,6 @@ void InjectedBundle::setPluginsEnabled(WebPageGroupProxy* pageGroup, bool enable
(*iter)->settings()->setPluginsEnabled(enabled);
}
void InjectedBundle::setGeoLocationPermission(WebPageGroupProxy* pageGroup, bool enabled)
{
#if ENABLE(GEOLOCATION)
const HashSet<Page*>& pages = PageGroup::pageGroup(pageGroup->identifier())->pages();
for (HashSet<Page*>::iterator iter = pages.begin(); iter != pages.end(); ++iter)
static_cast<GeolocationClientMock*>(GeolocationController::from(*iter)->client())->setPermission(enabled);
#else
UNUSED_PARAM(pageGroup);
UNUSED_PARAM(enabled);
#endif // ENABLE(GEOLOCATION)
}
void InjectedBundle::setJavaScriptCanAccessClipboard(WebPageGroupProxy* pageGroup, bool enabled)
{
const HashSet<Page*>& pages = PageGroup::pageGroup(pageGroup->identifier())->pages();
......
......@@ -111,7 +111,6 @@ public:
void setMinimumLogicalFontSize(WebPageGroupProxy*, int size);
void setFrameFlatteningEnabled(WebPageGroupProxy*, bool);
void setPluginsEnabled(WebPageGroupProxy*, bool);
void setGeoLocationPermission(WebPageGroupProxy*, bool);
void setJavaScriptCanAccessClipboard(WebPageGroupProxy*, bool);
void setPrivateBrowsingEnabled(WebPageGroupProxy*, bool);
void setPopupBlockingEnabled(WebPageGroupProxy*, bool);
......
2012-09-21 Benjamin Poulain <bpoulain@apple.com>
[WK2] Add basic testing support for Geolocation
https://bugs.webkit.org/show_bug.cgi?id=97278
Reviewed by Kenneth Rohde Christiansen.
Update the Geolocation testing to use the proper API in the UIProcess.
* WebKitTestRunner/CMakeLists.txt:
* WebKitTestRunner/GNUmakefile.am:
* WebKitTestRunner/GeolocationProviderMock.cpp: Added.
(WTR::startUpdatingCallback):
(WTR::stopUpdatingCallback):
(WTR::GeolocationProviderMock::GeolocationProvierMock):
(WTR::GeolocationProviderMock::setMockGeolocationPosition):
(WTR::GeolocationProviderMock::startUpdating):
(WTR::GeolocationProviderMock::stopUpdating):
(GeolocationProviderMock):
The GeolocationProvider store the location update and deliver them as needed.
WebCore GeolocationController do not support asynchronous update on start/stop. This is not
a problem in this case because all the messages between the WebProcess and the UIProcess are
asynchronous. Because of this, unlike GeolocationClientMock, we do not use a timer for event
delivery.
* WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl:
* WebKitTestRunner/InjectedBundle/InjectedBundle.cpp:
(WTR::InjectedBundle::setGeolocationPermission):
(WTR::InjectedBundle::setMockGeolocationPosition):
* WebKitTestRunner/InjectedBundle/InjectedBundle.h:
(InjectedBundle):
* WebKitTestRunner/InjectedBundle/TestRunner.cpp:
(WTR::TestRunner::setGeolocationPermission):
(WTR::TestRunner::setMockGeolocationPosition):
From the InjectedBundle, we now pass the information to the UIProcess so that
GeolocationProvider and the TestController can respond appropriately.
* WebKitTestRunner/InjectedBundle/TestRunner.h:
(TestRunner):
* WebKitTestRunner/Target.pri:
* WebKitTestRunner/TestController.cpp:
(WTR::TestController::TestController):
(WTR::decidePolicyForGeolocationPermissionRequest):
(WTR::TestController::createOtherPage):
(WTR::TestController::initialize):
(WTR::TestController::setMockGeolocationPosition):
* WebKitTestRunner/TestController.h:
(TestController):
(WTR::TestController::setGeolocationPermission):
(WTR::TestController::isGeolocationPermissionAllowed):
* WebKitTestRunner/TestInvocation.cpp:
(WTR::TestInvocation::didReceiveMessageFromInjectedBundle):
* WebKitTestRunner/WebKitTestRunner.xcodeproj/project.pbxproj:
* WebKitTestRunner/win/WebKitTestRunner.vcproj:
2012-09-21 Joanmarie Diggs <jdiggs@igalia.com>
REGRESSION (r127882): accessibility/spinbutton-value.html failing on GTK
......@@ -5,6 +5,7 @@ FILE(MAKE_DIRECTORY ${DERIVED_SOURCES_DIR}/InjectedBundle)
SET(WebKitTestRunner_SOURCES
${WEBKIT_TESTRUNNER_DIR}/CyclicRedundancyCheck.cpp
${WEBKIT_TESTRUNNER_DIR}/GeolocationProviderMock.cpp
${WEBKIT_TESTRUNNER_DIR}/PixelDumpSupport.cpp
${WEBKIT_TESTRUNNER_DIR}/TestController.cpp
${WEBKIT_TESTRUNNER_DIR}/TestInvocation.cpp
......
......@@ -19,6 +19,8 @@ Programs_WebKitTestRunner_SOURCES = \
Tools/WebKitTestRunner/cairo/TestInvocationCairo.cpp \
Tools/WebKitTestRunner/CyclicRedundancyCheck.cpp \
Tools/WebKitTestRunner/CyclicRedundancyCheck.h \
Tools/WebKitTestRunner/GeolocationProviderMock.cpp \
Tools/WebKitTestRunner/GeolocationProviderMock.h \
Tools/WebKitTestRunner/PixelDumpSupport.cpp \
Tools/WebKitTestRunner/PixelDumpSupport.h \
Tools/WebKitTestRunner/PlatformWebView.h \
......
/*
* Copyright (C) 2012 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 "GeolocationProviderMock.h"
#include <WebKit2/WKGeolocationManager.h>
#include <wtf/Assertions.h>
#include <wtf/CurrentTime.h>
namespace WTR {
static void startUpdatingCallback(WKGeolocationManagerRef geolocationManager, const void* clientInfo)
{
GeolocationProviderMock* geolocationProvider = static_cast<GeolocationProviderMock*>(const_cast<void*>(clientInfo));
geolocationProvider->startUpdating(geolocationManager);
}
static void stopUpdatingCallback(WKGeolocationManagerRef geolocationManager, const void* clientInfo)
{
GeolocationProviderMock* geolocationProvider = static_cast<GeolocationProviderMock*>(const_cast<void*>(clientInfo));
geolocationProvider->stopUpdating(geolocationManager);
}
GeolocationProviderMock::GeolocationProviderMock(WKContextRef context)
: m_isActive(false)
{
m_geolocationManager = WKContextGetGeolocationManager(context);
WKGeolocationProvider providerCallback = {
kWKGeolocationProviderCurrentVersion,
this,
startUpdatingCallback,
stopUpdatingCallback };
WKGeolocationManagerSetProvider(m_geolocationManager, &providerCallback);
}
void GeolocationProviderMock::setMockGeolocationPosition(double latitude, double longitude, double accuracy)
{
m_position.adopt(WKGeolocationPositionCreate(currentTime(), latitude, longitude, accuracy));
if (m_isActive)
WKGeolocationManagerProviderDidChangePosition(m_geolocationManager, m_position.get());
}
void GeolocationProviderMock::startUpdating(WKGeolocationManagerRef geolocationManager)
{
ASSERT_UNUSED(geolocationManager, geolocationManager == m_geolocationManager);
m_isActive = true;
if (m_position)
WKGeolocationManagerProviderDidChangePosition(m_geolocationManager, m_position.get());
}
void GeolocationProviderMock::stopUpdating(WKGeolocationManagerRef geolocationManager)
{
ASSERT_UNUSED(geolocationManager, geolocationManager == m_geolocationManager);
m_isActive = false;
}
} // namespace WTR
/*
* Copyright (C) 2012 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.
*/
#ifndef GeolocationProviderMock_h
#define GeolocationProviderMock_h
#include <WebKit2/WKRetainPtr.h>
namespace WTR {
class GeolocationProviderMock {
public:
GeolocationProviderMock(WKContextRef);
void setMockGeolocationPosition(double latitude, double longitude, double accuracy);
void startUpdating(WKGeolocationManagerRef);
void stopUpdating(WKGeolocationManagerRef);
private:
WKGeolocationManagerRef m_geolocationManager;
bool m_isActive;
WKRetainPtr<WKGeolocationPositionRef> m_position;
};
} // namespace WTR
#endif // GeolocationProviderMock_h
......@@ -60,7 +60,6 @@ module WTR {
void setAllowFileAccessFromFileURLs(in boolean value);
void setFrameFlatteningEnabled(in boolean value);
void setPluginsEnabled(in boolean value);
void setGeolocationPermission(in boolean value);
void setJavaScriptCanAccessClipboard(in boolean value);
void setPrivateBrowsingEnabled(in boolean value);
void setPopupBlockingEnabled(in boolean value);
......@@ -179,6 +178,10 @@ module WTR {
void removeAllWebNotificationPermissions();
void simulateWebNotificationClick(in object notification);
// Geolocation
void setGeolocationPermission(in boolean value);
void setMockGeolocationPosition(in double latitude, in double longitude, in double accuracy);
boolean callShouldCloseOnWebView();
};
......
......@@ -358,4 +358,32 @@ void InjectedBundle::postSimulateWebNotificationClick(uint64_t notificationID)
WKBundlePostMessage(m_bundle, messageName.get(), messageBody.get());
}
void InjectedBundle::setGeolocationPermission(bool enabled)
{
WKRetainPtr<WKStringRef> messageName(AdoptWK, WKStringCreateWithUTF8CString("SetGeolocationPermission"));
WKRetainPtr<WKBooleanRef> messageBody(AdoptWK, WKBooleanCreate(enabled));
WKBundlePostMessage(m_bundle, messageName.get(), messageBody.get());
}
void InjectedBundle::setMockGeolocationPosition(double latitude, double longitude, double accuracy)
{
WKRetainPtr<WKStringRef> messageName(AdoptWK, WKStringCreateWithUTF8CString("SetMockGeolocationPosition"));
WKRetainPtr<WKMutableDictionaryRef> messageBody(AdoptWK, WKMutableDictionaryCreate());
WKRetainPtr<WKStringRef> latitudeKeyWK(AdoptWK, WKStringCreateWithUTF8CString("latitude"));
WKRetainPtr<WKDoubleRef> latitudeWK(AdoptWK, WKDoubleCreate(latitude));
WKDictionaryAddItem(messageBody.get(), latitudeKeyWK.get(), latitudeWK.get());
WKRetainPtr<WKStringRef> longitudeKeyWK(AdoptWK, WKStringCreateWithUTF8CString("longitude"));
WKRetainPtr<WKDoubleRef> longitudeWK(AdoptWK, WKDoubleCreate(longitude));
WKDictionaryAddItem(messageBody.get(), longitudeKeyWK.get(), longitudeWK.get());
WKRetainPtr<WKStringRef> accuracyKeyWK(AdoptWK, WKStringCreateWithUTF8CString("accuracy"));
WKRetainPtr<WKDoubleRef> accuracyWK(AdoptWK, WKDoubleCreate(accuracy));
WKDictionaryAddItem(messageBody.get(), accuracyKeyWK.get(), accuracyWK.get());
WKBundlePostMessage(m_bundle, messageName.get(), messageBody.get());
}
} // namespace WTR
......@@ -90,6 +90,10 @@ public:
void postSetWindowIsKey(bool);
void postSimulateWebNotificationClick(uint64_t notificationID);
// Geolocation.
void setGeolocationPermission(bool);
void setMockGeolocationPosition(double latitude, double longitude, double accuracy);
private:
InjectedBundle();
~InjectedBundle();
......
......@@ -393,11 +393,6 @@ void TestRunner::setPluginsEnabled(bool enabled)
WKBundleSetPluginsEnabled(InjectedBundle::shared().bundle(), InjectedBundle::shared().pageGroup(), enabled);
}
void TestRunner::setGeolocationPermission(bool enabled)
{
WKBundleSetGeolocationPermission(InjectedBundle::shared().bundle(), InjectedBundle::shared().pageGroup(), enabled);
}
void TestRunner::setJavaScriptCanAccessClipboard(bool enabled)
{
WKBundleSetJavaScriptCanAccessClipboard(InjectedBundle::shared().bundle(), InjectedBundle::shared().pageGroup(), enabled);
......@@ -772,6 +767,17 @@ void TestRunner::simulateWebNotificationClick(JSValueRef notification)
InjectedBundle::shared().postSimulateWebNotificationClick(notificationID);
}
void TestRunner::setGeolocationPermission(bool enabled)
{
// FIXME: this should be done by frame.
InjectedBundle::shared().setGeolocationPermission(enabled);
}
void TestRunner::setMockGeolocationPosition(double latitude, double longitude, double accuracy)
{
InjectedBundle::shared().setMockGeolocationPosition(latitude, longitude, accuracy);
}
bool TestRunner::callShouldCloseOnWebView()
{
WKBundleFrameRef mainFrame = WKBundlePageGetMainFrame(InjectedBundle::shared().page()->page());
......
......@@ -98,7 +98,6 @@ public:
void setAllowFileAccessFromFileURLs(bool);
void setFrameFlatteningEnabled(bool);
void setPluginsEnabled(bool);
void setGeolocationPermission(bool);
void setJavaScriptCanAccessClipboard(bool);
void setPrivateBrowsingEnabled(bool);
void setPopupBlockingEnabled(bool);
......@@ -248,6 +247,10 @@ public:
void removeAllWebNotificationPermissions();
void simulateWebNotificationClick(JSValueRef notification);
// Geolocation.
void setGeolocationPermission(bool);
void setMockGeolocationPosition(double latitude, double longitude, double accuracy);
JSRetainPtr<JSStringRef> platformName();
void setPageVisibility(JSStringRef state);
......
......@@ -10,6 +10,7 @@ TARGET = WebKitTestRunner
HEADERS += \
$${ROOT_WEBKIT_DIR}/Tools/DumpRenderTree/qt/QtInitializeTestFonts.h \
EventSenderProxy.h \
GeolocationProviderMock.h \
PlatformWebView.h \
StringFunctions.h \
TestController.h \
......@@ -23,6 +24,7 @@ SOURCES += \
qt/PlatformWebViewQt.cpp \
qt/TestControllerQt.cpp \
qt/TestInvocationQt.cpp \
GeolocationProviderMock.cpp \
TestController.cpp \
TestInvocation.cpp \
WebNotificationProvider.cpp
......
......@@ -91,6 +91,7 @@ TestController::TestController(int argc, const char* argv[])
, m_didPrintWebProcessCrashedMessage(false)
, m_shouldExitWhenWebProcessCrashes(true)
, m_beforeUnloadReturnValue(true)
, m_isGeolocationPermissionAllowed(false)
#if PLATFORM(MAC) || PLATFORM(QT) || PLATFORM(GTK) || PLATFORM(EFL)
, m_eventSenderProxy(new EventSenderProxy(this))
#endif
......@@ -170,6 +171,15 @@ static void unfocus(WKPageRef page, const void* clientInfo)
view->setWindowIsKey(false);
}
static void decidePolicyForGeolocationPermissionRequest(WKPageRef, WKFrameRef, WKSecurityOriginRef, WKGeolocationPermissionRequestRef permissionRequest, const void* clientInfo)
{
TestController* testController = static_cast<TestController*>(const_cast<void*>(clientInfo));
if (testController->isGeolocationPermissionAllowed())
WKGeolocationPermissionRequestAllow(permissionRequest);
else
WKGeolocationPermissionRequestDeny(permissionRequest);
}
WKPageRef TestController::createOtherPage(WKPageRef oldPage, WKURLRequestRef, WKDictionaryRef, WKEventModifiers, WKEventMouseButton, const void*)
{
PlatformWebView* view = new PlatformWebView(WKPageGetContext(oldPage), WKPageGetPageGroup(oldPage));
......@@ -209,7 +219,7 @@ WKPageRef TestController::createOtherPage(WKPageRef oldPage, WKURLRequestRef, WK
0, // pageDidScroll
exceededDatabaseQuota,
0, // runOpenPanel
0, // decidePolicyForGeolocationPermissionRequest
decidePolicyForGeolocationPermissionRequest,
0, // headerHeight
0, // footerHeight
0, // drawHeader
......@@ -318,6 +328,7 @@ void TestController::initialize(int argc, const char* argv[])
m_pageGroup.adopt(WKPageGroupCreateWithIdentifier(pageGroupIdentifier.get()));
m_context.adopt(WKContextCreateWithInjectedBundlePath(injectedBundlePath()));
m_geolocationProvider = adoptPtr(new GeolocationProviderMock(m_context.get()));
const char* path = libraryPathForTesting();
if (path) {
......@@ -379,7 +390,7 @@ void TestController::initialize(int argc, const char* argv[])
0, // pageDidScroll
exceededDatabaseQuota,
0, // runOpenPanel
0, // decidePolicyForGeolocationPermissionRequest
decidePolicyForGeolocationPermissionRequest,
0, // headerHeight
0, // footerHeight
0, // drawHeader
......@@ -988,6 +999,11 @@ void TestController::simulateWebNotificationClick(uint64_t notificationID)
m_webNotificationProvider.simulateWebNotificationClick(notificationID);
}
void TestController::setMockGeolocationPosition(double latitude, double longitude, double accuracy)
{
m_geolocationProvider->setMockGeolocationPosition(latitude, longitude, accuracy);
}
void TestController::decidePolicyForNotificationPermissionRequest(WKPageRef page, WKSecurityOriginRef origin, WKNotificationPermissionRequestRef request, const void* clientInfo)
{
static_cast<TestController*>(const_cast<void*>(clientInfo))->decidePolicyForNotificationPermissionRequest(page, origin, request);
......
......@@ -27,6 +27,7 @@
#define TestController_h
#include "WebNotificationProvider.h"
#include <GeolocationProviderMock.h>
#include <WebKit2/WKRetainPtr.h>
#include <string>
#include <vector>
......@@ -65,6 +66,11 @@ public:
void simulateWebNotificationClick(uint64_t notificationID);
// Geolocation.
void setGeolocationPermission(bool enabled) { m_isGeolocationPermissionAllowed = enabled; }
bool isGeolocationPermissionAllowed() const { return m_isGeolocationPermissionAllowed; }
void setMockGeolocationPosition(double latitude, double longitude, double accuracy);
bool resetStateToConsistentValues();
private:
......@@ -123,6 +129,7 @@ private:
OwnPtr<PlatformWebView> m_mainWebView;
WKRetainPtr<WKContextRef> m_context;
WKRetainPtr<WKPageGroupRef> m_pageGroup;
OwnPtr<GeolocationProviderMock> m_geolocationProvider;
enum State {
Initial,
......@@ -143,6 +150,8 @@ private:
bool m_beforeUnloadReturnValue;
bool m_isGeolocationPermissionAllowed;
EventSenderProxy* m_eventSenderProxy;
};
......
......@@ -346,6 +346,33 @@ void TestInvocation::didReceiveMessageFromInjectedBundle(WKStringRef messageName
return;
}
if (WKStringIsEqualToUTF8CString(messageName, "SetGeolocationPermission")) {
ASSERT(WKGetTypeID(messageBody) == WKBooleanGetTypeID());
WKBooleanRef enabledWK = static_cast<WKBooleanRef>(messageBody);
TestController::shared().setGeolocationPermission(WKBooleanGetValue(enabledWK));
return;
}
if (WKStringIsEqualToUTF8CString(messageName, "SetMockGeolocationPosition")) {
ASSERT(WKGetTypeID(messageBody) == WKDictionaryGetTypeID());
WKDictionaryRef messageBodyDictionary = static_cast<WKDictionaryRef>(messageBody);
WKRetainPtr<WKStringRef> latitudeKeyWK(AdoptWK, WKStringCreateWithUTF8CString("latitude"));
WKDoubleRef latitudeWK = static_cast<WKDoubleRef>(WKDictionaryGetItemForKey(messageBodyDictionary, latitudeKeyWK.get()));
double latitude = WKDoubleGetValue(latitudeWK);
WKRetainPtr<WKStringRef> longitudeKeyWK(AdoptWK, WKStringCreateWithUTF8CString("longitude"));
WKDoubleRef longitudeWK = static_cast<WKDoubleRef>(WKDictionaryGetItemForKey(messageBodyDictionary, longitudeKeyWK.get()));
double longitude = WKDoubleGetValue(longitudeWK);
WKRetainPtr<WKStringRef> accuracyKeyWK(AdoptWK, WKStringCreateWithUTF8CString("accuracy"));
WKDoubleRef accuracyWK = static_cast<WKDoubleRef>(WKDictionaryGetItemForKey(messageBodyDictionary, accuracyKeyWK.get()));
double accuracy = WKDoubleGetValue(accuracyWK);
TestController::shared().setMockGeolocationPosition(latitude, longitude, accuracy);
return;
}
ASSERT_NOT_REACHED();
}
......
......@@ -23,6 +23,7 @@
/* Begin PBXBuildFile section */
0F5169CB1445222D00E0A9D7 /* WebKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0F5169CA1445222D00E0A9D7 /* WebKit.framework */; };
0F5169CC1445222D00E0A9D7 /* WebKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0F5169CA1445222D00E0A9D7 /* WebKit.framework */; };
26D758E7160BECDD00268472 /* GeolocationProviderMock.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26D758E5160BECDC00268472 /* GeolocationProviderMock.cpp */; };
29210EAE144CACB700835BB5 /* AccessibilityUIElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 29210EA9144CACB200835BB5 /* AccessibilityUIElement.cpp */; };
29210EB0144CACBD00835BB5 /* AccessibilityController.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 29210EA2144CAAA500835BB5 /* AccessibilityController.cpp */; };