summaryrefslogtreecommitdiffstats
path: root/chrome/browser/geolocation/geolocation_browsertest.cc
diff options
context:
space:
mode:
authorbulach@chromium.org <bulach@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-26 14:20:02 +0000
committerbulach@chromium.org <bulach@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-26 14:20:02 +0000
commit356f7e4168c535a36c9e8287e4771cb35c0341ac (patch)
tree355337320bfd9a55a6d042201872188e4f8c9f1f /chrome/browser/geolocation/geolocation_browsertest.cc
parentce21660d2b08335f80c63a64f1dee220df4ec869 (diff)
downloadchromium_src-356f7e4168c535a36c9e8287e4771cb35c0341ac.zip
chromium_src-356f7e4168c535a36c9e8287e4771cb35c0341ac.tar.gz
chromium_src-356f7e4168c535a36c9e8287e4771cb35c0341ac.tar.bz2
Uses GeolocationContentSettingsMap on GeolocationPermissionContext to persist settings.
TEST=geolocation_browsertest.cc Review URL: http://codereview.chromium.org/1141004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@42757 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/geolocation/geolocation_browsertest.cc')
-rw-r--r--chrome/browser/geolocation/geolocation_browsertest.cc55
1 files changed, 25 insertions, 30 deletions
diff --git a/chrome/browser/geolocation/geolocation_browsertest.cc b/chrome/browser/geolocation/geolocation_browsertest.cc
index 647ecb6..753d430 100644
--- a/chrome/browser/geolocation/geolocation_browsertest.cc
+++ b/chrome/browser/geolocation/geolocation_browsertest.cc
@@ -8,6 +8,7 @@
#include "chrome/browser/browser.h"
#include "chrome/browser/browser_list.h"
#include "chrome/browser/dom_operation_notification_details.h"
+#include "chrome/browser/geolocation/geolocation_content_settings_map.h"
#include "chrome/browser/geolocation/location_arbitrator.h"
#include "chrome/browser/geolocation/location_provider.h"
#include "chrome/browser/geolocation/mock_location_provider.h"
@@ -171,7 +172,8 @@ void NotifyGeopositionOnIOThread(const Geoposition& geoposition) {
class GeolocationBrowserTest : public InProcessBrowserTest {
public:
GeolocationBrowserTest()
- : infobar_(NULL), current_browser_(NULL),
+ : infobar_(NULL),
+ current_browser_(NULL),
html_for_tests_("files/geolocation/simple.html") {
EnableDOMAutomation();
}
@@ -236,6 +238,9 @@ class GeolocationBrowserTest : public InProcessBrowserTest {
}
EXPECT_TRUE(notification_observer.infobar_);
infobar_ = notification_observer.infobar_;
+ } else {
+ // Infobar wasn't displayed, so we need to wait for the JS prompt instead.
+ WaitForJSPrompt();
}
}
@@ -381,17 +386,13 @@ IN_PROC_BROWSER_TEST_F(GeolocationBrowserTest, MAYBE_ErrorOnPermissionDenied) {
#endif
IN_PROC_BROWSER_TEST_F(GeolocationBrowserTest, MAYBE_NoInfobarForSecondTab) {
-#if 0
- // TODO(bulach): enable this test once we use HostContentSettingsMap instead
- // of files.
Initialize(INITIALIZATION_NONE);
- SendGeoposition(true, GeopositionFromLatLong(0, 0));
+ AddGeolocationWatch(true);
SetInfobarResponse(current_url_, true);
// Checks infobar will not be created a second tab.
Initialize(INITIALIZATION_NEWTAB);
- SendGeoposition(false, GeopositionFromLatLong(0, 0));
- CheckStringValueFromJavascript("0", "geoGetLastError()");
-#endif
+ AddGeolocationWatch(false);
+ CheckGeoposition(MockLocationProvider::instance_->position_);
}
#if defined(OS_MACOSX)
@@ -403,19 +404,16 @@ IN_PROC_BROWSER_TEST_F(GeolocationBrowserTest, MAYBE_NoInfobarForSecondTab) {
#endif
IN_PROC_BROWSER_TEST_F(GeolocationBrowserTest, MAYBE_NoInfobarForDeniedOrigin) {
-#if 0
- // TODO(bulach): enable this test once we use HostContentSettingsMap instead
- // of files.
- WritePermissionFile("{\"allowed\":false}");
- // Checks no infobar will be created.
Initialize(INITIALIZATION_NONE);
- SendGeoposition(false, GeopositionFromLatLong(0, 0));
+ current_browser_->profile()->GetGeolocationContentSettingsMap()->
+ SetContentSetting(current_url_, current_url_, CONTENT_SETTING_BLOCK);
+ AddGeolocationWatch(false);
+ // Checks we have an error for this denied origin.
CheckStringValueFromJavascript("1", "geoGetLastError()");
// Checks infobar will not be created a second tab.
Initialize(INITIALIZATION_NEWTAB);
- SendGeoposition(false, GeopositionFromLatLong(0, 0));
+ AddGeolocationWatch(false);
CheckStringValueFromJavascript("1", "geoGetLastError()");
-#endif
}
#if defined(OS_MACOSX)
@@ -428,15 +426,13 @@ IN_PROC_BROWSER_TEST_F(GeolocationBrowserTest, MAYBE_NoInfobarForDeniedOrigin) {
IN_PROC_BROWSER_TEST_F(GeolocationBrowserTest,
MAYBE_NoInfobarForAllowedOrigin) {
-#if 0
- // TODO(bulach): enable this test once we use HostContentSettingsMap instead
- // of files.
- WritePermissionFile("{\"allowed\":true}");
+ Initialize(INITIALIZATION_NONE);
+ current_browser_->profile()->GetGeolocationContentSettingsMap()->
+ SetContentSetting(current_url_, current_url_, CONTENT_SETTING_ALLOW);
// Checks no infobar will be created and there's no error callback.
Initialize(INITIALIZATION_NONE);
- SendGeoposition(false, GeopositionFromLatLong(0, 0));
- CheckStringValueFromJavascript("0", "geoGetLastError()");
-#endif
+ AddGeolocationWatch(false);
+ CheckGeoposition(MockLocationProvider::instance_->position_);
}
#if defined(OS_MACOSX)
@@ -447,20 +443,19 @@ IN_PROC_BROWSER_TEST_F(GeolocationBrowserTest,
#define MAYBE_InfobarForOffTheRecord InfobarForOffTheRecord
#endif
-IN_PROC_BROWSER_TEST_F(GeolocationBrowserTest, MAYBE_InfobarForOffTheRecord) {
- // Checks infobar will be created for regular profile.
+IN_PROC_BROWSER_TEST_F(GeolocationBrowserTest, MAYBE_NoInfobarForOffTheRecord) {
+ // First, check infobar will be created for regular profile
Initialize(INITIALIZATION_NONE);
AddGeolocationWatch(true);
+ // Response will be persisted
SetInfobarResponse(current_url_, true);
CheckGeoposition(MockLocationProvider::instance_->position_);
// Disables further prompts from this tab.
CheckStringValueFromJavascript("false", "geoEnableAlerts(false)");
- // Go off the record, and checks infobar will be created and an error callback
- // is triggered.
+ // Go off the record, and checks no infobar will be created.
Initialize(INITIALIZATION_OFFTHERECORD);
- AddGeolocationWatch(true);
- SetInfobarResponse(current_url_, false);
- CheckStringValueFromJavascript("1", "geoGetLastError()");
+ AddGeolocationWatch(false);
+ CheckGeoposition(MockLocationProvider::instance_->position_);
}
#if defined(OS_MACOSX)