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..af6988a44356cddaf70254d0ccddb6b3f9572233 100644 |
--- a/chrome/browser/geolocation/geolocation_permission_context_unittest.cc |
+++ b/chrome/browser/geolocation/geolocation_permission_context_unittest.cc |
@@ -22,6 +22,7 @@ |
#include "chrome/browser/content_settings/tab_specific_content_settings.h" |
#include "chrome/browser/geolocation/geolocation_permission_context_factory.h" |
#include "chrome/browser/infobars/infobar_service.h" |
+#include "chrome/browser/permissions/permission_infobar_manager.h" |
#include "chrome/browser/permissions/permission_request_id.h" |
#include "chrome/browser/ui/website_settings/permission_bubble_request.h" |
#include "chrome/common/chrome_switches.h" |
@@ -127,6 +128,12 @@ class GeolocationPermissionContextTests |
InfoBarService* infobar_service_for_tab(int tab) { |
return InfoBarService::FromWebContents(extra_tabs_[tab]); |
} |
+ PermissionInfoBarManager* infobar_manager() { |
+ return PermissionInfoBarManager::FromWebContents(web_contents()); |
+ } |
+ PermissionInfoBarManager* infobar_manager_for_tab(int tab) { |
+ return PermissionInfoBarManager::FromWebContents(extra_tabs_[tab]); |
+ } |
void RequestGeolocationPermission(content::WebContents* web_contents, |
const PermissionRequestID& id, |
@@ -156,6 +163,9 @@ class GeolocationPermissionContextTests |
void AcceptPrompt(); |
base::string16 GetPromptText(); |
+ bool IsInfoBarShowPending(PermissionInfoBarManager* manager) const; |
+ void ShowNextQueuedInfoBar(PermissionInfoBarManager* manager); |
+ |
// owned by the browser context |
GeolocationPermissionContext* geolocation_permission_context_; |
ClosedInfoBarTracker closed_infobar_tracker_; |
@@ -241,6 +251,7 @@ void GeolocationPermissionContextTests::AddNewTab(const GURL& url) { |
#endif |
#if defined(OS_ANDROID) |
InfoBarService::CreateForWebContents(new_tab); |
+ PermissionInfoBarManager::CreateForWebContents(new_tab); |
#else |
PermissionBubbleManager::CreateForWebContents(new_tab); |
PermissionBubbleManager* permission_bubble_manager = |
@@ -276,6 +287,7 @@ void GeolocationPermissionContextTests::SetUp() { |
extensions::SetViewType(web_contents(), extensions::VIEW_TYPE_TAB_CONTENTS); |
#endif |
InfoBarService::CreateForWebContents(web_contents()); |
+ PermissionInfoBarManager::CreateForWebContents(web_contents()); |
TabSpecificContentSettings::CreateForWebContents(web_contents()); |
geolocation_permission_context_ = |
GeolocationPermissionContextFactory::GetForProfile(profile()); |
@@ -379,6 +391,16 @@ base::string16 GeolocationPermissionContextTests::GetPromptText() { |
#endif |
} |
+bool GeolocationPermissionContextTests::IsInfoBarShowPending( |
+ PermissionInfoBarManager* manager) const { |
+ return manager->is_show_pending_; |
+} |
+ |
+void GeolocationPermissionContextTests::ShowNextQueuedInfoBar( |
+ PermissionInfoBarManager* manager) { |
+ manager->ShowNextQueuedRequest(); |
+} |
+ |
// Tests ---------------------------------------------------------------------- |
TEST_F(GeolocationPermissionContextTests, SinglePermissionBubble) { |
@@ -496,6 +518,11 @@ TEST_F(GeolocationPermissionContextTests, QueuedPermission) { |
EXPECT_EQ(1U, closed_infobar_tracker_.size()); |
EXPECT_TRUE(closed_infobar_tracker_.Contains(infobar_0)); |
closed_infobar_tracker_.Clear(); |
+ |
+ // Make the next request appear after having checked that it was posted |
+ // to the event loop. |
+ ASSERT_TRUE(IsInfoBarShowPending(infobar_manager())); |
+ ShowNextQueuedInfoBar(infobar_manager()); |
#endif |
// Now we should have a new infobar for the second frame. |
@@ -564,14 +591,9 @@ TEST_F(GeolocationPermissionContextTests, HashIsIgnored) { |
#endif |
} |
-// TODO(felt): The bubble is rejecting file:// permission requests. |
-// Fix and enable this test. crbug.com/444047 |
-#if defined(OS_ANDROID) |
-#define MAYBE_PermissionForFileScheme PermissionForFileScheme |
-#else |
-#define MAYBE_PermissionForFileScheme DISABLED_PermissionForFileScheme |
-#endif |
-TEST_F(GeolocationPermissionContextTests, MAYBE_PermissionForFileScheme) { |
+// TODO(felt): The bubble and (recently) the infobar are rejecting file:// |
+// permission requests. Fix and enable this test. crbug.com/444047 |
+TEST_F(GeolocationPermissionContextTests, DISABLED_PermissionForFileScheme) { |
GURL requesting_frame("file://example/geolocation.html"); |
NavigateAndCommit(requesting_frame); |
BubbleManagerDocumentLoadCompleted(); |
@@ -624,7 +646,12 @@ TEST_F(GeolocationPermissionContextTests, CancelGeolocationPermissionRequest) { |
CloseBubble(manager); |
#else |
geolocation_permission_context_->CancelPermissionRequest(web_contents(), |
- RequestID(0)); |
+ RequestID(0)); |
+ |
+ // Make the next request appear after having checked that it was posted |
+ // to the event loop. |
+ ASSERT_TRUE(IsInfoBarShowPending(infobar_manager())); |
+ ShowNextQueuedInfoBar(infobar_manager()); |
#endif |
// Check that the next pending request is created correctly. |
@@ -705,16 +732,20 @@ TEST_F(GeolocationPermissionContextTests, SameOriginMultipleTabs) { |
EXPECT_EQ(2U, closed_infobar_tracker_.size()); |
EXPECT_TRUE(closed_infobar_tracker_.Contains(infobar_a0)); |
#endif |
+ |
CheckPermissionMessageSent(0, true); |
- // Because they're the same origin, this will cause tab A1's infobar to |
- // disappear. It does not cause the bubble to disappear: crbug.com/443013. |
- // TODO(felt): Update this test when the bubble's behavior is changed. |
+ |
+ // Because they're the same origin, tab_a1's bubble/infobar should disappear. |
+ // In the past, infobar used to disappear and bubble did not. |
+ // Now both have a consistent behviour (albiet broken) of not removing |
+ // the bubble/infobar: see crbug.com/443013. |
+ // TODO(felt): Update this test when this behavior is changed. |
// Either way, tab B should still have a pending permission request. |
#if !defined(OS_ANDROID) |
ASSERT_EQ(1U, GetBubblesQueueSize(manager_a1)); |
ASSERT_EQ(1U, GetBubblesQueueSize(manager_b)); |
#else |
- CheckPermissionMessageSentForTab(1, 0, true); |
+ EXPECT_EQ(1U, infobar_service_for_tab(1)->infobar_count()); |
ASSERT_EQ(1U, infobar_service_for_tab(0)->infobar_count()); |
#endif |
} |
@@ -759,19 +790,26 @@ TEST_F(GeolocationPermissionContextTests, QueuedOriginMultipleTabs) { |
ASSERT_TRUE(infobar_delegate_a1); |
infobar_delegate_a1->Accept(); |
infobar_service_for_tab(0)->RemoveInfoBar(infobar_a1); |
- EXPECT_EQ(2U, closed_infobar_tracker_.size()); |
+ EXPECT_EQ(1U, closed_infobar_tracker_.size()); |
EXPECT_TRUE(closed_infobar_tracker_.Contains(infobar_a1)); |
+ |
+ // Make the next request appear after having checked that it was posted |
+ // to the event loop. |
+ ASSERT_TRUE(IsInfoBarShowPending(infobar_manager_for_tab(0))); |
+ ShowNextQueuedInfoBar(infobar_manager_for_tab(0)); |
#endif |
+ |
CheckPermissionMessageSentForTab(0, 0, true); |
- // Because they're the same origin, this will cause tab A0's infobar to |
- // disappear. It does not cause the bubble to disappear: crbug.com/443013. |
- // TODO(felt): Update this test when the bubble's behavior is changed. |
+ // Because they're the same origin, tab_a0's bubble/infobar should disappear. |
+ // In the past, infobar used to disappear and bubble did not. |
+ // Now both have a consistent behviour (albiet broken) of not removing |
+ // the bubble/infobar: see crbug.com/443013. |
+ // TODO(felt): Update this test when this behavior is changed. |
#if !defined(OS_ANDROID) |
EXPECT_EQ(1U, GetBubblesQueueSize(manager_a0)); |
#else |
- EXPECT_EQ(0U, infobar_service()->infobar_count()); |
- CheckPermissionMessageSent(0, true); |
+ EXPECT_EQ(1U, infobar_service()->infobar_count()); |
#endif |
// The second request should now be visible in tab A1. |
@@ -917,6 +955,11 @@ TEST_F(GeolocationPermissionContextTests, LastUsageAuditedMultipleFrames) { |
AcceptPrompt(); |
#if defined(OS_ANDROID) |
infobar_service()->RemoveInfoBar(infobar_service()->infobar_at(0)); |
+ |
+ // Make the next request appear after having checked that it was posted |
+ // to the event loop. |
+ ASSERT_TRUE(IsInfoBarShowPending(infobar_manager())); |
+ ShowNextQueuedInfoBar(infobar_manager()); |
#endif |
CheckTabContentsState(requesting_frame_0, CONTENT_SETTING_ALLOW); |
CheckPermissionMessageSent(0, true); |