Title: [129252] trunk
Revision
129252
Author
[email protected]
Date
2012-09-21 14:06:05 -0700 (Fri, 21 Sep 2012)

Log Message

[WK2] Add basic testing support for Geolocation
https://bugs.webkit.org/show_bug.cgi?id=97278

Patch by Benjamin Poulain <[email protected]> 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.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (129251 => 129252)


--- trunk/LayoutTests/ChangeLog	2012-09-21 21:02:37 UTC (rev 129251)
+++ trunk/LayoutTests/ChangeLog	2012-09-21 21:06:05 UTC (rev 129252)
@@ -1,3 +1,12 @@
+2012-09-21  Benjamin Poulain  <[email protected]>
+
+        [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  <[email protected]>
 
         REGRESSION (r127882): accessibility/spinbutton-value.html failing on GTK

Modified: trunk/LayoutTests/platform/wk2/Skipped (129251 => 129252)


--- trunk/LayoutTests/platform/wk2/Skipped	2012-09-21 21:02:37 UTC (rev 129251)
+++ trunk/LayoutTests/platform/wk2/Skipped	2012-09-21 21:06:05 UTC (rev 129252)
@@ -288,40 +288,16 @@
 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
 

Modified: trunk/Source/WebKit2/ChangeLog (129251 => 129252)


--- trunk/Source/WebKit2/ChangeLog	2012-09-21 21:02:37 UTC (rev 129251)
+++ trunk/Source/WebKit2/ChangeLog	2012-09-21 21:06:05 UTC (rev 129252)
@@ -1,3 +1,20 @@
+2012-09-21  Benjamin Poulain  <[email protected]>
+
+        [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  <[email protected]>
 
         [WK2] Make Web Inspector work in multiple web process mode

Modified: trunk/Source/WebKit2/Shared/API/c/WKNumber.h (129251 => 129252)


--- trunk/Source/WebKit2/Shared/API/c/WKNumber.h	2012-09-21 21:02:37 UTC (rev 129251)
+++ trunk/Source/WebKit2/Shared/API/c/WKNumber.h	2012-09-21 21:06:05 UTC (rev 129252)
@@ -45,7 +45,7 @@
 /* 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
 }

Modified: trunk/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundle.cpp (129251 => 129252)


--- trunk/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundle.cpp	2012-09-21 21:02:37 UTC (rev 129251)
+++ trunk/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundle.cpp	2012-09-21 21:06:05 UTC (rev 129252)
@@ -162,11 +162,6 @@
     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);

Modified: trunk/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePrivate.h (129251 => 129252)


--- trunk/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePrivate.h	2012-09-21 21:02:37 UTC (rev 129251)
+++ trunk/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePrivate.h	2012-09-21 21:06:05 UTC (rev 129252)
@@ -60,7 +60,6 @@
 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);

Modified: trunk/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundle.cpp (129251 => 129252)


--- trunk/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundle.cpp	2012-09-21 21:02:37 UTC (rev 129251)
+++ trunk/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundle.cpp	2012-09-21 21:06:05 UTC (rev 129252)
@@ -248,18 +248,6 @@
         (*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();

Modified: trunk/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundle.h (129251 => 129252)


--- trunk/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundle.h	2012-09-21 21:02:37 UTC (rev 129251)
+++ trunk/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundle.h	2012-09-21 21:06:05 UTC (rev 129252)
@@ -111,7 +111,6 @@
     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);

Modified: trunk/Tools/ChangeLog (129251 => 129252)


--- trunk/Tools/ChangeLog	2012-09-21 21:02:37 UTC (rev 129251)
+++ trunk/Tools/ChangeLog	2012-09-21 21:06:05 UTC (rev 129252)
@@ -1,3 +1,60 @@
+2012-09-21  Benjamin Poulain  <[email protected]>
+
+        [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  <[email protected]>
 
         REGRESSION (r127882): accessibility/spinbutton-value.html failing on GTK

Modified: trunk/Tools/WebKitTestRunner/CMakeLists.txt (129251 => 129252)


--- trunk/Tools/WebKitTestRunner/CMakeLists.txt	2012-09-21 21:02:37 UTC (rev 129251)
+++ trunk/Tools/WebKitTestRunner/CMakeLists.txt	2012-09-21 21:06:05 UTC (rev 129252)
@@ -5,6 +5,7 @@
 
 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

Modified: trunk/Tools/WebKitTestRunner/GNUmakefile.am (129251 => 129252)


--- trunk/Tools/WebKitTestRunner/GNUmakefile.am	2012-09-21 21:02:37 UTC (rev 129251)
+++ trunk/Tools/WebKitTestRunner/GNUmakefile.am	2012-09-21 21:06:05 UTC (rev 129252)
@@ -19,6 +19,8 @@
 	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 \

Added: trunk/Tools/WebKitTestRunner/GeolocationProviderMock.cpp (0 => 129252)


--- trunk/Tools/WebKitTestRunner/GeolocationProviderMock.cpp	                        (rev 0)
+++ trunk/Tools/WebKitTestRunner/GeolocationProviderMock.cpp	2012-09-21 21:06:05 UTC (rev 129252)
@@ -0,0 +1,83 @@
+/*
+ * 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

Added: trunk/Tools/WebKitTestRunner/GeolocationProviderMock.h (0 => 129252)


--- trunk/Tools/WebKitTestRunner/GeolocationProviderMock.h	                        (rev 0)
+++ trunk/Tools/WebKitTestRunner/GeolocationProviderMock.h	2012-09-21 21:06:05 UTC (rev 129252)
@@ -0,0 +1,51 @@
+/*
+ * 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

Modified: trunk/Tools/WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl (129251 => 129252)


--- trunk/Tools/WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl	2012-09-21 21:02:37 UTC (rev 129251)
+++ trunk/Tools/WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl	2012-09-21 21:06:05 UTC (rev 129252)
@@ -60,7 +60,6 @@
         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 @@
         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();
     };
 

Modified: trunk/Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.cpp (129251 => 129252)


--- trunk/Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.cpp	2012-09-21 21:02:37 UTC (rev 129251)
+++ trunk/Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.cpp	2012-09-21 21:06:05 UTC (rev 129252)
@@ -358,4 +358,32 @@
     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

Modified: trunk/Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.h (129251 => 129252)


--- trunk/Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.h	2012-09-21 21:02:37 UTC (rev 129251)
+++ trunk/Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.h	2012-09-21 21:06:05 UTC (rev 129252)
@@ -90,6 +90,10 @@
     void postSetWindowIsKey(bool);
     void postSimulateWebNotificationClick(uint64_t notificationID);
 
+    // Geolocation.
+    void setGeolocationPermission(bool);
+    void setMockGeolocationPosition(double latitude, double longitude, double accuracy);
+
 private:
     InjectedBundle();
     ~InjectedBundle();

Modified: trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp (129251 => 129252)


--- trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp	2012-09-21 21:02:37 UTC (rev 129251)
+++ trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp	2012-09-21 21:06:05 UTC (rev 129252)
@@ -393,11 +393,6 @@
     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 @@
     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());

Modified: trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.h (129251 => 129252)


--- trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.h	2012-09-21 21:02:37 UTC (rev 129251)
+++ trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.h	2012-09-21 21:06:05 UTC (rev 129252)
@@ -98,7 +98,6 @@
     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 @@
     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);

Modified: trunk/Tools/WebKitTestRunner/Target.pri (129251 => 129252)


--- trunk/Tools/WebKitTestRunner/Target.pri	2012-09-21 21:02:37 UTC (rev 129251)
+++ trunk/Tools/WebKitTestRunner/Target.pri	2012-09-21 21:06:05 UTC (rev 129252)
@@ -10,6 +10,7 @@
 HEADERS += \
     $${ROOT_WEBKIT_DIR}/Tools/DumpRenderTree/qt/QtInitializeTestFonts.h \
     EventSenderProxy.h \
+    GeolocationProviderMock.h \
     PlatformWebView.h \
     StringFunctions.h \
     TestController.h \
@@ -23,6 +24,7 @@
     qt/PlatformWebViewQt.cpp \
     qt/TestControllerQt.cpp \
     qt/TestInvocationQt.cpp \
+    GeolocationProviderMock.cpp \
     TestController.cpp \
     TestInvocation.cpp \
     WebNotificationProvider.cpp

Modified: trunk/Tools/WebKitTestRunner/TestController.cpp (129251 => 129252)


--- trunk/Tools/WebKitTestRunner/TestController.cpp	2012-09-21 21:02:37 UTC (rev 129251)
+++ trunk/Tools/WebKitTestRunner/TestController.cpp	2012-09-21 21:06:05 UTC (rev 129252)
@@ -91,6 +91,7 @@
     , 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 @@
     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 @@
         0, // pageDidScroll
         exceededDatabaseQuota,
         0, // runOpenPanel
-        0, // decidePolicyForGeolocationPermissionRequest
+        decidePolicyForGeolocationPermissionRequest,
         0, // headerHeight
         0, // footerHeight
         0, // drawHeader
@@ -318,6 +328,7 @@
     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 @@
         0, // pageDidScroll
         exceededDatabaseQuota,
         0, // runOpenPanel
-        0, // decidePolicyForGeolocationPermissionRequest
+        decidePolicyForGeolocationPermissionRequest,
         0, // headerHeight
         0, // footerHeight
         0, // drawHeader
@@ -988,6 +999,11 @@
     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);

Modified: trunk/Tools/WebKitTestRunner/TestController.h (129251 => 129252)


--- trunk/Tools/WebKitTestRunner/TestController.h	2012-09-21 21:02:37 UTC (rev 129251)
+++ trunk/Tools/WebKitTestRunner/TestController.h	2012-09-21 21:06:05 UTC (rev 129252)
@@ -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 @@
 
     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 @@
     OwnPtr<PlatformWebView> m_mainWebView;
     WKRetainPtr<WKContextRef> m_context;
     WKRetainPtr<WKPageGroupRef> m_pageGroup;
+    OwnPtr<GeolocationProviderMock> m_geolocationProvider;
 
     enum State {
         Initial,
@@ -143,6 +150,8 @@
     
     bool m_beforeUnloadReturnValue;
 
+    bool m_isGeolocationPermissionAllowed;
+
     EventSenderProxy* m_eventSenderProxy;
 };
 

Modified: trunk/Tools/WebKitTestRunner/TestInvocation.cpp (129251 => 129252)


--- trunk/Tools/WebKitTestRunner/TestInvocation.cpp	2012-09-21 21:02:37 UTC (rev 129251)
+++ trunk/Tools/WebKitTestRunner/TestInvocation.cpp	2012-09-21 21:06:05 UTC (rev 129252)
@@ -346,6 +346,33 @@
         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();
 }
 

Modified: trunk/Tools/WebKitTestRunner/WebKitTestRunner.xcodeproj/project.pbxproj (129251 => 129252)


--- trunk/Tools/WebKitTestRunner/WebKitTestRunner.xcodeproj/project.pbxproj	2012-09-21 21:02:37 UTC (rev 129251)
+++ trunk/Tools/WebKitTestRunner/WebKitTestRunner.xcodeproj/project.pbxproj	2012-09-21 21:06:05 UTC (rev 129252)
@@ -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 */; };
 		29210EB4144CACD500835BB5 /* AccessibilityTextMarker.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 29210EB1144CACD400835BB5 /* AccessibilityTextMarker.cpp */; };
@@ -100,6 +101,8 @@
 
 /* Begin PBXFileReference section */
 		0F5169CA1445222D00E0A9D7 /* WebKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = WebKit.framework; sourceTree = BUILT_PRODUCTS_DIR; };
+		26D758E5160BECDC00268472 /* GeolocationProviderMock.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GeolocationProviderMock.cpp; sourceTree = "<group>"; };
+		26D758E6160BECDD00268472 /* GeolocationProviderMock.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GeolocationProviderMock.h; sourceTree = "<group>"; };
 		29210EA2144CAAA500835BB5 /* AccessibilityController.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AccessibilityController.cpp; sourceTree = "<group>"; };
 		29210EA3144CAAA500835BB5 /* AccessibilityController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AccessibilityController.h; sourceTree = "<group>"; };
 		29210EA8144CAB8800835BB5 /* AccessibilityController.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = AccessibilityController.idl; sourceTree = "<group>"; };
@@ -255,6 +258,8 @@
 				5322FB4113FDA0CD0041ABCC /* CyclicRedundancyCheck.cpp */,
 				5322FB4213FDA0CD0041ABCC /* CyclicRedundancyCheck.h */,
 				5670B8261386FC13002EB355 /* EventSenderProxy.h */,
+				26D758E5160BECDC00268472 /* GeolocationProviderMock.cpp */,
+				26D758E6160BECDD00268472 /* GeolocationProviderMock.h */,
 				5322FB4413FDA0EA0041ABCC /* PixelDumpSupport.cpp */,
 				5322FB4513FDA0EA0041ABCC /* PixelDumpSupport.h */,
 				BC7934DD119066EC005EA8E2 /* PlatformWebView.h */,
@@ -565,6 +570,7 @@
 			files = (
 				BC793400118F7C84005EA8E2 /* main.mm in Sources */,
 				5322FB4313FDA0CD0041ABCC /* CyclicRedundancyCheck.cpp in Sources */,
+				26D758E7160BECDD00268472 /* GeolocationProviderMock.cpp in Sources */,
 				5322FB4613FDA0EA0041ABCC /* PixelDumpSupport.cpp in Sources */,
 				BC7934E811906846005EA8E2 /* PlatformWebViewMac.mm in Sources */,
 				BC793431118F7F19005EA8E2 /* TestController.cpp in Sources */,

Modified: trunk/Tools/WebKitTestRunner/win/WebKitTestRunner.vcproj (129251 => 129252)


--- trunk/Tools/WebKitTestRunner/win/WebKitTestRunner.vcproj	2012-09-21 21:02:37 UTC (rev 129251)
+++ trunk/Tools/WebKitTestRunner/win/WebKitTestRunner.vcproj	2012-09-21 21:06:05 UTC (rev 129252)
@@ -479,6 +479,14 @@
 			>
 		</File>
 		<File
+			RelativePath="..\GeolocationProviderMock.cpp"
+			>
+		</File>
+		<File
+			RelativePath="..\GeolocationProviderMock.h"
+			>
+		</File>
+		<File
 			RelativePath="..\PixelDumpSupport.cpp"
 			>
 		</File>
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to