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

Unified Diff: chrome/browser/geolocation/geolocation_permission_context_unittest.cc

Issue 1411653004: Remove last usage functions from HostContentSettingsMap Base URL: https://chromium.googlesource.com/chromium/src.git@simplify-host-content-settings
Patch Set: Created 5 years, 1 month 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: chrome/browser/geolocation/geolocation_permission_context_unittest.cc
diff --git a/chrome/browser/geolocation/geolocation_permission_context_unittest.cc b/chrome/browser/geolocation/geolocation_permission_context_unittest.cc
index e33acba4d82811a21d7f142d86537eba91f46aba..f1b4dfd053604b63a066050442424152a4f30a76 100644
--- a/chrome/browser/geolocation/geolocation_permission_context_unittest.cc
+++ b/chrome/browser/geolocation/geolocation_permission_context_unittest.cc
@@ -832,140 +832,3 @@ TEST_F(GeolocationPermissionContextTests, TabDestroyed) {
CONTENT_SETTING_ASK,
GetGeolocationContentSetting(requesting_frame_1, requesting_frame_0));
}
-
-TEST_F(GeolocationPermissionContextTests, LastUsageAudited) {
- GURL requesting_frame("http://www.example.com/geolocation");
- NavigateAndCommit(requesting_frame);
- BubbleManagerDocumentLoadCompleted();
-
- base::SimpleTestClock* test_clock = new base::SimpleTestClock;
- test_clock->SetNow(base::Time::UnixEpoch() +
- base::TimeDelta::FromSeconds(10));
-
- HostContentSettingsMap* map =
- HostContentSettingsMapFactory::GetForProfile(profile());
- map->SetPrefClockForTesting(scoped_ptr<base::Clock>(test_clock));
-
- // The permission shouldn't have been used yet.
- EXPECT_EQ(map->GetLastUsage(requesting_frame.GetOrigin(),
- requesting_frame.GetOrigin(),
- CONTENT_SETTINGS_TYPE_GEOLOCATION).ToDoubleT(),
- 0);
- ASSERT_EQ(0U, GetNumberOfPrompts());
- RequestGeolocationPermission(
- web_contents(), RequestID(0), requesting_frame, false);
- ASSERT_EQ(1U, GetNumberOfPrompts());
-
- AcceptPrompt();
- CheckTabContentsState(requesting_frame, CONTENT_SETTING_ALLOW);
- CheckPermissionMessageSent(0, true);
-
- // Permission has been used at the starting time.
- EXPECT_EQ(map->GetLastUsage(requesting_frame.GetOrigin(),
- requesting_frame.GetOrigin(),
- CONTENT_SETTINGS_TYPE_GEOLOCATION).ToDoubleT(),
- 10);
-
- test_clock->Advance(base::TimeDelta::FromSeconds(3));
- RequestGeolocationPermission(
- web_contents(), RequestID(0), requesting_frame, false);
-
- // Permission has been used three seconds later.
- EXPECT_EQ(map->GetLastUsage(requesting_frame.GetOrigin(),
- requesting_frame.GetOrigin(),
- CONTENT_SETTINGS_TYPE_GEOLOCATION).ToDoubleT(),
- 13);
-}
-
-TEST_F(GeolocationPermissionContextTests, LastUsageAuditedMultipleFrames) {
- base::SimpleTestClock* test_clock = new base::SimpleTestClock;
- test_clock->SetNow(base::Time::UnixEpoch() +
- base::TimeDelta::FromSeconds(10));
-
- HostContentSettingsMap* map =
- HostContentSettingsMapFactory::GetForProfile(profile());
- map->SetPrefClockForTesting(scoped_ptr<base::Clock>(test_clock));
-
- GURL requesting_frame_0("http://www.example.com/geolocation");
- GURL requesting_frame_1("http://www.example-2.com/geolocation");
-
- // The permission shouldn't have been used yet.
- EXPECT_EQ(map->GetLastUsage(requesting_frame_0.GetOrigin(),
- requesting_frame_0.GetOrigin(),
- CONTENT_SETTINGS_TYPE_GEOLOCATION).ToDoubleT(),
- 0);
- EXPECT_EQ(map->GetLastUsage(requesting_frame_1.GetOrigin(),
- requesting_frame_0.GetOrigin(),
- CONTENT_SETTINGS_TYPE_GEOLOCATION).ToDoubleT(),
- 0);
-
- NavigateAndCommit(requesting_frame_0);
- BubbleManagerDocumentLoadCompleted();
-
- EXPECT_EQ(0U, GetNumberOfPrompts());
-
- // Request permission for two frames.
- RequestGeolocationPermission(
- web_contents(), RequestID(0), requesting_frame_0, false);
- RequestGeolocationPermission(
- web_contents(), RequestID(1), requesting_frame_1, false);
-
- // Ensure only one infobar is created.
- ASSERT_EQ(1U, GetNumberOfPrompts());
-
- // Accept the first frame.
- AcceptPrompt();
-#if defined(OS_ANDROID)
- infobar_service()->RemoveInfoBar(infobar_service()->infobar_at(0));
-#endif
- CheckTabContentsState(requesting_frame_0, CONTENT_SETTING_ALLOW);
- CheckPermissionMessageSent(0, true);
-
- // Verify that accepting the first didn't accept because it's embedded
- // in the other.
- EXPECT_EQ(map->GetLastUsage(requesting_frame_0.GetOrigin(),
- requesting_frame_0.GetOrigin(),
- CONTENT_SETTINGS_TYPE_GEOLOCATION).ToDoubleT(),
- 10);
- EXPECT_EQ(map->GetLastUsage(requesting_frame_1.GetOrigin(),
- requesting_frame_0.GetOrigin(),
- CONTENT_SETTINGS_TYPE_GEOLOCATION).ToDoubleT(),
- 0);
-
- ASSERT_EQ(1U, GetNumberOfPrompts());
-
- test_clock->Advance(base::TimeDelta::FromSeconds(1));
-
- // Allow the second frame.
- AcceptPrompt();
- CheckTabContentsState(requesting_frame_1, CONTENT_SETTING_ALLOW);
- CheckPermissionMessageSent(1, true);
-#if defined(OS_ANDROID)
- infobar_service()->RemoveInfoBar(infobar_service()->infobar_at(0));
-#endif
-
- // Verify that the times are different.
- EXPECT_EQ(map->GetLastUsage(requesting_frame_0.GetOrigin(),
- requesting_frame_0.GetOrigin(),
- CONTENT_SETTINGS_TYPE_GEOLOCATION).ToDoubleT(),
- 10);
- EXPECT_EQ(map->GetLastUsage(requesting_frame_1.GetOrigin(),
- requesting_frame_0.GetOrigin(),
- CONTENT_SETTINGS_TYPE_GEOLOCATION).ToDoubleT(),
- 11);
-
- test_clock->Advance(base::TimeDelta::FromSeconds(2));
- RequestGeolocationPermission(
- web_contents(), RequestID(0), requesting_frame_0, false);
-
- // Verify that requesting permission in one frame doesn't update other where
- // it is the embedder.
- EXPECT_EQ(map->GetLastUsage(requesting_frame_0.GetOrigin(),
- requesting_frame_0.GetOrigin(),
- CONTENT_SETTINGS_TYPE_GEOLOCATION).ToDoubleT(),
- 13);
- EXPECT_EQ(map->GetLastUsage(requesting_frame_1.GetOrigin(),
- requesting_frame_0.GetOrigin(),
- CONTENT_SETTINGS_TYPE_GEOLOCATION).ToDoubleT(),
- 11);
-}

Powered by Google App Engine
This is Rietveld 408576698