return popup_blocker_helper->GetBlockedPopupsCount();
}
- void NavigateAndCheckPopupShown(const GURL& url) {
- content::WindowedNotificationObserver observer(
- chrome::NOTIFICATION_TAB_ADDED,
- content::NotificationService::AllSources());
- ui_test_utils::NavigateToURL(browser(), url);
- observer.Wait();
-
- ASSERT_EQ(2u, chrome::GetBrowserCount(browser()->profile(),
- browser()->host_desktop_type()));
-
- ASSERT_EQ(0, GetBlockedContentsCount());
- }
-
enum WhatToExpect {
ExpectPopup,
ExpectTab
DontCheckTitle
};
+ void NavigateAndCheckPopupShown(const GURL& url,
+ WhatToExpect what_to_expect) {
+ content::WindowedNotificationObserver observer(
+ chrome::NOTIFICATION_TAB_ADDED,
+ content::NotificationService::AllSources());
+ ui_test_utils::NavigateToURL(browser(), url);
+ observer.Wait();
+
+ if (what_to_expect == ExpectPopup) {
+ ASSERT_EQ(2u,
+ chrome::GetBrowserCount(browser()->profile(),
+ browser()->host_desktop_type()));
+ } else {
+ ASSERT_EQ(1u,
+ chrome::GetBrowserCount(browser()->profile(),
+ browser()->host_desktop_type()));
+ ASSERT_EQ(2, browser()->tab_strip_model()->count());
+ }
+
+ ASSERT_EQ(0, GetBlockedContentsCount());
+ }
+
// Navigates to the test indicated by |test_name| using |browser| which is
// expected to try to open a popup. Verifies that the popup was blocked and
// then opens the blocked popup. Once the popup stopped loading, verifies
std::string(),
CONTENT_SETTING_ALLOW);
- NavigateAndCheckPopupShown(url);
+ NavigateAndCheckPopupShown(url, ExpectTab);
}
// Verify that content settings are applied based on the top-level frame URL.
// Popup from the iframe should be allowed since the top-level URL is
// whitelisted.
- NavigateAndCheckPopupShown(url);
+ NavigateAndCheckPopupShown(url, ExpectTab);
// Whitelist iframe URL instead.
GURL::Replacements replace_host;
embedded_test_server()->GetURL("/popup_blocker/popup-on-unload.html"));
ui_test_utils::NavigateToURL(browser(), url);
- NavigateAndCheckPopupShown(embedded_test_server()->GetURL("/popup_blocker/"));
+ NavigateAndCheckPopupShown(embedded_test_server()->GetURL("/popup_blocker/"),
+ ExpectPopup);
}
// Verify that when you unblock popup, the popup shows in history and omnibox.
switches::kDisablePopupBlocking);
GURL url(embedded_test_server()->GetURL(
"/popup_blocker/popup-blocked-to-post-blank.html"));
- NavigateAndCheckPopupShown(url);
+ NavigateAndCheckPopupShown(url, ExpectTab);
std::string search_string =
"data:text/html,<title>Popup Success!</title>you should not see this "