Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(961)

Unified Diff: Source/modules/geolocation/testing/InternalsGeolocation.cpp

Issue 925953003: Make Geolocation internal test methods more resilient. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: Source/modules/geolocation/testing/InternalsGeolocation.cpp
diff --git a/Source/modules/geolocation/testing/InternalsGeolocation.cpp b/Source/modules/geolocation/testing/InternalsGeolocation.cpp
index 07e033027d02eb00c017a88bfedf1c7ca9ec52a6..54b624787e4e48504f67d32be54d33cca47d85c0 100644
--- a/Source/modules/geolocation/testing/InternalsGeolocation.cpp
+++ b/Source/modules/geolocation/testing/InternalsGeolocation.cpp
@@ -44,9 +44,11 @@ namespace blink {
void InternalsGeolocation::setGeolocationClientMock(Internals&, Document* document)
{
- ASSERT(document && document->frame());
- GeolocationClientMock* client = new GeolocationClientMock();
+ ASSERT(document);
+ if (!document->frame())
+ return;
+ GeolocationClientMock* client = new GeolocationClientMock();
for (Frame* childFrame = document->page()->mainFrame(); childFrame; childFrame = childFrame->tree().traverseNext()) {
if (childFrame->isLocalFrame())
GeolocationController::from(toLocalFrame(childFrame))->setClientForTest(client);
@@ -55,7 +57,10 @@ void InternalsGeolocation::setGeolocationClientMock(Internals&, Document* docume
void InternalsGeolocation::setGeolocationPosition(Internals&, Document* document, double latitude, double longitude, double accuracy)
{
- ASSERT(document && document->frame());
+ ASSERT(document);
+ if (!document->frame())
+ return;
+
GeolocationClientMock* client = geolocationClient(document);
if (!client)
return;
@@ -64,7 +69,10 @@ void InternalsGeolocation::setGeolocationPosition(Internals&, Document* document
void InternalsGeolocation::setGeolocationPositionUnavailableError(Internals&, Document* document, const String& message)
{
- ASSERT(document && document->frame());
+ ASSERT(document);
+ if (!document->frame())
+ return;
+
GeolocationClientMock* client = geolocationClient(document);
if (!client)
return;
@@ -73,7 +81,10 @@ void InternalsGeolocation::setGeolocationPositionUnavailableError(Internals&, Do
void InternalsGeolocation::setGeolocationPermission(Internals&, Document* document, bool allowed)
{
- ASSERT(document && document->frame());
+ ASSERT(document);
+ if (!document->frame())
+ return;
+
GeolocationClientMock* client = geolocationClient(document);
if (!client)
return;
@@ -82,7 +93,10 @@ void InternalsGeolocation::setGeolocationPermission(Internals&, Document* docume
int InternalsGeolocation::numberOfPendingGeolocationPermissionRequests(Internals&, Document* document)
{
- ASSERT(document && document->frame());
+ ASSERT(document);
+ if (!document->frame())
+ return -1;
+
GeolocationClientMock* client = geolocationClient(document);
if (!client)
return -1;
@@ -91,9 +105,13 @@ int InternalsGeolocation::numberOfPendingGeolocationPermissionRequests(Internals
GeolocationClientMock* InternalsGeolocation::geolocationClient(Document* document)
{
+ ASSERT(document);
+ if (!document->frame())
+ return nullptr;
+
GeolocationController* controller = GeolocationController::from(document->frame());
if (!controller->hasClientForTest())
- return 0;
+ return nullptr;
return static_cast<GeolocationClientMock*>(controller->client());
}

Powered by Google App Engine
This is Rietveld 408576698