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..1401c7e5014ee6a19071d71e15cc789750a997cd 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,11 @@ 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())); |
raymes
2016/09/15 05:16:08
Maybe we could do WatchPositionAndObservePermissio
dominickn
2016/09/15 05:40:29
Done.
|
} |
#if defined(OS_LINUX) |
@@ -458,6 +473,11 @@ 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())); |
raymes
2016/09/15 05:16:08
Same with this (see below)
dominickn
2016/09/15 05:40:29
Done.
|
} |
#if defined(OS_LINUX) |
@@ -540,6 +560,30 @@ 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())); |
raymes
2016/09/15 05:16:08
Can we do WatchPositionAndObservePermissionRequest
dominickn
2016/09/15 05:40:29
Done.
|
+} |
+ |
+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())); |
raymes
2016/09/15 05:16:08
Same here.
dominickn
2016/09/15 05:40:29
Done.
|
+} |
+ |
#if defined(OS_LINUX) |
// http://crbug.com/527437 |
#define MAYBE_IFramesWithFreshPosition DISABLED_IFramesWithFreshPosition |