OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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 #import "ios/chrome/browser/web/blocked_popup_tab_helper.h" | 5 #import "ios/chrome/browser/web/blocked_popup_tab_helper.h" |
6 | 6 |
7 #include "base/memory/ptr_util.h" | 7 #include "base/memory/ptr_util.h" |
8 #include "components/content_settings/core/browser/host_content_settings_map.h" | 8 #include "components/content_settings/core/browser/host_content_settings_map.h" |
9 #include "components/infobars/core/confirm_infobar_delegate.h" | 9 #include "components/infobars/core/confirm_infobar_delegate.h" |
10 #include "components/infobars/core/infobar.h" | 10 #include "components/infobars/core/infobar.h" |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 infobars::InfoBar* infobar = GetInfobarManager()->infobar_at(0); | 95 infobars::InfoBar* infobar = GetInfobarManager()->infobar_at(0); |
96 auto* delegate = infobar->delegate()->AsConfirmInfoBarDelegate(); | 96 auto* delegate = infobar->delegate()->AsConfirmInfoBarDelegate(); |
97 ASSERT_TRUE(delegate); | 97 ASSERT_TRUE(delegate); |
98 ASSERT_FALSE(web_state_delegate_.last_open_url_request()); | 98 ASSERT_FALSE(web_state_delegate_.last_open_url_request()); |
99 delegate->Accept(); | 99 delegate->Accept(); |
100 | 100 |
101 // Verify that popups are allowed for |test_url|. | 101 // Verify that popups are allowed for |test_url|. |
102 EXPECT_FALSE(GetBlockedPopupTabHelper()->ShouldBlockPopup(source_url)); | 102 EXPECT_FALSE(GetBlockedPopupTabHelper()->ShouldBlockPopup(source_url)); |
103 | 103 |
104 // Verify that child window was open. | 104 // Verify that child window was open. |
105 auto open_url_request = web_state_delegate_.last_open_url_request(); | 105 auto* open_url_request = web_state_delegate_.last_open_url_request(); |
106 ASSERT_TRUE(open_url_request); | 106 ASSERT_TRUE(open_url_request); |
107 EXPECT_EQ(web_state(), open_url_request->web_state); | 107 EXPECT_EQ(web_state(), open_url_request->web_state); |
108 WebState::OpenURLParams params = open_url_request->params; | 108 WebState::OpenURLParams params = open_url_request->params; |
109 EXPECT_EQ(target_url, params.url); | 109 EXPECT_EQ(target_url, params.url); |
110 EXPECT_EQ(source_url, params.referrer.url); | 110 EXPECT_EQ(source_url, params.referrer.url); |
111 EXPECT_EQ(web::ReferrerPolicyDefault, params.referrer.policy); | 111 EXPECT_EQ(web::ReferrerPolicyDefault, params.referrer.policy); |
112 EXPECT_EQ(WindowOpenDisposition::NEW_POPUP, params.disposition); | 112 EXPECT_EQ(WindowOpenDisposition::NEW_POPUP, params.disposition); |
113 EXPECT_TRUE( | 113 EXPECT_TRUE( |
114 PageTransitionCoreTypeIs(params.transition, ui::PAGE_TRANSITION_LINK)); | 114 PageTransitionCoreTypeIs(params.transition, ui::PAGE_TRANSITION_LINK)); |
115 EXPECT_TRUE(params.is_renderer_initiated); | 115 EXPECT_TRUE(params.is_renderer_initiated); |
(...skipping 28 matching lines...) Expand all Loading... |
144 GetBlockedPopupTabHelper()->HandlePopup(popup_info); | 144 GetBlockedPopupTabHelper()->HandlePopup(popup_info); |
145 ASSERT_EQ(1U, GetInfobarManager()->infobar_count()); | 145 ASSERT_EQ(1U, GetInfobarManager()->infobar_count()); |
146 EXPECT_TRUE(IsObservingSources()); | 146 EXPECT_TRUE(IsObservingSources()); |
147 | 147 |
148 // Dismiss the infobar and check that the tab helper no longer has any | 148 // Dismiss the infobar and check that the tab helper no longer has any |
149 // registered observers. | 149 // registered observers. |
150 GetInfobarManager()->infobar_at(0)->RemoveSelf(); | 150 GetInfobarManager()->infobar_at(0)->RemoveSelf(); |
151 EXPECT_EQ(0U, GetInfobarManager()->infobar_count()); | 151 EXPECT_EQ(0U, GetInfobarManager()->infobar_count()); |
152 EXPECT_FALSE(IsObservingSources()); | 152 EXPECT_FALSE(IsObservingSources()); |
153 } | 153 } |
OLD | NEW |