OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "base/command_line.h" | 5 #include "base/command_line.h" |
6 #include "base/message_loop/message_loop.h" | 6 #include "base/message_loop/message_loop.h" |
7 #include "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
8 #include "chrome/browser/ui/website_settings/mock_permission_bubble_request.h" | 8 #include "chrome/browser/ui/website_settings/mock_permission_bubble_request.h" |
9 #include "chrome/browser/ui/website_settings/permission_bubble_manager.h" | 9 #include "chrome/browser/ui/website_settings/permission_bubble_manager.h" |
10 #include "chrome/browser/ui/website_settings/permission_bubble_request.h" | 10 #include "chrome/browser/ui/website_settings/permission_bubble_request.h" |
(...skipping 503 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
514 EXPECT_FALSE(request2_.finished()); | 514 EXPECT_FALSE(request2_.finished()); |
515 EXPECT_FALSE(iframe_request_other_domain_.finished()); | 515 EXPECT_FALSE(iframe_request_other_domain_.finished()); |
516 EXPECT_TRUE(view_.shown_); | 516 EXPECT_TRUE(view_.shown_); |
517 Closing(); | 517 Closing(); |
518 EXPECT_TRUE(request2_.finished()); | 518 EXPECT_TRUE(request2_.finished()); |
519 EXPECT_FALSE(iframe_request_other_domain_.finished()); | 519 EXPECT_FALSE(iframe_request_other_domain_.finished()); |
520 Closing(); | 520 Closing(); |
521 EXPECT_TRUE(iframe_request_other_domain_.finished()); | 521 EXPECT_TRUE(iframe_request_other_domain_.finished()); |
522 EXPECT_FALSE(view_.shown_); | 522 EXPECT_FALSE(view_.shown_); |
523 } | 523 } |
| 524 |
| 525 TEST_F(PermissionBubbleManagerTest, RequestsWithoutUserGesture) { |
| 526 manager_->RequireUserGesture(true); |
| 527 manager_->SetView(&view_); |
| 528 WaitForFrameLoad(); |
| 529 WaitForCoalescing(); |
| 530 manager_->AddRequest(&request1_); |
| 531 manager_->AddRequest(&iframe_request_other_domain_); |
| 532 manager_->AddRequest(&request2_); |
| 533 base::MessageLoop::current()->RunUntilIdle(); |
| 534 |
| 535 EXPECT_FALSE(view_.shown_); |
| 536 } |
| 537 |
| 538 TEST_F(PermissionBubbleManagerTest, RequestsWithUserGesture) { |
| 539 manager_->RequireUserGesture(true); |
| 540 manager_->SetView(&view_); |
| 541 WaitForFrameLoad(); |
| 542 WaitForCoalescing(); |
| 543 request1_.SetHasUserGesture(); |
| 544 manager_->AddRequest(&request1_); |
| 545 manager_->AddRequest(&iframe_request_other_domain_); |
| 546 manager_->AddRequest(&request2_); |
| 547 base::MessageLoop::current()->RunUntilIdle(); |
| 548 |
| 549 EXPECT_TRUE(view_.shown_); |
| 550 } |
| 551 |
| 552 TEST_F(PermissionBubbleManagerTest, RequestsDontNeedUserGesture) { |
| 553 manager_->SetView(&view_); |
| 554 WaitForFrameLoad(); |
| 555 WaitForCoalescing(); |
| 556 manager_->AddRequest(&request1_); |
| 557 manager_->AddRequest(&iframe_request_other_domain_); |
| 558 manager_->AddRequest(&request2_); |
| 559 base::MessageLoop::current()->RunUntilIdle(); |
| 560 |
| 561 EXPECT_TRUE(view_.shown_); |
| 562 } |
| 563 |
OLD | NEW |