Commit 0402e187 authored by Sam Sebree's avatar Sam Sebree Committed by Commit Bot

Bugfix: Popup blocker default state not considered

This change addresses an issue in which, when the context URL is not
available, popups continue to be blocked despite disabling popup
blocking.

Bug: 1128530
Change-Id: Ie25127f44da29a88e479ad1eca14ea3a69221b8d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2425127Reviewed-by: default avatarAvi Drissman <avi@chromium.org>
Commit-Queue: Sam Sebree <sasebree@microsoft.com>
Cr-Commit-Position: refs/heads/master@{#810788}
parent 4f3d0ebe
...@@ -461,6 +461,17 @@ IN_PROC_BROWSER_TEST_F(PopupBlockerBrowserTest, NoPopupsLaunchWhenTabIsClosed) { ...@@ -461,6 +461,17 @@ IN_PROC_BROWSER_TEST_F(PopupBlockerBrowserTest, NoPopupsLaunchWhenTabIsClosed) {
ASSERT_EQ(1u, chrome::GetBrowserCount(browser()->profile())); ASSERT_EQ(1u, chrome::GetBrowserCount(browser()->profile()));
} }
IN_PROC_BROWSER_TEST_F(PopupBlockerBrowserTest,
PopupsAllowedWhenPopupBlockingIsDisabled) {
base::CommandLine::ForCurrentProcess()->AppendSwitch(
embedder_support::kDisablePopupBlocking);
GURL url(
embedded_test_server()->GetURL("/popup_blocker/popup-window-open.html"));
NavigateAndCheckPopupShown(url, kExpectPopup);
}
// This only exists for the AllowPopupsWhenTabIsClosedWithSpecialPolicy test. // This only exists for the AllowPopupsWhenTabIsClosedWithSpecialPolicy test.
// Remove this in Chrome 88. https://crbug.com/937569 // Remove this in Chrome 88. https://crbug.com/937569
class PopupBlockerSpecialPolicyBrowserTest : public PopupBlockerBrowserTest { class PopupBlockerSpecialPolicyBrowserTest : public PopupBlockerBrowserTest {
......
...@@ -42,12 +42,18 @@ PopupBlockType ShouldBlockPopup(content::WebContents* web_contents, ...@@ -42,12 +42,18 @@ PopupBlockType ShouldBlockPopup(content::WebContents* web_contents,
// unloading page. // unloading page.
const GURL& url = const GURL& url =
opener_url ? *opener_url : web_contents->GetLastCommittedURL(); opener_url ? *opener_url : web_contents->GetLastCommittedURL();
if (url.is_valid() && ContentSetting cs;
settings_map->GetContentSetting(url, url, ContentSettingsType::POPUPS, if (url.is_valid()) {
std::string()) == CONTENT_SETTING_ALLOW) { cs = settings_map->GetContentSetting(url, url, ContentSettingsType::POPUPS,
return PopupBlockType::kNotBlocked; std::string());
} else {
cs = settings_map->GetDefaultContentSetting(ContentSettingsType::POPUPS,
nullptr);
} }
if (cs == CONTENT_SETTING_ALLOW)
return PopupBlockType::kNotBlocked;
if (!user_gesture) if (!user_gesture)
return PopupBlockType::kNoGesture; return PopupBlockType::kNoGesture;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment