Title: [188068] trunk
Revision
188068
Author
cdu...@apple.com
Date
2015-08-06 15:37:47 -0700 (Thu, 06 Aug 2015)

Log Message

Toggle GPS state based on page visibility to save battery
https://bugs.webkit.org/show_bug.cgi?id=147685

Reviewed by Benjamin Poulain.

Source/WebCore:

Toggle GPS state based on page visibility to save battery. Previously,
if the site you were viewing was watching your position and you
switched tab, the GPS would stay on. This was bad for battery life.

Tests: fast/dom/Geolocation/startUpdatingOnlyWhenPageVisible.html
       fast/dom/Geolocation/stopUpdatingForHiddenPage.html

* Modules/geolocation/GeolocationController.cpp:
(WebCore::GeolocationController::addObserver):
(WebCore::GeolocationController::viewStateDidChange):

Tools:

Add testRunner.isGeolocationProviderActive() test support function.

* DumpRenderTree/TestRunner.cpp:
(isGeolocationProviderActiveCallback):
(TestRunner::staticFunctions):
* DumpRenderTree/TestRunner.h:
* DumpRenderTree/mac/MockGeolocationProvider.h:
* DumpRenderTree/mac/MockGeolocationProvider.mm:
(-[MockGeolocationProvider isActive]):
* DumpRenderTree/mac/TestRunnerMac.mm:
(TestRunner::isGeolocationProviderActive):
* DumpRenderTree/win/TestRunnerWin.cpp:
(TestRunner::isGeolocationProviderActive):
* WebKitTestRunner/GeolocationProviderMock.h:
(WTR::GeolocationProviderMock::isActive):
* WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl:
* WebKitTestRunner/InjectedBundle/InjectedBundle.cpp:
(WTR::InjectedBundle::isGeolocationProviderActive):
* WebKitTestRunner/InjectedBundle/InjectedBundle.h:
* WebKitTestRunner/InjectedBundle/TestRunner.cpp:
(WTR::TestRunner::isGeolocationProviderActive):
* WebKitTestRunner/InjectedBundle/TestRunner.h:
* WebKitTestRunner/TestController.cpp:
(WTR::TestController::isGeolocationProviderActive):
* WebKitTestRunner/TestController.h:
* WebKitTestRunner/TestInvocation.cpp:
(WTR::TestInvocation::didReceiveSynchronousMessageFromInjectedBundle):

LayoutTests:

Add layout tests to check that the GeolocationClient starts and stops
updating when page visibility changes.

* fast/dom/Geolocation/startUpdatingOnlyWhenPageVisible-expected.txt: Added.
* fast/dom/Geolocation/startUpdatingOnlyWhenPageVisible.html: Added.
* fast/dom/Geolocation/stopUpdatingForHiddenPage-expected.txt: Added.
* fast/dom/Geolocation/stopUpdatingForHiddenPage.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (188067 => 188068)


--- trunk/LayoutTests/ChangeLog	2015-08-06 22:36:34 UTC (rev 188067)
+++ trunk/LayoutTests/ChangeLog	2015-08-06 22:37:47 UTC (rev 188068)
@@ -1,3 +1,18 @@
+2015-08-06  Chris Dumez  <cdu...@apple.com>
+
+        Toggle GPS state based on page visibility to save battery
+        https://bugs.webkit.org/show_bug.cgi?id=147685
+
+        Reviewed by Benjamin Poulain.
+
+        Add layout tests to check that the GeolocationClient starts and stops
+        updating when page visibility changes.
+
+        * fast/dom/Geolocation/startUpdatingOnlyWhenPageVisible-expected.txt: Added.
+        * fast/dom/Geolocation/startUpdatingOnlyWhenPageVisible.html: Added.
+        * fast/dom/Geolocation/stopUpdatingForHiddenPage-expected.txt: Added.
+        * fast/dom/Geolocation/stopUpdatingForHiddenPage.html: Added.
+
 2015-08-06  Brian Burg  <bb...@apple.com>
 
         Web Inspector: move http/tests/inspector-protocol/ contents to http/tests/inspector/

Added: trunk/LayoutTests/fast/dom/Geolocation/startUpdatingOnlyWhenPageVisible-expected.txt (0 => 188068)


--- trunk/LayoutTests/fast/dom/Geolocation/startUpdatingOnlyWhenPageVisible-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/dom/Geolocation/startUpdatingOnlyWhenPageVisible-expected.txt	2015-08-06 22:37:47 UTC (rev 188068)
@@ -0,0 +1,20 @@
+Tests that the GeolocationClient only starts updating when the page becomes visible
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+Page is initially visible
+PASS document.hidden is false
+PASS testRunner.isGeolocationProviderActive() is false
+Changing page visibility to 'hidden'
+Page visibility changed to false
+PASS testRunner.isGeolocationProviderActive() is false
+Adding Geolocation watcher
+PASS testRunner.isGeolocationProviderActive() is false
+Changing page visibility to 'visible'
+Page visibility changed to true
+PASS testRunner.isGeolocationProviderActive() became true
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/fast/dom/Geolocation/startUpdatingOnlyWhenPageVisible.html (0 => 188068)


--- trunk/LayoutTests/fast/dom/Geolocation/startUpdatingOnlyWhenPageVisible.html	                        (rev 0)
+++ trunk/LayoutTests/fast/dom/Geolocation/startUpdatingOnlyWhenPageVisible.html	2015-08-06 22:37:47 UTC (rev 188068)
@@ -0,0 +1,54 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src=""
+</head>
+<body _onload_="runTest()">
+<script>
+
+description("Tests that the GeolocationClient only starts updating when the page becomes visible");
+window.jsTestIsAsync = true;
+
+function geolocationWatchFunction()
+{
+}
+
+function checkNotUpdatingAndShowPage()
+{
+    shouldBeFalse("testRunner.isGeolocationProviderActive()");
+    debug("Changing page visibility to 'visible'");
+    testRunner.setPageVisibility("visible");
+}
+
+function onVisibilityChange() {
+    debug("Page visibility changed to " + !document.hidden);
+    if (document.hidden) {
+        shouldBeFalse("testRunner.isGeolocationProviderActive()");
+        debug("Adding Geolocation watcher");
+        navigator.geolocation.watchPosition(geolocationWatchFunction);
+        setTimeout(checkNotUpdatingAndShowPage, 50);
+    } else
+        shouldBecomeEqual("testRunner.isGeolocationProviderActive()", "true", finishJSTest);
+}
+
+document.addEventListener("visibilitychange", onVisibilityChange, false)
+
+if (window.testRunner) {
+    testRunner.setGeolocationPermission(true);
+    testRunner.setMockGeolocationPosition(1, 2, 3);
+}
+
+function runTest()
+{
+    debug("Page is initially visible");
+    shouldBeFalse("document.hidden");
+    shouldBeFalse("testRunner.isGeolocationProviderActive()");
+
+    debug("Changing page visibility to 'hidden'");
+    if (window.testRunner)
+        testRunner.setPageVisibility("hidden");
+}
+</script>
+<script src=""
+</body>
+</html>

Added: trunk/LayoutTests/fast/dom/Geolocation/stopUpdatingForHiddenPage-expected.txt (0 => 188068)


--- trunk/LayoutTests/fast/dom/Geolocation/stopUpdatingForHiddenPage-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/dom/Geolocation/stopUpdatingForHiddenPage-expected.txt	2015-08-06 22:37:47 UTC (rev 188068)
@@ -0,0 +1,20 @@
+Tests that the GeolocationClient stops updating when the page becomes hidden
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+Page is initially visible
+PASS document.hidden is false
+PASS testRunner.isGeolocationProviderActive() is false
+Adding Geolocation watcher
+PASS testRunner.isGeolocationProviderActive() became true
+Changing page visibility to 'hidden'
+Page visibility changed to false
+PASS testRunner.isGeolocationProviderActive() became false
+Changing page visibility to 'visible'
+Page visibility changed to true
+PASS testRunner.isGeolocationProviderActive() became true
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/fast/dom/Geolocation/stopUpdatingForHiddenPage.html (0 => 188068)


--- trunk/LayoutTests/fast/dom/Geolocation/stopUpdatingForHiddenPage.html	                        (rev 0)
+++ trunk/LayoutTests/fast/dom/Geolocation/stopUpdatingForHiddenPage.html	2015-08-06 22:37:47 UTC (rev 188068)
@@ -0,0 +1,58 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src=""
+</head>
+<body _onload_="runTest()">
+<script>
+
+description("Tests that the GeolocationClient stops updating when the page becomes hidden");
+window.jsTestIsAsync = true;
+
+function geolocationWatchFunction()
+{
+}
+
+function showPage()
+{
+    debug("Changing page visibility to 'visible'");
+    testRunner.setPageVisibility("visible");
+}
+
+function onVisibilityChange() {
+    debug("Page visibility changed to " + !document.hidden);
+    if (document.hidden)
+        shouldBecomeEqual("testRunner.isGeolocationProviderActive()", "false", showPage);
+    else
+        shouldBecomeEqual("testRunner.isGeolocationProviderActive()", "true", finishJSTest);
+}
+
+document.addEventListener("visibilitychange", onVisibilityChange, false)
+
+if (window.testRunner) {
+    testRunner.setGeolocationPermission(true);
+    testRunner.setMockGeolocationPosition(1, 2, 3);
+}
+
+function hidePage()
+{
+    debug("Changing page visibility to 'hidden'");
+    if (window.testRunner)
+        testRunner.setPageVisibility("hidden");
+}
+
+function runTest()
+{
+    debug("Page is initially visible");
+    shouldBeFalse("document.hidden");
+    shouldBeFalse("testRunner.isGeolocationProviderActive()");
+
+    debug("Adding Geolocation watcher");
+    navigator.geolocation.watchPosition(geolocationWatchFunction);
+
+    shouldBecomeEqual("testRunner.isGeolocationProviderActive()", "true", hidePage);
+}
+</script>
+<script src=""
+</body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (188067 => 188068)


--- trunk/Source/WebCore/ChangeLog	2015-08-06 22:36:34 UTC (rev 188067)
+++ trunk/Source/WebCore/ChangeLog	2015-08-06 22:37:47 UTC (rev 188068)
@@ -1,3 +1,21 @@
+2015-08-06  Chris Dumez  <cdu...@apple.com>
+
+        Toggle GPS state based on page visibility to save battery
+        https://bugs.webkit.org/show_bug.cgi?id=147685
+
+        Reviewed by Benjamin Poulain.
+
+        Toggle GPS state based on page visibility to save battery. Previously,
+        if the site you were viewing was watching your position and you
+        switched tab, the GPS would stay on. This was bad for battery life.
+
+        Tests: fast/dom/Geolocation/startUpdatingOnlyWhenPageVisible.html
+               fast/dom/Geolocation/stopUpdatingForHiddenPage.html
+
+        * Modules/geolocation/GeolocationController.cpp:
+        (WebCore::GeolocationController::addObserver):
+        (WebCore::GeolocationController::viewStateDidChange):
+
 2015-08-06  Anders Carlsson  <ander...@apple.com>
 
         SQLStatementBackend doesn't need to be refcounted

Modified: trunk/Source/WebCore/Modules/geolocation/GeolocationController.cpp (188067 => 188068)


--- trunk/Source/WebCore/Modules/geolocation/GeolocationController.cpp	2015-08-06 22:36:34 UTC (rev 188067)
+++ trunk/Source/WebCore/Modules/geolocation/GeolocationController.cpp	2015-08-06 22:37:47 UTC (rev 188068)
@@ -63,7 +63,7 @@
 
     if (enableHighAccuracy)
         m_client.setEnableHighAccuracy(true);
-    if (wasEmpty)
+    if (wasEmpty && m_page.isVisible())
         m_client.startUpdating();
 }
 
@@ -124,8 +124,17 @@
     return m_client.lastPosition();
 }
 
-void GeolocationController::viewStateDidChange(ViewState::Flags, ViewState::Flags)
+void GeolocationController::viewStateDidChange(ViewState::Flags oldViewState, ViewState::Flags newViewState)
 {
+    // Toggle GPS based on page visibility to save battery.
+    ViewState::Flags changed = oldViewState ^ newViewState;
+    if (changed & ViewState::IsVisible && !m_observers.isEmpty()) {
+        if (newViewState & ViewState::IsVisible)
+            m_client.startUpdating();
+        else
+            m_client.stopUpdating();
+    }
+
     if (!m_page.isVisible())
         return;
 

Modified: trunk/Tools/ChangeLog (188067 => 188068)


--- trunk/Tools/ChangeLog	2015-08-06 22:36:34 UTC (rev 188067)
+++ trunk/Tools/ChangeLog	2015-08-06 22:37:47 UTC (rev 188068)
@@ -1,3 +1,38 @@
+2015-08-06  Chris Dumez  <cdu...@apple.com>
+
+        Toggle GPS state based on page visibility to save battery
+        https://bugs.webkit.org/show_bug.cgi?id=147685
+
+        Reviewed by Benjamin Poulain.
+
+        Add testRunner.isGeolocationProviderActive() test support function.
+
+        * DumpRenderTree/TestRunner.cpp:
+        (isGeolocationProviderActiveCallback):
+        (TestRunner::staticFunctions):
+        * DumpRenderTree/TestRunner.h:
+        * DumpRenderTree/mac/MockGeolocationProvider.h:
+        * DumpRenderTree/mac/MockGeolocationProvider.mm:
+        (-[MockGeolocationProvider isActive]):
+        * DumpRenderTree/mac/TestRunnerMac.mm:
+        (TestRunner::isGeolocationProviderActive):
+        * DumpRenderTree/win/TestRunnerWin.cpp:
+        (TestRunner::isGeolocationProviderActive):
+        * WebKitTestRunner/GeolocationProviderMock.h:
+        (WTR::GeolocationProviderMock::isActive):
+        * WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl:
+        * WebKitTestRunner/InjectedBundle/InjectedBundle.cpp:
+        (WTR::InjectedBundle::isGeolocationProviderActive):
+        * WebKitTestRunner/InjectedBundle/InjectedBundle.h:
+        * WebKitTestRunner/InjectedBundle/TestRunner.cpp:
+        (WTR::TestRunner::isGeolocationProviderActive):
+        * WebKitTestRunner/InjectedBundle/TestRunner.h:
+        * WebKitTestRunner/TestController.cpp:
+        (WTR::TestController::isGeolocationProviderActive):
+        * WebKitTestRunner/TestController.h:
+        * WebKitTestRunner/TestInvocation.cpp:
+        (WTR::TestInvocation::didReceiveSynchronousMessageFromInjectedBundle):
+
 2015-08-06  Ryosuke Niwa  <rn...@webkit.org>
 
         Automate JSBench with run-benchmark

Modified: trunk/Tools/DumpRenderTree/TestRunner.cpp (188067 => 188068)


--- trunk/Tools/DumpRenderTree/TestRunner.cpp	2015-08-06 22:36:34 UTC (rev 188067)
+++ trunk/Tools/DumpRenderTree/TestRunner.cpp	2015-08-06 22:37:47 UTC (rev 188068)
@@ -646,6 +646,12 @@
     return JSValueMakeNumber(context, controller->numberOfPendingGeolocationPermissionRequests());
 }
 
+static JSValueRef isGeolocationProviderActiveCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
+{
+    TestRunner* controller = static_cast<TestRunner*>(JSObjectGetPrivate(thisObject));
+    return JSValueMakeBoolean(context, controller->isGeolocationProviderActive());
+}
+
 static JSValueRef queueBackNavigationCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
 {
     // Has mac & windows implementation
@@ -2033,6 +2039,7 @@
         { "originsWithApplicationCache", originsWithApplicationCacheCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
         { "goBack", goBackCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, 
         { "ignoreLegacyWebNotificationPermissionRequests", ignoreLegacyWebNotificationPermissionRequestsCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
+        { "isGeolocationProviderActive", isGeolocationProviderActiveCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
         { "isCommandEnabled", isCommandEnabledCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
         { "keepWebHistory", keepWebHistoryCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
         { "numberOfPendingGeolocationPermissionRequests", numberOfPendingGeolocationPermissionRequestsCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },

Modified: trunk/Tools/DumpRenderTree/TestRunner.h (188067 => 188068)


--- trunk/Tools/DumpRenderTree/TestRunner.h	2015-08-06 22:36:34 UTC (rev 188067)
+++ trunk/Tools/DumpRenderTree/TestRunner.h	2015-08-06 22:37:47 UTC (rev 188068)
@@ -76,6 +76,7 @@
     void keepWebHistory();
     void notifyDone();
     int numberOfPendingGeolocationPermissionRequests();
+    bool isGeolocationProviderActive();
     void overridePreference(JSStringRef key, JSStringRef value);
     JSStringRef pathToLocalResource(JSContextRef, JSStringRef url);
     void queueBackNavigation(int howFarBackward);

Modified: trunk/Tools/DumpRenderTree/mac/MockGeolocationProvider.h (188067 => 188068)


--- trunk/Tools/DumpRenderTree/mac/MockGeolocationProvider.h	2015-08-06 22:36:34 UTC (rev 188067)
+++ trunk/Tools/DumpRenderTree/mac/MockGeolocationProvider.h	2015-08-06 22:37:47 UTC (rev 188068)
@@ -44,6 +44,7 @@
 - (void)setPositionUnavailableErrorWithMessage:(NSString *)errorMessage;
 
 - (void)stopTimer;
+- (BOOL)isActive;
 
 @end
 #endif

Modified: trunk/Tools/DumpRenderTree/mac/MockGeolocationProvider.mm (188067 => 188068)


--- trunk/Tools/DumpRenderTree/mac/MockGeolocationProvider.mm	2015-08-06 22:36:34 UTC (rev 188067)
+++ trunk/Tools/DumpRenderTree/mac/MockGeolocationProvider.mm	2015-08-06 22:37:47 UTC (rev 188068)
@@ -115,6 +115,11 @@
     _timer = 0;
 }
 
+- (BOOL)isActive
+{
+    return !_registeredViews.isEmpty();
+}
+
 - (void)timerFired
 {
     _timer = 0;

Modified: trunk/Tools/DumpRenderTree/mac/TestRunnerMac.mm (188067 => 188068)


--- trunk/Tools/DumpRenderTree/mac/TestRunnerMac.mm	2015-08-06 22:36:34 UTC (rev 188067)
+++ trunk/Tools/DumpRenderTree/mac/TestRunnerMac.mm	2015-08-06 22:37:47 UTC (rev 188068)
@@ -254,6 +254,11 @@
     return [(UIDelegate *)[[mainFrame webView] UIDelegate] numberOfPendingGeolocationPermissionRequests];
 }
 
+bool TestRunner::isGeolocationProviderActive()
+{
+    return MockGeolocationProvider.shared.isActive;
+}
+
 size_t TestRunner::webHistoryItemCount()
 {
     return [[[WebHistory optionalSharedHistory] allItems] count];

Modified: trunk/Tools/DumpRenderTree/win/TestRunnerWin.cpp (188067 => 188068)


--- trunk/Tools/DumpRenderTree/win/TestRunnerWin.cpp	2015-08-06 22:36:34 UTC (rev 188067)
+++ trunk/Tools/DumpRenderTree/win/TestRunnerWin.cpp	2015-08-06 22:37:47 UTC (rev 188068)
@@ -241,6 +241,13 @@
     return -1;
 }
 
+bool TestRunner::isGeolocationProviderActive()
+{
+    // FIXME: Implement for Geolocation layout tests.
+    printf("ERROR: TestRunner::isGeolocationProviderActive() not implemented\n");
+    return false;
+}
+
 size_t TestRunner::webHistoryItemCount()
 {
     COMPtr<IWebHistory> history;

Modified: trunk/Tools/WebKitTestRunner/GeolocationProviderMock.h (188067 => 188068)


--- trunk/Tools/WebKitTestRunner/GeolocationProviderMock.h	2015-08-06 22:36:34 UTC (rev 188067)
+++ trunk/Tools/WebKitTestRunner/GeolocationProviderMock.h	2015-08-06 22:37:47 UTC (rev 188068)
@@ -41,6 +41,8 @@
     void startUpdating(WKGeolocationManagerRef);
     void stopUpdating(WKGeolocationManagerRef);
 
+    bool isActive() const { return m_isActive; }
+
 private:
     void sendPositionIfNeeded();
     void sendErrorIfNeeded();

Modified: trunk/Tools/WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl (188067 => 188068)


--- trunk/Tools/WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl	2015-08-06 22:36:34 UTC (rev 188067)
+++ trunk/Tools/WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl	2015-08-06 22:37:47 UTC (rev 188068)
@@ -169,6 +169,7 @@
     void setGeolocationPermission(boolean value);
     void setMockGeolocationPosition(double latitude, double longitude, double accuracy, [Default=Undefined] optional object altitude, optional object altitudeAccuracy, optional object heading, optional object speed);
     void setMockGeolocationPositionUnavailableError(DOMString errorMessage);
+    boolean isGeolocationProviderActive();
 
     // MediaStream
     void setUserMediaPermission(boolean value);

Modified: trunk/Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.cpp (188067 => 188068)


--- trunk/Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.cpp	2015-08-06 22:36:34 UTC (rev 188067)
+++ trunk/Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.cpp	2015-08-06 22:37:47 UTC (rev 188068)
@@ -464,6 +464,16 @@
     WKBundlePagePostMessage(page()->page(), messageName.get(), errorMessage);
 }
 
+bool InjectedBundle::isGeolocationProviderActive() const
+{
+    WKRetainPtr<WKStringRef> messageName(AdoptWK, WKStringCreateWithUTF8CString("IsGeolocationClientActive"));
+    WKTypeRef resultToPass = 0;
+    WKBundlePagePostSynchronousMessage(page()->page(), messageName.get(), 0, &resultToPass);
+    WKRetainPtr<WKBooleanRef> isActive(AdoptWK, static_cast<WKBooleanRef>(resultToPass));
+
+    return WKBooleanGetValue(isActive.get());
+}
+
 void InjectedBundle::setUserMediaPermission(bool enabled)
 {
     auto messageName = adoptWK(WKStringCreateWithUTF8CString("SetUserMediaPermission"));

Modified: trunk/Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.h (188067 => 188068)


--- trunk/Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.h	2015-08-06 22:36:34 UTC (rev 188067)
+++ trunk/Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.h	2015-08-06 22:37:47 UTC (rev 188068)
@@ -91,6 +91,7 @@
     void setGeolocationPermission(bool);
     void setMockGeolocationPosition(double latitude, double longitude, double accuracy, bool providesAltitude, double altitude, bool providesAltitudeAccuracy, double altitudeAccuracy, bool providesHeading, double heading, bool providesSpeed, double speed);
     void setMockGeolocationPositionUnavailableError(WKStringRef errorMessage);
+    bool isGeolocationProviderActive() const;
 
     // MediaStream.
     void setUserMediaPermission(bool);

Modified: trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp (188067 => 188068)


--- trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp	2015-08-06 22:36:34 UTC (rev 188067)
+++ trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp	2015-08-06 22:37:47 UTC (rev 188068)
@@ -699,6 +699,11 @@
     InjectedBundle::singleton().setGeolocationPermission(enabled);
 }
 
+bool TestRunner::isGeolocationProviderActive()
+{
+    return InjectedBundle::singleton().isGeolocationProviderActive();
+}
+
 void TestRunner::setMockGeolocationPosition(double latitude, double longitude, double accuracy, JSValueRef jsAltitude, JSValueRef jsAltitudeAccuracy, JSValueRef jsHeading, JSValueRef jsSpeed)
 {
     auto& injectedBundle = InjectedBundle::singleton();

Modified: trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.h (188067 => 188068)


--- trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.h	2015-08-06 22:36:34 UTC (rev 188067)
+++ trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.h	2015-08-06 22:37:47 UTC (rev 188068)
@@ -256,6 +256,7 @@
     void setGeolocationPermission(bool);
     void setMockGeolocationPosition(double latitude, double longitude, double accuracy, JSValueRef altitude, JSValueRef altitudeAccuracy, JSValueRef heading, JSValueRef speed);
     void setMockGeolocationPositionUnavailableError(JSStringRef message);
+    bool isGeolocationProviderActive();
 
     // MediaStream
     void setUserMediaPermission(bool);

Modified: trunk/Tools/WebKitTestRunner/TestController.cpp (188067 => 188068)


--- trunk/Tools/WebKitTestRunner/TestController.cpp	2015-08-06 22:36:34 UTC (rev 188067)
+++ trunk/Tools/WebKitTestRunner/TestController.cpp	2015-08-06 22:37:47 UTC (rev 188068)
@@ -1478,6 +1478,11 @@
     decidePolicyForGeolocationPermissionRequestIfPossible();
 }
 
+bool TestController::isGeolocationProviderActive() const
+{
+    return m_geolocationProvider->isActive();
+}
+
 void TestController::setUserMediaPermission(bool enabled)
 {
     m_isUserMediaPermissionSet = true;

Modified: trunk/Tools/WebKitTestRunner/TestController.h (188067 => 188068)


--- trunk/Tools/WebKitTestRunner/TestController.h	2015-08-06 22:36:34 UTC (rev 188067)
+++ trunk/Tools/WebKitTestRunner/TestController.h	2015-08-06 22:37:47 UTC (rev 188068)
@@ -89,6 +89,7 @@
     void setMockGeolocationPosition(double latitude, double longitude, double accuracy, bool providesAltitude, double altitude, bool providesAltitudeAccuracy, double altitudeAccuracy, bool providesHeading, double heading, bool providesSpeed, double speed);
     void setMockGeolocationPositionUnavailableError(WKStringRef errorMessage);
     void handleGeolocationPermissionRequest(WKGeolocationPermissionRequestRef);
+    bool isGeolocationProviderActive() const;
 
     // MediaStream.
     void setUserMediaPermission(bool);

Modified: trunk/Tools/WebKitTestRunner/TestInvocation.cpp (188067 => 188068)


--- trunk/Tools/WebKitTestRunner/TestInvocation.cpp	2015-08-06 22:36:34 UTC (rev 188067)
+++ trunk/Tools/WebKitTestRunner/TestInvocation.cpp	2015-08-06 22:37:47 UTC (rev 188068)
@@ -642,6 +642,12 @@
         return 0;
     }
 
+    if (WKStringIsEqualToUTF8CString(messageName, "IsGeolocationClientActive")) {
+        bool isActive = TestController::singleton().isGeolocationProviderActive();
+        WKRetainPtr<WKTypeRef> result(AdoptWK, WKBooleanCreate(isActive));
+        return result;
+    }
+
     if (WKStringIsEqualToUTF8CString(messageName, "IsWorkQueueEmpty")) {
         bool isEmpty = TestController::singleton().workQueueManager().isWorkQueueEmpty();
         WKRetainPtr<WKTypeRef> result(AdoptWK, WKBooleanCreate(isEmpty));
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to