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 054fb30ae9eb6f9f8457bbba63e89438dc85b870..c95b1ec9adfb9f12f7ec28faef72b3a3edf03032 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/mock_permission_bubble_view.h" |
#include "chrome/browser/ui/website_settings/permission_bubble_manager.h" |
@@ -126,6 +127,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, |
@@ -154,6 +161,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_; |
@@ -238,6 +248,7 @@ void GeolocationPermissionContextTests::AddNewTab(const GURL& url) { |
extensions::SetViewType(new_tab, extensions::VIEW_TYPE_TAB_CONTENTS); |
#endif |
InfoBarService::CreateForWebContents(new_tab); |
+ PermissionInfoBarManager::CreateForWebContents(new_tab); |
if (BubbleEnabled()) { |
PermissionBubbleManager::CreateForWebContents(new_tab); |
PermissionBubbleManager* permission_bubble_manager = |
@@ -273,6 +284,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()); |
@@ -376,6 +388,16 @@ base::string16 GeolocationPermissionContextTests::GetPromptText() { |
return infobar_delegate->GetMessageText(); |
} |
+bool GeolocationPermissionContextTests::IsInfoBarShowPending( |
+ PermissionInfoBarManager* manager) const { |
+ return manager->is_show_pending_; |
+} |
+ |
+void GeolocationPermissionContextTests::ShowNextQueuedInfoBar( |
+ PermissionInfoBarManager* manager) { |
+ manager->ShowNextQueuedRequest(); |
+} |
+ |
// Tests ---------------------------------------------------------------------- |
TEST_F(GeolocationPermissionContextTests, SinglePermissionInfobar) { |
@@ -497,6 +519,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()); |
} |
// Now we should have a new infobar for the second frame. |
@@ -560,11 +587,9 @@ TEST_F(GeolocationPermissionContextTests, HashIsIgnored) { |
} |
} |
-TEST_F(GeolocationPermissionContextTests, PermissionForFileScheme) { |
- // TODO(felt): The bubble is rejecting file:// permission requests. |
- // Fix and enable this test. crbug.com/444047 |
- if (BubbleEnabled()) return; |
- |
+// 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); |
if (BubbleEnabled()) BubbleManagerDocumentLoadCompleted(); |
@@ -618,6 +643,11 @@ TEST_F(GeolocationPermissionContextTests, CancelGeolocationPermissionRequest) { |
} else { |
geolocation_permission_context_->CancelPermissionRequest(web_contents(), |
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()); |
} |
// Check that the next pending request is created correctly. |
@@ -695,17 +725,20 @@ TEST_F(GeolocationPermissionContextTests, SameOriginMultipleTabs) { |
ASSERT_TRUE(infobar_delegate_a0); |
infobar_delegate_a0->Accept(); |
infobar_service()->RemoveInfoBar(infobar_a0); |
- EXPECT_EQ(2U, closed_infobar_tracker_.size()); |
+ EXPECT_EQ(1U, closed_infobar_tracker_.size()); |
EXPECT_TRUE(closed_infobar_tracker_.Contains(infobar_a0)); |
} |
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. |
if (BubbleEnabled()) |
ASSERT_EQ(1U, GetBubblesQueueSize(manager_a1)); |
else |
- CheckPermissionMessageSentForTab(1, 0, true); |
+ EXPECT_EQ(1U, infobar_service_for_tab(1)->infobar_count()); |
// Either way, tab B should still have a pending permission request. |
if (BubbleEnabled()) |
@@ -754,20 +787,25 @@ 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)); |
} |
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. |
- if (BubbleEnabled()) { |
+ // 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 (BubbleEnabled()) |
EXPECT_EQ(1U, GetBubblesQueueSize(manager_a0)); |
- } else { |
- EXPECT_EQ(0U, infobar_service()->infobar_count()); |
- CheckPermissionMessageSent(0, true); |
- } |
+ else |
+ EXPECT_EQ(1U, infobar_service()->infobar_count()); |
// The second request should now be visible in tab A1. |
if (BubbleEnabled()) |
@@ -909,8 +947,14 @@ TEST_F(GeolocationPermissionContextTests, LastUsageAuditedMultipleFrames) { |
// Accept the first frame. |
AcceptPrompt(); |
- if (!BubbleEnabled()) |
+ if (!BubbleEnabled()) { |
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()); |
+ } |
CheckTabContentsState(requesting_frame_0, CONTENT_SETTING_ALLOW); |
CheckPermissionMessageSent(0, true); |