Commit c95a01d7 authored by Andy Paicu's avatar Andy Paicu Committed by Commit Bot

Added automatic tests to replace manual popup tests

This CL adds UI and browser tests for the POPUPS content setting.
These tests are meant to replace the manual tests listed in the bug and
spreadsheet.

Bug: 1093253
Change-Id: Ic7ff67672224b3a8e429c9faab2fe37eb80da169
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2237980Reviewed-by: default avatarClark DuVall <cduvall@chromium.org>
Commit-Queue: Andy Paicu <andypaicu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#778429}
parent db082ec6
......@@ -314,4 +314,39 @@ suite('CategoryDefaultSetting', function() {
prefsCookiesSessionOnly, ContentSettingsTypes.COOKIES,
ContentSetting.SESSION_ONLY, '#subOptionCookiesToggle');
});
test('test popups content setting default value', function() {
testElement.category = ContentSettingsTypes.POPUPS;
return browserProxy.getDefaultValueForContentType(testElement.category)
.then((defaultValue) => {
assertEquals(ContentSetting.BLOCK, defaultValue.setting);
browserProxy.resetResolver('getDefaultValueForContentType');
});
});
test('test popups content setting in BLOCKED state', function() {
const prefs = createSiteSettingsPrefs(
[createContentSettingTypeToValuePair(
ContentSettingsTypes.POPUPS, createDefaultContentSetting({
setting: ContentSetting.BLOCK,
}))],
[]);
return testCategoryEnabled(
testElement, ContentSettingsTypes.POPUPS, prefs, false,
ContentSetting.ALLOW);
});
test('test popups content setting in ALLOWED state', function() {
const prefs = createSiteSettingsPrefs(
[createContentSettingTypeToValuePair(
ContentSettingsTypes.POPUPS, createDefaultContentSetting({
setting: ContentSetting.ALLOW,
}))],
[]);
return testCategoryEnabled(
testElement, ContentSettingsTypes.POPUPS, prefs, true,
ContentSetting.ALLOW);
});
});
......@@ -161,7 +161,7 @@ IN_PROC_BROWSER_TEST_F(PopupBlockerBrowserTest, OpensBlockedPopup) {
}
IN_PROC_BROWSER_TEST_F(PopupBlockerBrowserTest,
AllowsPopupThroughContentSetting) {
AllowsPopupThroughContentSettingException) {
GURL popup_url = embedded_test_server()->GetURL("/echo?popup");
HostContentSettingsMapFactory::GetForBrowserContext(
GetWebContents(original_tab())->GetBrowserContext())
......@@ -176,6 +176,39 @@ IN_PROC_BROWSER_TEST_F(PopupBlockerBrowserTest,
EXPECT_EQ(GetBlockedPopupCount(), 0u);
}
IN_PROC_BROWSER_TEST_F(PopupBlockerBrowserTest,
AllowsPopupThroughContentSettingDefaultValue) {
GURL popup_url = embedded_test_server()->GetURL("/echo?popup");
HostContentSettingsMapFactory::GetForBrowserContext(
GetWebContents(original_tab())->GetBrowserContext())
->SetDefaultContentSetting(ContentSettingsType::POPUPS,
CONTENT_SETTING_ALLOW);
ExecuteScript(
original_tab(),
base::StringPrintf("window.open('%s')", popup_url.spec().c_str()), true);
Tab* new_tab = WaitForNewTab();
ExpectTabURL(new_tab, popup_url);
EXPECT_EQ(GetBlockedPopupCount(), 0u);
}
IN_PROC_BROWSER_TEST_F(PopupBlockerBrowserTest,
BlockPopupThroughContentSettingException) {
GURL popup_url = embedded_test_server()->GetURL("/echo?popup");
HostContentSettingsMapFactory::GetForBrowserContext(
GetWebContents(original_tab())->GetBrowserContext())
->SetDefaultContentSetting(ContentSettingsType::POPUPS,
CONTENT_SETTING_ALLOW);
HostContentSettingsMapFactory::GetForBrowserContext(
GetWebContents(original_tab())->GetBrowserContext())
->SetContentSettingDefaultScope(popup_url, GURL(),
ContentSettingsType::POPUPS,
std::string(), CONTENT_SETTING_BLOCK);
ExecuteScript(
original_tab(),
base::StringPrintf("window.open('%s')", popup_url.spec().c_str()), true);
EXPECT_EQ(GetBlockedPopupCount(), 1u);
}
IN_PROC_BROWSER_TEST_F(PopupBlockerBrowserTest,
BlocksAndOpensPopupFromOpenURL) {
GURL popup_url = embedded_test_server()->GetURL("/echo?popup");
......
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