[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc
commit-queue at webkit.org
commit-queue at webkit.org
Wed Dec 22 13:22:42 UTC 2010
The following commit has been merged in the debian/experimental branch:
commit 3ec81dfb37df8d1c04188ea30ad25a25e6cd97b6
Author: commit-queue at webkit.org <commit-queue at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Mon Sep 13 14:20:38 2010 +0000
2010-09-13 Jonathan Dixon <joth at chromium.org>
Reviewed by Steve Block.
[chromium] Port test shell geolocation fixes to DRT
https://bugs.webkit.org/show_bug.cgi?id=45313
Remove exceptions for tests that now pass (in DRT and downstream test_shell)
* platform/chromium/drt_expectations.txt:
* platform/chromium/test_expectations.txt:
2010-09-13 Jonathan Dixon <joth at chromium.org>
Reviewed by Steve Block.
[chromium] Port test shell geolocation fixes to DRT
https://bugs.webkit.org/show_bug.cgi?id=45313
Also re-apply rolled out patch http://trac.webkit.org/changeset/66886 :-
Add missing virtual destructor to the abstract base class.
* platform/chromium/GeolocationServiceChromium.cpp:
(WebCore::GeolocationServiceBridge::~GeolocationServiceBridge):
* platform/chromium/GeolocationServiceChromium.h:
2010-09-13 Jonathan Dixon <joth at chromium.org>
Reviewed by Steve Block.
[chromium] Port test shell geolocation fixes to DRT
https://bugs.webkit.org/show_bug.cgi?id=45313
Ports over fixes from test shell:
- http://codereview.chromium.org/3294007
- http://codereview.chromium.org/333800
Resets state between service instances, which fixes delayed-permission-allowed-for-multiple-requests.html
Also re-apply rolled out patch http://trac.webkit.org/changeset/66886 :-
Access to out-of-scope WebGeolocationServiceBridgeImpl
https://bugs.webkit.org/show_bug.cgi?id=45112
Keep the WebGeolocationService pointer for lifetime of the bridge, to
ensure it can be detached reliably
Includes follow-up review comment to rename onWebGeolocationServiceDestroyed to didDestroyGeolocationService
* public/WebGeolocationService.h:
(WebKit::WebGeolocationService::~WebGeolocationService):
* public/WebGeolocationServiceBridge.h:
(WebKit::WebGeolocationServiceBridge::onWebGeolocationServiceDestroyed):
* public/WebGeolocationServiceMock.h:
* src/WebGeolocationServiceBridgeImpl.cpp:
(WebKit::WebGeolocationServiceBridgeImpl::WebGeolocationServiceBridgeImpl):
(WebKit::WebGeolocationServiceBridgeImpl::~WebGeolocationServiceBridgeImpl):
(WebKit::WebGeolocationServiceBridgeImpl::startUpdating):
(WebKit::WebGeolocationServiceBridgeImpl::stopUpdating):
(WebKit::WebGeolocationServiceBridgeImpl::suspend):
(WebKit::WebGeolocationServiceBridgeImpl::resume):
(WebKit::WebGeolocationServiceBridgeImpl::attachBridgeIfNeeded):
(WebKit::WebGeolocationServiceBridgeImpl::setIsAllowed):
(WebKit::WebGeolocationServiceBridgeImpl::setLastPosition):
(WebKit::WebGeolocationServiceBridgeImpl::setLastError):
(WebKit::WebGeolocationServiceBridgeImpl::didDestroyGeolocationService):
(WebKit::WebGeolocationServiceBridgeImpl::isAttached):
* src/WebGeolocationServiceMock.cpp:
(WebKit::WebGeolocationServiceMock::setMockGeolocationPermission):
(WebKit::WebGeolocationServiceMockImpl::WebGeolocationServiceMockImpl):
(WebKit::WebGeolocationServiceMockImpl::~WebGeolocationServiceMockImpl):
(WebKit::WebGeolocationServiceMockImpl::setMockGeolocationPermission):
(WebKit::WebGeolocationServiceMockImpl::requestPermissionForFrame):
(WebKit::WebGeolocationServiceMockImpl::notifyPendingPermissions):
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@67387 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index 986d7dc..4880280 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,15 @@
+2010-09-13 Jonathan Dixon <joth at chromium.org>
+
+ Reviewed by Steve Block.
+
+ [chromium] Port test shell geolocation fixes to DRT
+ https://bugs.webkit.org/show_bug.cgi?id=45313
+
+ Remove exceptions for tests that now pass (in DRT and downstream test_shell)
+
+ * platform/chromium/drt_expectations.txt:
+ * platform/chromium/test_expectations.txt:
+
2010-09-13 Yury Semikhatsky <yurys at chromium.org>
Unreviewed. Skip new debugger test on Qt.
diff --git a/LayoutTests/platform/chromium/drt_expectations.txt b/LayoutTests/platform/chromium/drt_expectations.txt
index 0d07fe9..91f346d 100644
--- a/LayoutTests/platform/chromium/drt_expectations.txt
+++ b/LayoutTests/platform/chromium/drt_expectations.txt
@@ -110,7 +110,6 @@ BUG_DRT LINUX : fast/text/international/003.html = IMAGE
BUG_DRT LINUX : svg/batik/text/verticalText.svg = IMAGE+TEXT
// Misc.
-BUG_DRT WIN MAC LINUX : fast/dom/Geolocation/delayed-permission-allowed-for-multiple-requests.html = TIMEOUT
BUG_DRT WIN MAC LINUX : fast/dynamic/window-resize-scrollbars-test.html = IMAGE+TEXT
BUG_DRT WIN MAC LINUX : http/tests/security/xssAuditor/link-opens-new-window.html = TEXT
BUG_DRT WIN MAC LINUX : storage/domstorage/quota.html = TEXT
diff --git a/LayoutTests/platform/chromium/test_expectations.txt b/LayoutTests/platform/chromium/test_expectations.txt
index ec2d9bc..2d0edb3 100644
--- a/LayoutTests/platform/chromium/test_expectations.txt
+++ b/LayoutTests/platform/chromium/test_expectations.txt
@@ -2960,10 +2960,6 @@ BUG50637 : fast/dom/prototype-inheritance.html = FAIL
// Application Cache Quotas
BUGWK43459 : http/tests/appcache/origin-quota.html = TEXT MISSING
-// Missing LayoutTestController harness.
-BUGWK43480 SKIP : fast/dom/Geolocation/delayed-permission-allowed.html = TEXT TIMEOUT PASS
-BUGWK43480 SKIP : fast/dom/Geolocation/delayed-permission-denied.html = TEXT TIMEOUT PASS
-
BUG51161 LINUX DEBUG : svg/W3C-SVG-1.1/masking-mask-01-b.svg = CRASH
BUG51161 LINUX DEBUG : svg/clip-path/clip-path-text.svg = CRASH
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 7ad587f..1b16426 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,17 @@
+2010-09-13 Jonathan Dixon <joth at chromium.org>
+
+ Reviewed by Steve Block.
+
+ [chromium] Port test shell geolocation fixes to DRT
+ https://bugs.webkit.org/show_bug.cgi?id=45313
+
+ Also re-apply rolled out patch http://trac.webkit.org/changeset/66886 :-
+ Add missing virtual destructor to the abstract base class.
+
+ * platform/chromium/GeolocationServiceChromium.cpp:
+ (WebCore::GeolocationServiceBridge::~GeolocationServiceBridge):
+ * platform/chromium/GeolocationServiceChromium.h:
+
2010-09-13 Yury Semikhatsky <yurys at chromium.org>
Reviewed by Pavel Feldman.
diff --git a/WebCore/platform/chromium/GeolocationServiceChromium.cpp b/WebCore/platform/chromium/GeolocationServiceChromium.cpp
index 9333999..b64f5eb 100644
--- a/WebCore/platform/chromium/GeolocationServiceChromium.cpp
+++ b/WebCore/platform/chromium/GeolocationServiceChromium.cpp
@@ -35,6 +35,10 @@
namespace WebCore {
+GeolocationServiceBridge::~GeolocationServiceBridge()
+{
+}
+
GeolocationServiceChromium::GeolocationServiceChromium(GeolocationServiceClient* c)
: GeolocationService(c),
m_geolocation(static_cast<Geolocation*>(c)),
diff --git a/WebCore/platform/chromium/GeolocationServiceChromium.h b/WebCore/platform/chromium/GeolocationServiceChromium.h
index f139220..7e6f633 100644
--- a/WebCore/platform/chromium/GeolocationServiceChromium.h
+++ b/WebCore/platform/chromium/GeolocationServiceChromium.h
@@ -42,6 +42,7 @@ namespace WebCore {
// Provides an interface for GeolocationServiceChromium to call into the embedder.
class GeolocationServiceBridge {
public:
+ virtual ~GeolocationServiceBridge();
// Called by GeolocationServiceChromium.
virtual bool startUpdating(PositionOptions*) = 0;
virtual void stopUpdating() = 0;
diff --git a/WebKit/chromium/ChangeLog b/WebKit/chromium/ChangeLog
index 749e160..53c16c8 100644
--- a/WebKit/chromium/ChangeLog
+++ b/WebKit/chromium/ChangeLog
@@ -1,3 +1,51 @@
+2010-09-13 Jonathan Dixon <joth at chromium.org>
+
+ Reviewed by Steve Block.
+
+ [chromium] Port test shell geolocation fixes to DRT
+ https://bugs.webkit.org/show_bug.cgi?id=45313
+
+ Ports over fixes from test shell:
+ - http://codereview.chromium.org/3294007
+ - http://codereview.chromium.org/333800
+
+ Resets state between service instances, which fixes delayed-permission-allowed-for-multiple-requests.html
+
+ Also re-apply rolled out patch http://trac.webkit.org/changeset/66886 :-
+ Access to out-of-scope WebGeolocationServiceBridgeImpl
+ https://bugs.webkit.org/show_bug.cgi?id=45112
+
+ Keep the WebGeolocationService pointer for lifetime of the bridge, to
+ ensure it can be detached reliably
+
+ Includes follow-up review comment to rename onWebGeolocationServiceDestroyed to didDestroyGeolocationService
+
+ * public/WebGeolocationService.h:
+ (WebKit::WebGeolocationService::~WebGeolocationService):
+ * public/WebGeolocationServiceBridge.h:
+ (WebKit::WebGeolocationServiceBridge::onWebGeolocationServiceDestroyed):
+ * public/WebGeolocationServiceMock.h:
+ * src/WebGeolocationServiceBridgeImpl.cpp:
+ (WebKit::WebGeolocationServiceBridgeImpl::WebGeolocationServiceBridgeImpl):
+ (WebKit::WebGeolocationServiceBridgeImpl::~WebGeolocationServiceBridgeImpl):
+ (WebKit::WebGeolocationServiceBridgeImpl::startUpdating):
+ (WebKit::WebGeolocationServiceBridgeImpl::stopUpdating):
+ (WebKit::WebGeolocationServiceBridgeImpl::suspend):
+ (WebKit::WebGeolocationServiceBridgeImpl::resume):
+ (WebKit::WebGeolocationServiceBridgeImpl::attachBridgeIfNeeded):
+ (WebKit::WebGeolocationServiceBridgeImpl::setIsAllowed):
+ (WebKit::WebGeolocationServiceBridgeImpl::setLastPosition):
+ (WebKit::WebGeolocationServiceBridgeImpl::setLastError):
+ (WebKit::WebGeolocationServiceBridgeImpl::didDestroyGeolocationService):
+ (WebKit::WebGeolocationServiceBridgeImpl::isAttached):
+ * src/WebGeolocationServiceMock.cpp:
+ (WebKit::WebGeolocationServiceMock::setMockGeolocationPermission):
+ (WebKit::WebGeolocationServiceMockImpl::WebGeolocationServiceMockImpl):
+ (WebKit::WebGeolocationServiceMockImpl::~WebGeolocationServiceMockImpl):
+ (WebKit::WebGeolocationServiceMockImpl::setMockGeolocationPermission):
+ (WebKit::WebGeolocationServiceMockImpl::requestPermissionForFrame):
+ (WebKit::WebGeolocationServiceMockImpl::notifyPendingPermissions):
+
2010-09-13 Yury Semikhatsky <yurys at chromium.org>
Reviewed by Pavel Feldman.
diff --git a/WebKit/chromium/public/WebGeolocationService.h b/WebKit/chromium/public/WebGeolocationService.h
index ed8c4e8..ea91b58 100644
--- a/WebKit/chromium/public/WebGeolocationService.h
+++ b/WebKit/chromium/public/WebGeolocationService.h
@@ -31,10 +31,9 @@
#ifndef WebGeolocationService_h
#define WebGeolocationService_h
-#include "WebGeolocationServiceBridge.h"
-
namespace WebKit {
+class WebGeolocationServiceBridge;
class WebString;
class WebURL;
@@ -50,10 +49,14 @@ public:
// Attaches the WebGeolocationServiceBridge to the embedder and returns its
// id, which should be used on subsequent calls for the methods above.
+ // An ID of zero indicates the attach failed.
virtual int attachBridge(WebGeolocationServiceBridge*) { return 0; }
// Detaches the WebGeolocationServiceBridge from the embedder.
virtual void detachBridge(int bridgeId) { }
+
+protected:
+ virtual ~WebGeolocationService() {}
};
} // namespace WebKit
diff --git a/WebKit/chromium/public/WebGeolocationServiceBridge.h b/WebKit/chromium/public/WebGeolocationServiceBridge.h
index 422b32b..d209c23 100644
--- a/WebKit/chromium/public/WebGeolocationServiceBridge.h
+++ b/WebKit/chromium/public/WebGeolocationServiceBridge.h
@@ -47,7 +47,11 @@ public:
virtual void setIsAllowed(bool allowed) = 0;
virtual void setLastPosition(double latitude, double longitude, bool providesAltitude, double altitude, double accuracy, bool providesAltitudeAccuracy, double altitudeAccuracy, bool providesHeading, double heading, bool providesSpeed, double speed, long long timestamp) = 0;
virtual void setLastError(int errorCode, const WebString& message) = 0;
- virtual void onWebGeolocationServiceDestroyed() = 0;
+ // Called when the WebGeolocationService to which this bridge is attached is going out of scope. On receiving
+ // this call the bridge implementation must not make any further access to the service.
+ virtual void didDestroyGeolocationService() = 0;
+ // FIXME: Remove this badly named method when all callers are using didDestroyGeolocationService directly.
+ void onWebGeolocationServiceDestroyed() { didDestroyGeolocationService(); }
protected:
virtual ~WebGeolocationServiceBridge() {}
diff --git a/WebKit/chromium/public/WebGeolocationServiceMock.h b/WebKit/chromium/public/WebGeolocationServiceMock.h
index 407fe9d..820975e 100644
--- a/WebKit/chromium/public/WebGeolocationServiceMock.h
+++ b/WebKit/chromium/public/WebGeolocationServiceMock.h
@@ -44,9 +44,6 @@ public:
WEBKIT_API static void setMockGeolocationPermission(bool allowed);
WEBKIT_API static void setMockGeolocationPosition(double latitude, double longitude, double accuracy);
WEBKIT_API static void setMockGeolocationError(int errorCode, const WebString& message);
-
-protected:
- static bool s_mockGeolocationPermission;
};
} // namespace WebKit
diff --git a/WebKit/chromium/src/WebGeolocationServiceBridgeImpl.cpp b/WebKit/chromium/src/WebGeolocationServiceBridgeImpl.cpp
index bbb7162..bbc852f 100644
--- a/WebKit/chromium/src/WebGeolocationServiceBridgeImpl.cpp
+++ b/WebKit/chromium/src/WebGeolocationServiceBridgeImpl.cpp
@@ -79,13 +79,15 @@ public:
virtual void setIsAllowed(bool allowed);
virtual void setLastPosition(double latitude, double longitude, bool providesAltitude, double altitude, double accuracy, bool providesAltitudeAccuracy, double altitudeAccuracy, bool providesHeading, double heading, bool providesSpeed, double speed, long long timestamp);
virtual void setLastError(int errorCode, const WebString& message);
- virtual void onWebGeolocationServiceDestroyed();
+ virtual void didDestroyGeolocationService();
private:
- WebViewClient* getWebViewClient();
-
+ bool isAttached() const;
+ // Pointer back to the WebKit geolocation client. We obtain this via the frame's page, but need to cache it
+ // as it may still be alive after the page has detached from the frame.
+ WebGeolocationService* m_webGeolocationService;
// GeolocationServiceChromium owns us, we only have a pointer back to it.
- GeolocationServiceChromium* m_GeolocationServiceChromium;
+ GeolocationServiceChromium* m_geolocationServiceChromium;
int m_bridgeId;
};
@@ -95,49 +97,47 @@ GeolocationServiceBridge* createGeolocationServiceBridgeImpl(GeolocationServiceC
}
WebGeolocationServiceBridgeImpl::WebGeolocationServiceBridgeImpl(GeolocationServiceChromium* geolocationServiceChromium)
- : m_GeolocationServiceChromium(geolocationServiceChromium)
+ : m_webGeolocationService(0)
+ , m_geolocationServiceChromium(geolocationServiceChromium)
, m_bridgeId(0)
{
}
WebGeolocationServiceBridgeImpl::~WebGeolocationServiceBridgeImpl()
{
- WebKit::WebViewClient* webViewClient = getWebViewClient();
- // Geolocation has an OwnPtr to us, and it's destroyed after the frame has
- // been potentially disconnected. In this case, it calls stopUpdating()
- // has been called and we have already detached ourselves.
- if (!webViewClient)
- ASSERT(!m_bridgeId);
- else if (m_bridgeId)
- webViewClient->geolocationService()->detachBridge(m_bridgeId);
+ if (isAttached())
+ m_webGeolocationService->detachBridge(m_bridgeId);
}
bool WebGeolocationServiceBridgeImpl::startUpdating(PositionOptions* positionOptions)
{
attachBridgeIfNeeded();
- getWebViewClient()->geolocationService()->startUpdating(m_bridgeId, m_GeolocationServiceChromium->frame()->document()->url(), positionOptions->enableHighAccuracy());
+ if (!isAttached())
+ return false;
+ m_webGeolocationService->startUpdating(m_bridgeId, m_geolocationServiceChromium->frame()->document()->url(), positionOptions->enableHighAccuracy());
return true;
}
void WebGeolocationServiceBridgeImpl::stopUpdating()
{
- WebViewClient* webViewClient = getWebViewClient();
- if (m_bridgeId && webViewClient) {
- WebGeolocationService* geolocationService = webViewClient->geolocationService();
- geolocationService->stopUpdating(m_bridgeId);
- geolocationService->detachBridge(m_bridgeId);
+ if (isAttached()) {
+ m_webGeolocationService->stopUpdating(m_bridgeId);
+ m_webGeolocationService->detachBridge(m_bridgeId);
+ m_bridgeId = 0;
+ m_webGeolocationService = 0;
}
- m_bridgeId = 0;
}
void WebGeolocationServiceBridgeImpl::suspend()
{
- getWebViewClient()->geolocationService()->suspend(m_bridgeId);
+ if (isAttached())
+ m_webGeolocationService->suspend(m_bridgeId);
}
void WebGeolocationServiceBridgeImpl::resume()
{
- getWebViewClient()->geolocationService()->resume(m_bridgeId);
+ if (isAttached())
+ m_webGeolocationService->resume(m_bridgeId);
}
int WebGeolocationServiceBridgeImpl::getBridgeId() const
@@ -147,38 +147,54 @@ int WebGeolocationServiceBridgeImpl::getBridgeId() const
void WebGeolocationServiceBridgeImpl::attachBridgeIfNeeded()
{
- if (!m_bridgeId)
- m_bridgeId = getWebViewClient()->geolocationService()->attachBridge(this);
+ if (isAttached())
+ return;
+ // Lazy attach to the geolocation service of the associated page if there is one.
+ Frame* frame = m_geolocationServiceChromium->frame();
+ if (!frame || !frame->page())
+ return;
+ WebKit::ChromeClientImpl* chromeClientImpl = static_cast<WebKit::ChromeClientImpl*>(frame->page()->chrome()->client());
+ WebKit::WebViewClient* webViewClient = chromeClientImpl->webView()->client();
+ m_webGeolocationService = webViewClient->geolocationService();
+ ASSERT(m_webGeolocationService);
+ m_bridgeId = m_webGeolocationService->attachBridge(this);
+ if (!m_bridgeId) {
+ // Attach failed. Release association with this service.
+ m_webGeolocationService = 0;
+ }
}
void WebGeolocationServiceBridgeImpl::setIsAllowed(bool allowed)
{
- m_GeolocationServiceChromium->setIsAllowed(allowed);
+ m_geolocationServiceChromium->setIsAllowed(allowed);
}
void WebGeolocationServiceBridgeImpl::setLastPosition(double latitude, double longitude, bool providesAltitude, double altitude, double accuracy, bool providesAltitudeAccuracy, double altitudeAccuracy, bool providesHeading, double heading, bool providesSpeed, double speed, long long timestamp)
{
RefPtr<Geoposition> geoposition = Geoposition::create(Coordinates::create(latitude, longitude, providesAltitude, altitude, accuracy, providesAltitudeAccuracy, altitudeAccuracy, providesHeading, heading, providesSpeed, speed), timestamp);
- m_GeolocationServiceChromium->setLastPosition(geoposition);
+ m_geolocationServiceChromium->setLastPosition(geoposition);
}
void WebGeolocationServiceBridgeImpl::setLastError(int errorCode, const WebString& message)
{
- m_GeolocationServiceChromium->setLastError(errorCode, message);
+ m_geolocationServiceChromium->setLastError(errorCode, message);
}
-WebViewClient* WebGeolocationServiceBridgeImpl::getWebViewClient()
+void WebGeolocationServiceBridgeImpl::didDestroyGeolocationService()
{
- Frame* frame = m_GeolocationServiceChromium->frame();
- if (!frame || !frame->page())
- return 0;
- WebKit::ChromeClientImpl* chromeClientImpl = static_cast<WebKit::ChromeClientImpl*>(frame->page()->chrome()->client());
- WebKit::WebViewClient* webViewClient = chromeClientImpl->webView()->client();
- return webViewClient;
+ m_bridgeId = 0;
+ m_webGeolocationService = 0;
}
-void WebGeolocationServiceBridgeImpl::onWebGeolocationServiceDestroyed()
+bool WebGeolocationServiceBridgeImpl::isAttached() const
{
+ // Test the class invariant.
+ if (m_webGeolocationService)
+ ASSERT(m_bridgeId);
+ else
+ ASSERT(!m_bridgeId);
+
+ return m_webGeolocationService;
}
} // namespace WebKit
diff --git a/WebKit/chromium/src/WebGeolocationServiceMock.cpp b/WebKit/chromium/src/WebGeolocationServiceMock.cpp
index 2a10c96..e149cf1 100644
--- a/WebKit/chromium/src/WebGeolocationServiceMock.cpp
+++ b/WebKit/chromium/src/WebGeolocationServiceMock.cpp
@@ -34,9 +34,11 @@
#include "GeolocationService.h"
#include "GeolocationServiceChromium.h"
#include "GeolocationServiceMock.h"
+#include "WebGeolocationServiceBridge.h"
#include "WebString.h"
#include <wtf/CurrentTime.h>
#include <wtf/HashMap.h>
+#include <wtf/Vector.h>
#if ENABLE(GEOLOCATION)
@@ -51,6 +53,7 @@ using WebCore::Geoposition;
using WebCore::PositionError;
using WebCore::PositionOptions;
using WTF::String;
+using WTF::Vector;
namespace WebCore {
class GeolocationServiceChromiumMock : public GeolocationServiceChromium, public GeolocationServiceClient {
@@ -124,17 +127,34 @@ namespace WebKit {
class WebGeolocationServiceMockImpl : public WebGeolocationServiceMock {
public:
- virtual ~WebGeolocationServiceMockImpl() { }
+ WebGeolocationServiceMockImpl();
+ virtual ~WebGeolocationServiceMockImpl();
+ static void setMockGeolocationPermission(bool allowed);
+
+ // WebGeolocationService
virtual void requestPermissionForFrame(int bridgeId, const WebURL& url);
virtual int attachBridge(WebGeolocationServiceBridge*);
virtual void detachBridge(int bridgeId);
private:
+ void notifyPendingPermissions();
+
typedef HashMap<int, WebGeolocationServiceBridge*> IdToBridgeMap;
IdToBridgeMap m_idToBridgeMap;
+ Vector<int> m_pendingPermissionRequests;
+
+ // In addition to the singleton instance pointer, we need to keep the setMockGeolocationPermission() state
+ // as a static (not object members) as this call may come in before the service has been created.
+ static enum PermissionState {
+ PermissionStateUnset,
+ PermissionStateAllowed,
+ PermissionStateDenied,
+ } s_permissionState;
+ static WebGeolocationServiceMockImpl* s_instance;
};
-bool WebGeolocationServiceMock::s_mockGeolocationPermission = false;
+WebGeolocationServiceMockImpl::PermissionState WebGeolocationServiceMockImpl::s_permissionState = WebGeolocationServiceMockImpl::PermissionStateUnset;
+WebGeolocationServiceMockImpl* WebGeolocationServiceMockImpl::s_instance = 0;
WebGeolocationServiceMock* WebGeolocationServiceMock::createWebGeolocationServiceMock()
{
@@ -143,7 +163,7 @@ WebGeolocationServiceMock* WebGeolocationServiceMock::createWebGeolocationServic
void WebGeolocationServiceMock::setMockGeolocationPermission(bool allowed)
{
- s_mockGeolocationPermission = allowed;
+ WebGeolocationServiceMockImpl::setMockGeolocationPermission(allowed);
}
void WebGeolocationServiceMock::setMockGeolocationPosition(double latitude, double longitude, double accuracy)
@@ -160,12 +180,35 @@ void WebGeolocationServiceMock::setMockGeolocationError(int errorCode, const Web
GeolocationServiceMock::setError(positionError);
}
+WebGeolocationServiceMockImpl::WebGeolocationServiceMockImpl()
+{
+ ASSERT(!s_instance);
+ s_instance = this;
+}
+
+WebGeolocationServiceMockImpl::~WebGeolocationServiceMockImpl()
+{
+ ASSERT(this == s_instance);
+ s_instance = 0;
+ // Reset the permission state, so any future service instance (e.g. running
+ // multiple tests in a single DRT run) will see a clean call sequence.
+ s_permissionState = PermissionStateUnset;
+ for (IdToBridgeMap::iterator it = m_idToBridgeMap.begin(); it != m_idToBridgeMap.end(); ++it)
+ it->second->didDestroyGeolocationService();
+}
+
+void WebGeolocationServiceMockImpl::setMockGeolocationPermission(bool allowed)
+{
+ s_permissionState = allowed ? PermissionStateAllowed : PermissionStateDenied;
+ if (s_instance)
+ s_instance->notifyPendingPermissions();
+}
+
void WebGeolocationServiceMockImpl::requestPermissionForFrame(int bridgeId, const WebURL& url)
{
- IdToBridgeMap::iterator iter = m_idToBridgeMap.find(bridgeId);
- if (iter == m_idToBridgeMap.end())
- return;
- iter->second->setIsAllowed(s_mockGeolocationPermission);
+ m_pendingPermissionRequests.append(bridgeId);
+ if (s_permissionState != PermissionStateUnset)
+ notifyPendingPermissions();
}
int WebGeolocationServiceMockImpl::attachBridge(WebGeolocationServiceBridge* bridge)
@@ -183,6 +226,19 @@ void WebGeolocationServiceMockImpl::detachBridge(int bridgeId)
m_idToBridgeMap.remove(bridgeId);
}
+void WebGeolocationServiceMockImpl::notifyPendingPermissions()
+{
+ ASSERT(s_permissionState == PermissionStateAllowed || s_permissionState == PermissionStateDenied);
+ Vector<int> pendingPermissionRequests;
+ pendingPermissionRequests.swap(m_pendingPermissionRequests);
+ for (Vector<int>::const_iterator it = pendingPermissionRequests.begin(); it != pendingPermissionRequests.end(); ++it) {
+ ASSERT(*it > 0);
+ IdToBridgeMap::iterator iter = m_idToBridgeMap.find(*it);
+ if (iter != m_idToBridgeMap.end())
+ iter->second->setIsAllowed(s_permissionState == PermissionStateAllowed);
+ }
+}
+
} // namespace WebKit
#endif // ENABLE(GEOLOCATION)
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list