| Index: chrome/browser/geolocation/geolocation_browsertest.cc
|
| diff --git a/chrome/browser/geolocation/geolocation_browsertest.cc b/chrome/browser/geolocation/geolocation_browsertest.cc
|
| index e0212fdc6850ab3a20d3111d34e9dcde53f7ce0e..74583ce68862e07c0cca5ed509a146034b610a12 100644
|
| --- a/chrome/browser/geolocation/geolocation_browsertest.cc
|
| +++ b/chrome/browser/geolocation/geolocation_browsertest.cc
|
| @@ -254,6 +254,9 @@ class GeolocationBrowserTest : public InProcessBrowserTest {
|
| // Convenience method to look up the number of queued permission requests.
|
| int GetRequestQueueSize(PermissionRequestManager* manager);
|
|
|
| + // Toggle whether the prompt decision should be persisted.
|
| + void TogglePersist(bool persist);
|
| +
|
| private:
|
| // Calls watchPosition() in JavaScript and accepts or denies the resulting
|
| // permission request. Returns the JavaScript response.
|
| @@ -429,6 +432,13 @@ int GeolocationBrowserTest::GetRequestQueueSize(
|
| return static_cast<int>(manager->requests_.size());
|
| }
|
|
|
| +void GeolocationBrowserTest::TogglePersist(bool persist) {
|
| + content::WebContents* web_contents =
|
| + current_browser()->tab_strip_model()->GetActiveWebContents();
|
| + PermissionRequestManager::FromWebContents(web_contents)
|
| + ->TogglePersist(persist);
|
| +}
|
| +
|
| // Tests ----------------------------------------------------------------------
|
|
|
| #if defined(OS_LINUX)
|
| @@ -440,6 +450,14 @@ int GeolocationBrowserTest::GetRequestQueueSize(
|
| IN_PROC_BROWSER_TEST_F(GeolocationBrowserTest, MAYBE_DisplaysPrompt) {
|
| ASSERT_NO_FATAL_FAILURE(Initialize(INITIALIZATION_DEFAULT));
|
| ASSERT_TRUE(WatchPositionAndGrantPermission());
|
| +
|
| + EXPECT_EQ(CONTENT_SETTING_ALLOW,
|
| + GetHostContentSettingsMap()->GetContentSetting(
|
| + current_url(), current_url(), CONTENT_SETTINGS_TYPE_GEOLOCATION,
|
| + std::string()));
|
| +
|
| + // Ensure a second request doesn't create a prompt in this tab.
|
| + WatchPositionAndObservePermissionRequest(false);
|
| }
|
|
|
| #if defined(OS_LINUX)
|
| @@ -458,6 +476,14 @@ IN_PROC_BROWSER_TEST_F(GeolocationBrowserTest, ErrorOnPermissionDenied) {
|
| ASSERT_NO_FATAL_FAILURE(Initialize(INITIALIZATION_DEFAULT));
|
| EXPECT_TRUE(WatchPositionAndDenyPermission());
|
| ExpectValueFromScript(GetErrorCodePermissionDenied(), "geoGetLastError()");
|
| +
|
| + EXPECT_EQ(CONTENT_SETTING_BLOCK,
|
| + GetHostContentSettingsMap()->GetContentSetting(
|
| + current_url(), current_url(), CONTENT_SETTINGS_TYPE_GEOLOCATION,
|
| + std::string()));
|
| +
|
| + // Ensure a second request doesn't create a prompt in this tab.
|
| + WatchPositionAndObservePermissionRequest(false);
|
| }
|
|
|
| #if defined(OS_LINUX)
|
| @@ -540,6 +566,46 @@ IN_PROC_BROWSER_TEST_F(GeolocationBrowserTest,
|
| ExpectPosition(fake_latitude(), fake_longitude());
|
| }
|
|
|
| +IN_PROC_BROWSER_TEST_F(GeolocationBrowserTest, TogglePersistGranted) {
|
| + // Initialize and turn persistence off.
|
| + ASSERT_NO_FATAL_FAILURE(Initialize(INITIALIZATION_DEFAULT));
|
| + TogglePersist(false);
|
| +
|
| + ASSERT_TRUE(WatchPositionAndGrantPermission());
|
| + EXPECT_EQ(CONTENT_SETTING_ASK,
|
| + GetHostContentSettingsMap()->GetContentSetting(
|
| + current_url(), current_url(), CONTENT_SETTINGS_TYPE_GEOLOCATION,
|
| + std::string()));
|
| +
|
| + // Expect the grant to be remembered at the blink layer, so a second request
|
| + // on this page doesn't create a request.
|
| + WatchPositionAndObservePermissionRequest(false);
|
| +
|
| + // Navigate and ensure that a prompt is shown when we request again.
|
| + ASSERT_NO_FATAL_FAILURE(Initialize(INITIALIZATION_DEFAULT));
|
| + WatchPositionAndObservePermissionRequest(true);
|
| +}
|
| +
|
| +IN_PROC_BROWSER_TEST_F(GeolocationBrowserTest, TogglePersistBlocked) {
|
| + // Initialize and turn persistence off.
|
| + ASSERT_NO_FATAL_FAILURE(Initialize(INITIALIZATION_DEFAULT));
|
| + TogglePersist(false);
|
| +
|
| + ASSERT_TRUE(WatchPositionAndDenyPermission());
|
| + EXPECT_EQ(CONTENT_SETTING_ASK,
|
| + GetHostContentSettingsMap()->GetContentSetting(
|
| + current_url(), current_url(), CONTENT_SETTINGS_TYPE_GEOLOCATION,
|
| + std::string()));
|
| +
|
| + // Expect the block to be remembered at the blink layer, so a second request
|
| + // on this page doesn't create a request.
|
| + WatchPositionAndObservePermissionRequest(false);
|
| +
|
| + // Navigate and ensure that a prompt is shown when we request again.
|
| + ASSERT_NO_FATAL_FAILURE(Initialize(INITIALIZATION_DEFAULT));
|
| + WatchPositionAndObservePermissionRequest(true);
|
| +}
|
| +
|
| #if defined(OS_LINUX)
|
| // http://crbug.com/527437
|
| #define MAYBE_IFramesWithFreshPosition DISABLED_IFramesWithFreshPosition
|
|
|