Title: [243533] trunk
Revision
243533
Author
carlo...@webkit.org
Date
2019-03-27 02:36:29 -0700 (Wed, 27 Mar 2019)

Log Message

Geolocation request not complete when watch request was started in a different web process
https://bugs.webkit.org/show_bug.cgi?id=195996

Reviewed by Alex Christensen.

Source/WebKit:

In WebGeolocationManagerProxy::startUpdating() we do nothing when the provider is already updating. We should
reply with a DidChangePosition using the last known position, if available. If we are updating, but we still
don't have a known position, the request will be completed when
WebGeolocationManagerProxy::providerDidChangePosition() is called since it always notifies all web
processes.

* UIProcess/WebGeolocationManagerProxy.cpp:
(WebKit::WebGeolocationManagerProxy::providerDidChangePosition): Cache the position.
(WebKit::WebGeolocationManagerProxy::startUpdating): Reply using cached position if already known.
* UIProcess/WebGeolocationManagerProxy.h:
(WebKit::WebGeolocationManagerProxy::lastPosition const): Return cached position.
* WebProcess/WebCoreSupport/WebGeolocationClient.cpp:
(WebKit::WebGeolocationClient::lastPosition): Remove the FIXME since we don't want this feature.

Tools:

Add a test case.

* TestWebKitAPI/Tests/WebKit/Geolocation.cpp:
(TestWebKitAPI::runJavaScriptAlert):
(TestWebKitAPI::TEST):

Modified Paths

Diff

Modified: trunk/Source/WebKit/ChangeLog (243532 => 243533)


--- trunk/Source/WebKit/ChangeLog	2019-03-27 01:05:32 UTC (rev 243532)
+++ trunk/Source/WebKit/ChangeLog	2019-03-27 09:36:29 UTC (rev 243533)
@@ -1,3 +1,24 @@
+2019-03-27  Carlos Garcia Campos  <cgar...@igalia.com>
+
+        Geolocation request not complete when watch request was started in a different web process
+        https://bugs.webkit.org/show_bug.cgi?id=195996
+
+        Reviewed by Alex Christensen.
+
+        In WebGeolocationManagerProxy::startUpdating() we do nothing when the provider is already updating. We should
+        reply with a DidChangePosition using the last known position, if available. If we are updating, but we still
+        don't have a known position, the request will be completed when
+        WebGeolocationManagerProxy::providerDidChangePosition() is called since it always notifies all web
+        processes.
+
+        * UIProcess/WebGeolocationManagerProxy.cpp:
+        (WebKit::WebGeolocationManagerProxy::providerDidChangePosition): Cache the position.
+        (WebKit::WebGeolocationManagerProxy::startUpdating): Reply using cached position if already known.
+        * UIProcess/WebGeolocationManagerProxy.h:
+        (WebKit::WebGeolocationManagerProxy::lastPosition const): Return cached position.
+        * WebProcess/WebCoreSupport/WebGeolocationClient.cpp:
+        (WebKit::WebGeolocationClient::lastPosition): Remove the FIXME since we don't want this feature.
+
 2019-03-26  Brent Fulgham  <bfulg...@apple.com>
 
         [macOS] Correct kerberos-related sandbox violations

Modified: trunk/Source/WebKit/UIProcess/WebGeolocationManagerProxy.cpp (243532 => 243533)


--- trunk/Source/WebKit/UIProcess/WebGeolocationManagerProxy.cpp	2019-03-27 01:05:32 UTC (rev 243532)
+++ trunk/Source/WebKit/UIProcess/WebGeolocationManagerProxy.cpp	2019-03-27 09:36:29 UTC (rev 243533)
@@ -88,10 +88,12 @@
 
 void WebGeolocationManagerProxy::providerDidChangePosition(WebGeolocationPosition* position)
 {
+    m_lastPosition = position->corePosition();
+
     if (!processPool())
         return;
 
-    processPool()->sendToAllProcesses(Messages::WebGeolocationManager::DidChangePosition(position->corePosition()));
+    processPool()->sendToAllProcesses(Messages::WebGeolocationManager::DidChangePosition(m_lastPosition.value()));
 }
 
 void WebGeolocationManagerProxy::providerDidFailToDeterminePosition(const String& errorMessage)
@@ -116,7 +118,8 @@
     if (!wasUpdating) {
         m_provider->setEnableHighAccuracy(*this, isHighAccuracyEnabled());
         m_provider->startUpdating(*this);
-    }
+    } else if (m_lastPosition)
+        connection.send(Messages::WebGeolocationManager::DidChangePosition(m_lastPosition.value()), 0);
 }
 
 void WebGeolocationManagerProxy::stopUpdating(IPC::Connection& connection)

Modified: trunk/Source/WebKit/UIProcess/WebGeolocationManagerProxy.h (243532 => 243533)


--- trunk/Source/WebKit/UIProcess/WebGeolocationManagerProxy.h	2019-03-27 01:05:32 UTC (rev 243532)
+++ trunk/Source/WebKit/UIProcess/WebGeolocationManagerProxy.h	2019-03-27 09:36:29 UTC (rev 243533)
@@ -29,6 +29,7 @@
 #include "Connection.h"
 #include "MessageReceiver.h"
 #include "WebContextSupplement.h"
+#include <WebCore/GeolocationPosition.h>
 #include <wtf/HashSet.h>
 #include <wtf/text/WTFString.h>
 
@@ -54,6 +55,7 @@
 #if PLATFORM(IOS_FAMILY)
     void resetPermissions();
 #endif
+    const Optional<WebCore::GeolocationPosition>& lastPosition() const { return m_lastPosition; }
 
     using API::Object::ref;
     using API::Object::deref;
@@ -82,6 +84,7 @@
     HashSet<const IPC::Connection::Client*> m_highAccuracyRequesters;
 
     std::unique_ptr<API::GeolocationProvider> m_provider;
+    Optional<WebCore::GeolocationPosition> m_lastPosition;
 };
 
 } // namespace WebKit

Modified: trunk/Source/WebKit/WebProcess/WebCoreSupport/WebGeolocationClient.cpp (243532 => 243533)


--- trunk/Source/WebKit/WebProcess/WebCoreSupport/WebGeolocationClient.cpp	2019-03-27 01:05:32 UTC (rev 243532)
+++ trunk/Source/WebKit/WebProcess/WebCoreSupport/WebGeolocationClient.cpp	2019-03-27 09:36:29 UTC (rev 243533)
@@ -65,7 +65,6 @@
 
 Optional<GeolocationPosition> WebGeolocationClient::lastPosition()
 {
-    // FIXME: Implement this.
     return WTF::nullopt;
 }
 

Modified: trunk/Tools/ChangeLog (243532 => 243533)


--- trunk/Tools/ChangeLog	2019-03-27 01:05:32 UTC (rev 243532)
+++ trunk/Tools/ChangeLog	2019-03-27 09:36:29 UTC (rev 243533)
@@ -1,3 +1,16 @@
+2019-03-27  Carlos Garcia Campos  <cgar...@igalia.com>
+
+        Geolocation request not complete when watch request was started in a different web process
+        https://bugs.webkit.org/show_bug.cgi?id=195996
+
+        Reviewed by Alex Christensen.
+
+        Add a test case.
+
+        * TestWebKitAPI/Tests/WebKit/Geolocation.cpp:
+        (TestWebKitAPI::runJavaScriptAlert):
+        (TestWebKitAPI::TEST):
+
 2019-03-26  Keith Rollin  <krol...@apple.com>
 
         Update the way generate-xcfilelists returns strings from functions

Modified: trunk/Tools/TestWebKitAPI/Tests/WebKit/Geolocation.cpp (243532 => 243533)


--- trunk/Tools/TestWebKitAPI/Tests/WebKit/Geolocation.cpp	2019-03-27 01:05:32 UTC (rev 243532)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit/Geolocation.cpp	2019-03-27 09:36:29 UTC (rev 243533)
@@ -315,9 +315,16 @@
     }
 };
 
+struct _javascript_AlertContext {
+    bool didRun { false };
+    std::string alertText;
+};
+
 static void runJavaScriptAlert(WKPageRef page, WKStringRef alertText, WKFrameRef frame, const void* clientInfo)
 {
-    *static_cast<bool*>(const_cast<void*>(clientInfo)) = true;
+    auto* context = static_cast<_javascript_AlertContext*>(const_cast<void*>(clientInfo));
+    context->didRun = true;
+    context->alertText = Util::toSTD(alertText);
 }
 
 TEST(WebKit, GeolocationTransitionToLowAccuracy)
@@ -336,12 +343,12 @@
     PlatformWebView lowAccuracyWebView(context.get());
     setupView(lowAccuracyWebView);
 
-    bool finishedSecondStep = false;
+    _javascript_AlertContext secondStepContext;
 
     WKPageUIClientV2 uiClient;
     memset(&uiClient, 0, sizeof(uiClient));
     uiClient.base.version = 2;
-    uiClient.base.clientInfo = &finishedSecondStep;
+    uiClient.base.clientInfo = &secondStepContext;
     uiClient.decidePolicyForGeolocationPermissionRequest = decidePolicyForGeolocationPermissionRequestCallBack;
     uiClient.runJavaScriptAlert = runJavaScriptAlert;
     WKPageSetPageUIClient(lowAccuracyWebView.page(), &uiClient.base);
@@ -348,7 +355,8 @@
 
     WKRetainPtr<WKURLRef> lowAccuracyURL(AdoptWK, Util::createURLForResource("geolocationWatchPosition", "html"));
     WKPageLoadURL(lowAccuracyWebView.page(), lowAccuracyURL.get());
-    Util::run(&finishedSecondStep);
+    Util::run(&secondStepContext.didRun);
+    EXPECT_EQ(secondStepContext.alertText, "SUCCESS");
 
     WKRetainPtr<WKURLRef> resetUrl = adoptWK(WKURLCreateWithUTF8CString("about:blank"));
     WKPageLoadURL(highAccuracyWebView.page(), resetUrl.get());
@@ -361,6 +369,42 @@
     clearGeolocationProvider(context.get());
 }
 
+TEST(WebKit, GeolocationWatchMultiprocess)
+{
+    WKRetainPtr<WKContextRef> context(AdoptWK, WKContextCreateWithConfiguration(nullptr));
+
+    GeolocationStateTracker stateTracker;
+    setupGeolocationProvider(context.get(), &stateTracker);
+
+    _javascript_AlertContext testContext;
+
+    WKPageUIClientV2 uiClient;
+    memset(&uiClient, 0, sizeof(uiClient));
+    uiClient.base.version = 2;
+    uiClient.base.clientInfo = &testContext;
+    uiClient.decidePolicyForGeolocationPermissionRequest = decidePolicyForGeolocationPermissionRequestCallBack;
+    uiClient.runJavaScriptAlert = runJavaScriptAlert;
+
+    PlatformWebView view1(context.get());
+    WKPageSetPageUIClient(view1.page(), &uiClient.base);
+    WKRetainPtr<WKURLRef> url(AdoptWK, Util::createURLForResource("geolocationWatchPosition", "html"));
+    WKPageLoadURL(view1.page(), url.get());
+    Util::run(&testContext.didRun);
+    EXPECT_EQ(testContext.alertText, "SUCCESS");
+    WKPageSetPageUIClient(view1.page(), nullptr);
+
+    testContext.didRun = false;
+    testContext.alertText = { };
+
+    PlatformWebView view2(context.get());
+    WKPageSetPageUIClient(view2.page(), &uiClient.base);
+    WKPageLoadURL(view2.page(), url.get());
+    Util::run(&testContext.didRun);
+    EXPECT_EQ(testContext.alertText, "SUCCESS");
+
+    clearGeolocationProvider(context.get());
+}
+
 } // namespace TestWebKitAPI
 
 #endif
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to