Index: chrome/browser/ui/blocked_content/popup_blocker_browsertest.cc |
diff --git a/chrome/browser/ui/blocked_content/popup_blocker_browsertest.cc b/chrome/browser/ui/blocked_content/popup_blocker_browsertest.cc |
index 0170b46f793777dbb6bbc228870853ce237ecae4..951f855883a5ac9de8ba02058ca1306f8baab56d 100644 |
--- a/chrome/browser/ui/blocked_content/popup_blocker_browsertest.cc |
+++ b/chrome/browser/ui/blocked_content/popup_blocker_browsertest.cc |
@@ -113,19 +113,6 @@ class PopupBlockerBrowserTest : public InProcessBrowserTest { |
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 |
@@ -136,6 +123,28 @@ class PopupBlockerBrowserTest : public InProcessBrowserTest { |
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 |
@@ -290,7 +299,7 @@ IN_PROC_BROWSER_TEST_F(PopupBlockerBrowserTest, |
std::string(), |
CONTENT_SETTING_ALLOW); |
- NavigateAndCheckPopupShown(url); |
+ NavigateAndCheckPopupShown(url, ExpectTab); |
} |
// Verify that content settings are applied based on the top-level frame URL. |
@@ -306,7 +315,7 @@ IN_PROC_BROWSER_TEST_F(PopupBlockerBrowserTest, |
// 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; |
@@ -337,7 +346,8 @@ IN_PROC_BROWSER_TEST_F(PopupBlockerBrowserTest, |
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. |
@@ -347,7 +357,7 @@ IN_PROC_BROWSER_TEST_F(PopupBlockerBrowserTest, |
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 " |