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

Unified Diff: chrome/browser/ui/blocked_content/popup_blocker_browsertest.cc

Issue 2778113003: Fix popunders spawned from a subframe. (Closed)
Patch Set: Created 3 years, 9 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 | « no previous file | chrome/test/data/popup_blocker/popup-subframe.html » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 5be1073c34d182b7bd857e07962e0fc1598fcd17..538ad3f690b1fa2f5f51e11b7eda2623ec6b0c88 100644
--- a/chrome/browser/ui/blocked_content/popup_blocker_browsertest.cc
+++ b/chrome/browser/ui/blocked_content/popup_blocker_browsertest.cc
@@ -601,6 +601,44 @@ IN_PROC_BROWSER_TEST_F(PopupBlockerBrowserTest, ModalPopUnderWindowOpener) {
ASSERT_EQ(popup_browser, chrome::FindLastActive());
}
+// Verify that popunders from subframes are prevented. https://crbug.com/705316
+IN_PROC_BROWSER_TEST_F(PopupBlockerBrowserTest, ModalPopUnderSubframe) {
+ WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents();
+ GURL url(embedded_test_server()->GetURL(
+ "/popup_blocker/popup-window-subframe-open.html"));
+ HostContentSettingsMapFactory::GetForProfile(browser()->profile())
+ ->SetContentSettingDefaultScope(url, GURL(), CONTENT_SETTINGS_TYPE_POPUPS,
+ std::string(), CONTENT_SETTING_ALLOW);
+
+ NavigateAndCheckPopupShown(url, ExpectPopup);
+
+ Browser* popup_browser = chrome::FindLastActive();
+ ASSERT_NE(popup_browser, browser());
+
+// Showing an alert will raise the tab over the popup.
+#if !defined(OS_MACOSX)
+ // Mac doesn't activate the browser during modal dialogs, see
+ // https://crbug.com/687732 for details.
+ ui_test_utils::BrowserActivationWaiter alert_waiter(browser());
+#endif
+ tab->GetMainFrame()->ExecuteJavaScriptForTests(base::UTF8ToUTF16("alert()"));
+ app_modal::AppModalDialog* dialog = ui_test_utils::WaitForAppModalDialog();
+#if !defined(OS_MACOSX)
+ if (chrome::FindLastActive() != browser())
+ alert_waiter.WaitForActivation();
+#endif
+
+ // Verify that after the dialog is closed, the popup is in front again.
+ ASSERT_TRUE(dialog->IsJavaScriptModalDialog());
+ app_modal::JavaScriptAppModalDialog* js_dialog =
+ static_cast<app_modal::JavaScriptAppModalDialog*>(dialog);
+
+ ui_test_utils::BrowserActivationWaiter waiter(popup_browser);
+ js_dialog->native_dialog()->AcceptAppModalDialog();
+ waiter.WaitForActivation();
+ ASSERT_EQ(popup_browser, chrome::FindLastActive());
+}
+
// Verify that popups without an opener don't interfere with popup blocking.
IN_PROC_BROWSER_TEST_F(PopupBlockerBrowserTest, ModalPopUnderNoOpener) {
WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents();
« no previous file with comments | « no previous file | chrome/test/data/popup_blocker/popup-subframe.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698