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

Unified Diff: chrome/browser/ui/website_settings/permission_bubble_manager_unittest.cc

Issue 292453009: Handles iframe permissions requests separately, in a subsequent bubble. (Closed) Base URL: https://chromium.googlesource.com/chromium/src
Patch Set: fixed iframe check Created 6 years, 7 months 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/ui/website_settings/permission_bubble_manager.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/website_settings/permission_bubble_manager_unittest.cc
diff --git a/chrome/browser/ui/website_settings/permission_bubble_manager_unittest.cc b/chrome/browser/ui/website_settings/permission_bubble_manager_unittest.cc
index 0f43c4f528ee8793003b813e3425a9d0b0176248..8cf3855631cc9b4016aa2daff2cebe234255fa3b 100644
--- a/chrome/browser/ui/website_settings/permission_bubble_manager_unittest.cc
+++ b/chrome/browser/ui/website_settings/permission_bubble_manager_unittest.cc
@@ -64,12 +64,17 @@ class PermissionBubbleManagerTest : public ChromeRenderViewHostTestHarness {
PermissionBubbleManagerTest()
: ChromeRenderViewHostTestHarness(),
request1_("test1"),
- request2_("test2") {}
+ request2_("test2"),
+ iframe_request_same_domain_("iframe",
+ GURL("http://www.google.com/some/url")),
+ iframe_request_other_domain_("iframe",
+ GURL("http://www.youtube.com")) {}
virtual ~PermissionBubbleManagerTest() {}
virtual void SetUp() OVERRIDE {
ChromeRenderViewHostTestHarness::SetUp();
SetContents(CreateTestWebContents());
+ NavigateAndCommit(GURL("http://www.google.com"));
manager_.reset(new PermissionBubbleManager(web_contents()));
}
@@ -91,6 +96,11 @@ class PermissionBubbleManagerTest : public ChromeRenderViewHostTestHarness {
manager_->Closing();
}
+ void WaitForFrameLoad() {
+ manager_->DocumentLoadedInFrame(0, NULL);
+ base::MessageLoop::current()->RunUntilIdle();
+ }
+
void WaitForCoalescing() {
manager_->DocumentOnLoadCompletedInMainFrame();
base::MessageLoop::current()->RunUntilIdle();
@@ -104,6 +114,8 @@ class PermissionBubbleManagerTest : public ChromeRenderViewHostTestHarness {
protected:
MockPermissionBubbleRequest request1_;
MockPermissionBubbleRequest request2_;
+ MockPermissionBubbleRequest iframe_request_same_domain_;
+ MockPermissionBubbleRequest iframe_request_other_domain_;
MockView view_;
scoped_ptr<PermissionBubbleManager> manager_;
};
@@ -321,7 +333,6 @@ TEST_F(PermissionBubbleManagerTest, DuplicateQueuedRequest) {
}
TEST_F(PermissionBubbleManagerTest, ForgetRequestsOnPageNavigation) {
- NavigateAndCommit(GURL("http://www.google.com/"));
manager_->SetView(&view_);
manager_->AddRequest(&request1_);
WaitForCoalescing();
@@ -391,3 +402,122 @@ TEST_F(PermissionBubbleManagerTest, TestCancelPendingRequest) {
EXPECT_TRUE(request2_.finished());
}
+TEST_F(PermissionBubbleManagerTest, MainFrameNoRequestIFrameRequest) {
+ manager_->SetView(&view_);
+ manager_->AddRequest(&iframe_request_same_domain_);
+ WaitForCoalescing();
+ WaitForFrameLoad();
+
+ EXPECT_TRUE(view_.shown_);
+ Closing();
+ EXPECT_TRUE(iframe_request_same_domain_.finished());
+}
+
+TEST_F(PermissionBubbleManagerTest, MainFrameAndIFrameRequestSameDomain) {
+ manager_->SetView(&view_);
+ manager_->AddRequest(&request1_);
+ manager_->AddRequest(&iframe_request_same_domain_);
+ WaitForFrameLoad();
+ WaitForCoalescing();
+
+ EXPECT_TRUE(view_.shown_);
+ Closing();
+ EXPECT_TRUE(request1_.finished());
+ EXPECT_TRUE(iframe_request_same_domain_.finished());
+ EXPECT_FALSE(view_.shown_);
+}
+
+TEST_F(PermissionBubbleManagerTest, MainFrameAndIFrameRequestOtherDomain) {
+ manager_->SetView(&view_);
+ manager_->AddRequest(&request1_);
+ manager_->AddRequest(&iframe_request_other_domain_);
+ WaitForFrameLoad();
+ WaitForCoalescing();
+
+ EXPECT_TRUE(view_.shown_);
+ Closing();
+ EXPECT_TRUE(request1_.finished());
+ EXPECT_FALSE(iframe_request_other_domain_.finished());
+ EXPECT_TRUE(view_.shown_);
+ Closing();
+ EXPECT_TRUE(iframe_request_other_domain_.finished());
+}
+
+TEST_F(PermissionBubbleManagerTest, IFrameRequestWhenMainRequestVisible) {
+ manager_->SetView(&view_);
+ manager_->AddRequest(&request1_);
+ WaitForCoalescing();
+ EXPECT_TRUE(view_.shown_);
+
+ manager_->AddRequest(&iframe_request_same_domain_);
Greg Billock 2014/05/27 20:04:55 Sorry, one other thing I thought of: we want same-
leng 2014/05/27 23:03:55 I made the same assumption - that same-domain ifra
Greg Billock 2014/05/27 23:07:55 ok, cool On 2014/05/27 23:03:55, leng wrote:
+ WaitForFrameLoad();
+ EXPECT_EQ(1u, view_.permission_requests_.size());
+ Closing();
+ EXPECT_TRUE(request1_.finished());
+ EXPECT_FALSE(iframe_request_same_domain_.finished());
+ EXPECT_TRUE(view_.shown_);
+ EXPECT_EQ(1u, view_.permission_requests_.size());
+ Closing();
+ EXPECT_TRUE(iframe_request_same_domain_.finished());
+}
+
+TEST_F(PermissionBubbleManagerTest,
+ IFrameRequestOtherDomainWhenMainRequestVisible) {
+ manager_->SetView(&view_);
+ manager_->AddRequest(&request1_);
+ WaitForCoalescing();
+ EXPECT_TRUE(view_.shown_);
+
+ manager_->AddRequest(&iframe_request_other_domain_);
+ WaitForFrameLoad();
+ Closing();
+ EXPECT_TRUE(request1_.finished());
+ EXPECT_FALSE(iframe_request_other_domain_.finished());
+ EXPECT_TRUE(view_.shown_);
+ Closing();
+ EXPECT_TRUE(iframe_request_other_domain_.finished());
+}
+
+TEST_F(PermissionBubbleManagerTest, IFrameUserGestureRequest) {
+ iframe_request_other_domain_.SetHasUserGesture();
+ manager_->SetView(&view_);
+ manager_->AddRequest(&request1_);
+ manager_->AddRequest(&iframe_request_other_domain_);
+ WaitForFrameLoad();
+ WaitForCoalescing();
+ manager_->AddRequest(&request2_);
+
+ EXPECT_TRUE(view_.shown_);
+ Closing();
+ EXPECT_TRUE(request1_.finished());
+ EXPECT_FALSE(iframe_request_other_domain_.finished());
+ EXPECT_FALSE(request2_.finished());
+ EXPECT_TRUE(view_.shown_);
+ Closing();
+ EXPECT_TRUE(iframe_request_other_domain_.finished());
+ EXPECT_FALSE(request2_.finished());
+}
+
+TEST_F(PermissionBubbleManagerTest, AllUserGestureRequests) {
+ iframe_request_other_domain_.SetHasUserGesture();
+ request2_.SetHasUserGesture();
+ manager_->SetView(&view_);
+ manager_->AddRequest(&request1_);
+ manager_->AddRequest(&iframe_request_other_domain_);
+ WaitForCoalescing();
+ WaitForFrameLoad();
+ manager_->AddRequest(&request2_);
+
+ EXPECT_TRUE(view_.shown_);
+ Closing();
+ EXPECT_TRUE(request1_.finished());
+ EXPECT_FALSE(request2_.finished());
+ EXPECT_FALSE(iframe_request_other_domain_.finished());
+ EXPECT_TRUE(view_.shown_);
+ Closing();
+ EXPECT_TRUE(request2_.finished());
+ EXPECT_FALSE(iframe_request_other_domain_.finished());
+ Closing();
+ EXPECT_TRUE(iframe_request_other_domain_.finished());
+ EXPECT_FALSE(view_.shown_);
+}
« no previous file with comments | « chrome/browser/ui/website_settings/permission_bubble_manager.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698