Chromium Code Reviews| Index: chrome/browser/geolocation/geolocation_browsertest.cc |
| diff --git a/chrome/browser/geolocation/geolocation_browsertest.cc b/chrome/browser/geolocation/geolocation_browsertest.cc |
| index 647ecb6c4955b8ee47d463e1960690aa5e63a89e..753d4302f81ee9a63a25923ac5080eea5f4f76aa 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 |
|
TVL
2010/03/26 15:24:29
I think these should all be "NoInfo...", they don'
|
| #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) |