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

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

Issue 8775004: Geolocation InfoBar sometimes doesn't expire when navigating back. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 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
« no previous file with comments | « chrome/browser/geolocation/chrome_geolocation_permission_context.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/geolocation/chrome_geolocation_permission_context_unittest.cc
diff --git a/chrome/browser/geolocation/chrome_geolocation_permission_context_unittest.cc b/chrome/browser/geolocation/chrome_geolocation_permission_context_unittest.cc
index 4530a11e2389d5315f779f3163cd17445fbc503a..3529e56c514a17a299920b1eeb2e5b16bb56f337 100644
--- a/chrome/browser/geolocation/chrome_geolocation_permission_context_unittest.cc
+++ b/chrome/browser/geolocation/chrome_geolocation_permission_context_unittest.cc
@@ -24,6 +24,7 @@
#include "content/browser/geolocation/location_provider.h"
#include "content/browser/geolocation/mock_location_provider.h"
#include "content/browser/renderer_host/mock_render_process_host.h"
+#include "content/browser/tab_contents/navigation_details.h"
#include "content/browser/tab_contents/test_tab_contents.h"
#include "content/public/browser/notification_registrar.h"
#include "content/public/browser/notification_service.h"
@@ -570,3 +571,33 @@ TEST_F(GeolocationPermissionContextTests, TabDestroyed) {
DeleteContents();
infobar_0->InfoBarClosed();
}
+
+TEST_F(GeolocationPermissionContextTests, InfoBarUsesCommittedEntry) {
+ GURL requesting_frame_0("http://www.example.com/geolocation");
+ GURL requesting_frame_1("http://www.example-2.com/geolocation");
+ NavigateAndCommit(requesting_frame_0);
+ NavigateAndCommit(requesting_frame_1);
+ EXPECT_EQ(0U, infobar_tab_helper()->infobar_count());
+ // Go back: navigate to a pending entry before requesting geolocation
+ // permission.
+ contents()->controller().GoBack();
+ // Request permission for the committed frame (not the pending one).
+ RequestGeolocationPermission(
+ process_id(), render_id(), bridge_id(), requesting_frame_1);
+ // Ensure the infobar is created.
+ ASSERT_EQ(1U, infobar_tab_helper()->infobar_count());
+ InfoBarDelegate* infobar_0 = infobar_tab_helper()->GetInfoBarDelegateAt(0);
+ ASSERT_TRUE(infobar_0);
+ // Ensure the infobar is not yet expired.
+ content::LoadCommittedDetails details;
+ details.entry = contents()->controller().GetLastCommittedEntry();
+ ASSERT_FALSE(infobar_0->ShouldExpire(details));
+ // Commit the "GoBack()" above, and ensure the infobar is now expired.
+ contents()->CommitPendingNavigation();
+ details.entry = contents()->controller().GetLastCommittedEntry();
+ ASSERT_TRUE(infobar_0->ShouldExpire(details));
+
+ // Delete the tab contents.
+ DeleteContents();
+ infobar_0->InfoBarClosed();
+}
« no previous file with comments | « chrome/browser/geolocation/chrome_geolocation_permission_context.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698